☕
Pause for minutes until .
Remaining:
Pius Walter
T4INF1202: Kryptologie
Part 3: Authentication functions
2026-04-14
Recap
  • Last week we discussed hash functions and their different flavors in detail
  • Today, we will build upon that foundation and build authentication functions
  • The goal is to meet one of our security goals, data integrity
Hashing vs. authentication
  • Imagine you are transmitting data over an insecure line
  • Confidentiality is not important to you, data integrity is
  • Implementation: You use a cryptographically secure hash function like SHA-256 and append the hash over the data to your datagram
  • What is the issue with this?
Hashing vs. authentication
  • Such a scheme is resilient against faults, i.e., non-targeted attacks
  • Protects against bit/burst errors nicely
  • It does not protect against a malicious, deliberate attacker
  • The attacker can simply alter the data, recompute the MICMessage Integrity Code and alter the MICMessage Integrity Code field of the message
Hashing vs. authentication
  • In other words, it may not be the case that the attacker is able to recompute the MICMessage Integrity Code
  • The MICMessage Integrity Code needs to depend on something secret, something known only to the communicating parties
  • We need to introduce a key into the system that is used to authenticate (and validate) the data
Hash function
Authentication function
Hashing vs. authentication
Relation between hashing and authentication
Signature function
  • MICMessage Integrity Codes are, in some instances, also referred to as symmetric signatures
  • Both symmetric and asymmetric signatures are typically denoted by the letter Q4mta4Ck5NLH\sigmaZf1qH71g5gJY
  • Symmetric refers to the property that it is the identical key Q4mta4Ck5NLHKZf1qH71g5gJY on both sides which is used to generate and validate the signature
Symmetric signing
  • Assume sender and receiver have negotiated a secret key Q4mta4Ck5NLHKZf1qH71g5gJY only known to the two of them
  • Then a message Q4mta4Ck5NLHmZf1qH71g5gJY can be authenticated and transmitted: Q4mta4Ck5NLHm\ ||\ \sigma(m, K)Zf1qH71g5gJY
  • The receiving party also computes Q4mta4Ck5NLH\sigma(m, K)Zf1qH71g5gJY and compares if that value is the same as that was appended to the message
Symmetric signing issue
  • One fundamental problem with this scheme is the following: Any of the two parties can claim the other sent them a “signed” message
  • Both parties need to have Q4mta4Ck5NLHKZf1qH71g5gJY, therefore a “signed” message can have originated from either one
  • It's impossible to tell who the original author is
  • Symmetric authentication can therefore never achieve non-repudiation
Constructing an authentication function
  • How can we easily introduce a key into a hash function construct so that the MICMessage Integrity Code can only be created by those who know the key?
  • What would be your idea?
Naive implementation
  • The simplest way of doing this is by simply concatenating the key Q4mta4Ck5NLHKZf1qH71g5gJY to the data
  • I.e., instead of computing just a hash function Q4mta4Ck5NLHHZf1qH71g5gJY over a message Q4mta4Ck5NLHmZf1qH71g5gJY, we add the secret key Q4mta4Ck5NLHKZf1qH71g5gJY
  • Q4mta4Ck5NLHH(m) \rightarrow H(K\ ||\ m)Zf1qH71g5gJY
  • Or should we rather do Q4mta4Ck5NLHH(m\ ||\ K)Zf1qH71g5gJY? Any difference?
Append vs. prepend construction
  • Q4mta4Ck5NLHH(m\ ||\ K)Zf1qH71g5gJY is called the append-only construction
  • Q4mta4Ck5NLHH(K\ ||\ m)Zf1qH71g5gJY is called the prepend-only construction
  • Both are used in various contexts as naive implementations of an authentication function
  • Interestingly, neither are secure
Append-only authenticator
Prepend-only authenticator
Authentication security
  • Things we want in an authentication function:
    • Even if a collision can be found in the hash function, we do not want that to translate to a collision in the authentication function
    • From messages and their respective MICMessage Integrity Codes, no new MICMessage Integrity Codes for different messages can be efficiently computed
Append-only security
  • Recall the append-only construction: Q4mta4Ck5NLHH(m\ ||\ K)Zf1qH71g5gJY
  • Think about the internal state of the hash function during the computation of the message
  • If there are two messages Q4mta4Ck5NLHmZf1qH71g5gJY and Q4mta4Ck5NLHm'Zf1qH71g5gJY that lead to a collision, what is the internal state of Q4mta4Ck5NLHHZf1qH71g5gJY going to be after input of Q4mta4Ck5NLHmZf1qH71g5gJY or Q4mta4Ck5NLHm'Zf1qH71g5gJY?
Append-only security
  • The internal state of two hash functions that produce a collision is synchronized, they're in lockstep
  • This means any data that is fed into Q4mta4Ck5NLHHZf1qH71g5gJY after that leads to the deterministically identical result
  • In consequence, this means that a collision of the hash function in an append-only authenticator just appends an (unknown) key Q4mta4Ck5NLHKZf1qH71g5gJY
  • Since the states are synchronized, the MICMessage Integrity Codes are going to be identical
