4 ms·
I think you're confused on nomenclature here. GCM is both an authentication method and encryption mode. The big benefit is its all specified as one primitive b
by bawolff 5y ago
I think you're confused on nomenclature here.
GCM is both an authentication method and encryption mode. The big benefit is its all specified as one primitive because combining primitives is where people often screw up.
HMAC-SHA1 is an authentication mechanism, there's various ways you can combine it with something like AES-CTR or AES-CBC to make something secure, but also plenty of ways to screw it up. Saying something like AES-SHA1 is meaningless because there's no standard way to combine those two, so you dont know what the person is doing, and you still dont know what the mode is.
- rsj_hn 5y agoI don't believe they are confused about the nomenclature, as everything the parent said was correct. In terms of there not being standard ways to add an HMAC to an encrypted string, there are plenty of standard ways to do that. How do you think people implemented secure channels before Cisco released AES-GCM to speed up their VPNs? Just let attackers modify payloads? SSL/TLS, SSH, IPsec and many other widely used secure channel protocols were over a decade old before anyone standardized an authenticated encryption mode. But none of these widely used and well-standardized protocols require an authenticated encryption mode even though they all have both authentication and encryption as security properties. Authenticated encryption doesn't give you anything other than performance over the standard encrypt + tag approach (which is still widely used). And AES-GCM has some drawbacks that encrypt + tag do not (although the performance gains usually trump the drawbacks).
- tptacek 5y agoAES+HMAC is harder to screw up than GCM, which is notoriously brittle. In particular: AES-CBC + HMAC doesn't fail catastrophically if randomness fails somehow, and GCM does.
- KMag 5y agoIs there a well-reviewed paranoid alternative to libnacl/libsodium, given that ChaCha20-Poly1305 is just as brittle to nonce reuse as AES-GCM? I trust libsodium/libnacl's randombytes_buf to give me unique nonces as long as I rekey often enough. However, for those who are still rolling their own crypto because they're paranoid about RNG issues, is there a paranoid alternative I can point to in order to tell them they still shouldn't be rolling their own?
- unscaled 5y agoI don't think it is _just_ as brittle. There are two mitigating factors: 1. XChaCha20-Poly1305 (I think you _should_ be using the extended nonce version if you're going for a random nonce) ihas twice the amount of bits of AES-GCM. That alone make birthday collisions an entire universe of order of magnitudes less likely. 2. I might be wrong here, but I'm not quite sure if the Poly1305 MAC itself is as brittle as the GHASH MAC in GCM. That being said, if you're really paranoid about your RNG, even the greater safety margins won't help. If you use the Sony PS3 RNG which always returns 4, it doesn't matter how many bits of random nonce you've got. You do have nonce-misuse resistant constructions such AES-GCM-SIV. I'm not a cryptographer so I can't comment about how well reviewed they are, but they are only claim to protect you against accidental nonce misuse, not intentionally fixed nonces, so if you have the legendary PS3 RNG, I guess it's no dice (sorry for the pun).
- KMag 5y agoPoint taken about different partitions of the IV into counter and nonce. As far as GCM GHASH vs Poly1305, they use the same math. Just one is in a Galois field modulo the prime 2**130 - 5 and the other is in a 128-bit binary Galois field reduced by a fixed primitive polynomial (the lexographically smallest 128-bit primitive binary polynomial, IIRC). Poly1305 does drop two bits of the 130-bit result field element when outputting the tag, so I guess that does provide a bit more work for an attacker, but they're both simple polynomial evaluations in finite fields of similar size. Breaking them is just finite field algebra if the r and s values are reused. Poly1305 is a MAC taken by calculating the tag: def tag(r, s, message): v = 0 # No associated data case for chunk in message: v += chunk + 2**128 v = (v * r) % (2**130 - 5) return ((v + s) % (2**130 - 5)) % 2**128 The GCM GHASH tag is: # multiply() is multiplication in GF 2**128 # add() is addition in GF 2**128 (a.k.a. 128-bit XOR) def tag(key, iv, message): r = AES_encrypt(key, 0) s = AES_encrypt(key, iv) v = 0 # No associated data case for chunk in message: v = add(v, chunk) v = multiply(v, r) return add(v, s) (I think the extra 2**128 addition inside the Poly1305 loop is to ensure the function doesn't have a fixed point at zero, but I'm not sure.)