Append-only security
  • Append-only authenticators therefore have the undesirable property that collisions in Q4mta4Ck5NLHHZf1qH71g5gJY automatically give a valid collision in the authenticator
  • No extra work is required, it's an inherent property of the construction
  • Therefore, not a good choice for an authenticator
Prepend-only security
  • Note that this does not apply to the prepend-only construction
  • Since Q4mta4Ck5NLHH(K\ ||\ m)Zf1qH71g5gJY is the authenticator, at the point where Q4mta4Ck5NLHKZf1qH71g5gJY has been fed to the authenticator, the internal states will be completely different
  • Therefore, anything appended afterwards (such as Q4mta4Ck5NLHmZf1qH71g5gJY) modifies the state in different ways
Prepend-only security
  • Prepend-only suffers from a different flaw, however – an even more problematic one
  • Think about the internal state of Q4mta4Ck5NLHHZf1qH71g5gJY after the computation of the full MICMessage Integrity Code, i.e., after Q4mta4Ck5NLHH(K\ ||\ m)Zf1qH71g5gJY
  • Consider a case where the length of Q4mta4Ck5NLHK\ ||\ mZf1qH71g5gJY together with internal length fields is a multiple of the internal block size
  • The output value now corresponds tightly with the internal state of Q4mta4Ck5NLHHZf1qH71g5gJY after the digesting the message
Prepend-only security
  • This gives rise to a so-called extension attack
  • An attacker observes a message that is the correct length and the attacker also knows the legitimate (public) MICMessage Integrity Code of that message
  • They then infer the internal state just before emission of the MICMessage Integrity Code
Prepend-only security
  • When the internal state is known at this point in time, the attacker can simply reset their Q4mta4Ck5NLHHZf1qH71g5gJY to that internal state
  • Then append arbitrary malicious data and compute a valid MICMessage Integrity Code
  • Knowledge of the key is not necessary at all, yet valid forgeries can be produced efficiently by the adversary
Target security level
  • One thing to keep in mind: No weaseling out of security guarantees.
  • If an authentication function allows any forgeries or is not robust against collisions, we consider it broken
  • Common fallacy: “but the forged messages do not make sense, it's not that bad”
  • Yes, it is. It's exactly that bad.
Abstraction layer
  • When designing cryptographic primitives, we provide a layer of abstraction to the system
  • Above layers need to be able to rely on that abstraction, regardless of the circumstances or use case
  • This is why collision attacks are relevant for hash function security and why forgeries are breaking the system, regardless of their perceived meaningfulness
Naive MAC constructions
  • Build robust authentication functions is surprisingly complex
  • It should never be done manually, this is a huge warning sign
  • There are internal nuances to this that make accurate security estimation exceptionally difficult
  • How many of the aforementioned issues would you have detected in code review?
Robust MAC constructions
  • So what are robust alternatives we can use to authenticate data?
  • Do you know any?
Authentication functions
HMAC
  • HMACKeyed-Hash Message Authentication Code is probably the most common and only relies on an unmodified hash function internally
  • Essentially, HMACKeyed-Hash Message Authentication Code is the construction Q4mta4Ck5NLH\sigma(m, K) = H((K \oplus p_1)\ ||\ H((K \oplus p_2)\ ||\ m))Zf1qH71g5gJY
  • Q4mta4Ck5NLHp_1Zf1qH71g5gJY and Q4mta4Ck5NLHp_2Zf1qH71g5gJY are fixed padding blocks
  • The symbol Q4mta4Ck5NLH\sigmaZf1qH71g5gJY is used to denote a signature (in this case, a symmetric signature)
UMAC and CMAC
Encryption and authentication
  • During typical communication, we want to achieve both confidentiality and data integrity
  • This means a cipher is already present (achieving confidentiality) and additionally an authenticator is applied (for data integrity)
  • A typical construction is EtAEncrypt-then-Authenticate (sometimes also called EtM, encrypt-then-MACMessage Authentication Code)
Encryption and authentication
  • Having encryption and authentication separate creates the possibility of doing things wrong
  • Recall that the order of operations is critical to achieve security
  • When designing cryptographic constructions, we want those to be as rigid as possible, so they cannot be accidentally misused
Encrypted authentication
Encrypted authentication
Encrypted authentication
Encrypted authentication
  • Key drawback of AEADAuthenticated Encryption with Associated Data schemes is the nonce (number used once)
  • Encryption depends on this randomized value (and hence is nondeterministic)
  • Depending on the scheme, there is loss of various security guarantees if a nonce is actually reused
  • Can be catastrophic, i.e., loss of full confidentiality and data integrity. Caveat emptor.
Encrypted authentication
Encrypted authentication
What achieves AEAD?
Conclusion
43
Summary
Complexity of operation
  • The constructions that are typically used are proven and have been peer-reviewed thoroughly
  • It is highly unlikely to be able to naively put together an authenticator which does not exhibit a security issue
  • Much more complex than it superficially looks – do not invent your own crypto
  • Easy to build something that you cannot break, difficult to build something that nobody can break
Thank you!
Any questions?