TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

AES-GCM and breaking it on nonce reuse

141 pointsby _tk_12 months ago

13 comments

WantonQuantum12 months ago
&quot;At first glance, this seems fine, but it is not. If an attacker knows the plaintext p1 and the ciphertext c1, then they can compute the keystream by XORing p1 and c1 together&quot;<p>Also, if the attacker only has c1 and c2, if the nonce is reused then c1 xor c2 will be the same as p1 xor p2. In most cases, two plaintexts xored with each other are trivial to decode.
评论 #40655572 未加载
jedisct112 months ago
Not just AES-GCM.<p>The vast majority of encryption algorithms must be used in a nonce-respecting scenario. This is part of the contract to achieve the claimed security properties.<p>Alternatives require multiple passes over the data, which is not applicable to some protocols in addition to having performance implications.<p>Common protocols such as TLS transparently handle nonces in a safe way. But the primitives used in TLS may require additional steps to be safely used is other contexts, especially in distributed systems.<p>Whenever applications try to use these primitives directly, using a fixed key and picking nonces at random is a very common practice. Unfortunately, due to their small size, nonces collisions can quickly happen.<p>We&#x27;re missing standard constructions with large nonces that would alleviate this problem, because IETF protocols haven&#x27;t needed them. But there&#x27;s a lot of evidence that many custom applications and protocols do.<p>There are multiple great proposals to derive AES-GCM subkeys and nonces from a key and a large nonce. We may expect convergence and adoption in crypto libraries soon.<p>Until then, constructions such as XSalsa20 and XChaCha20 are widely implemented and deployed. If you don&#x27;t need NIST compliance, they&#x27;re excellent choices.<p>But my recommendation today would be to replace AES-GCM with the AEGIS family of algorithms whenever possible. They have nice properties that AES-GCM doesn&#x27;t have, including more comfortable usage limits, much better performance and large nonces up to 256 bits.<p>This page [1] and that draft [2] summarize usage limits of common constructions, including when using random nonces.<p>[2] <a href="https:&#x2F;&#x2F;doc.libsodium.org&#x2F;secret-key_cryptography&#x2F;aead" rel="nofollow">https:&#x2F;&#x2F;doc.libsodium.org&#x2F;secret-key_cryptography&#x2F;aead</a><p>[3] <a href="https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;draft-irtf-cfrg-aead-limits&#x2F;" rel="nofollow">https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;draft-irtf-cfrg-aead-limits...</a>
chkas12 months ago
I find the article a little confusing. IMHO the point is that you must NEVER reuse an XOR key sequence for stream cipher encryption. With RC4, this meant that you could never use the same key. With modern stream ciphers there is the nonce for this - the CTR mode of a block cipher is also a stream cipher. (GCM mode is just an extension of CTR mode for authentication).<p>I&#x27;ve put together a little online demo tutorial (in my teaching and learning programming language).<p><a href="https:&#x2F;&#x2F;easylang.online&#x2F;apps&#x2F;tut_cipher.html?v=2405e" rel="nofollow">https:&#x2F;&#x2F;easylang.online&#x2F;apps&#x2F;tut_cipher.html?v=2405e</a>
评论 #40660392 未加载
bux9312 months ago
I dunno, nonce means number-used-once, it should be kinda obvious that it should be used only once?
评论 #40656193 未加载
评论 #40656562 未加载
评论 #40656892 未加载
评论 #40660957 未加载
评论 #40671907 未加载
benlivengood12 months ago
I&#x27;m curious for the use-cases where people have to maintain a key over a long period where the choice of nonce can&#x27;t be made strictly non-decreasing or otherwise prevent nonce reuse (per key).<p>I can imagine VPNs or other packetized communications potentially running into this problem, e.g. with N parties needing to encrypt messages under the same key to each other without coordination on nonces. The worst case I can think of is a large number of devices with a baked-in key and secure RNG but no non-volatile storage. They can&#x27;t generate more than 2^48 messages with AES-GCM or risk collision.<p>Full disk encryption has always had a similar problem; generally a single long-lived master key that individual sectors or blocks are encrypted by, often without the additional storage set aside for IVs or nonces (which would break exact sector to sector mapping of encrypted virtual disk to plaintext disk). That leaves IV-derivation to be static per block offset&#x2F;number, or key derivation on master key and block offset&#x2F;number.<p>Devices without secure RNGs are also at risk (microcontrollers with no non-volatile storage that restart a lot, for example).<p>I&#x27;m curious if there are any other hard cases where nonce reuse becomes a risk in practice.
jas-12 months ago
Great post! Thanks for taking the time to put this up.<p>What do you think the ratios are regarding improper use of nonce with this mode?<p>Most implementations that I am familiar with intentionally generate a random nonce to help lower the percentage of app devs doing this very thing
评论 #40655285 未加载
评论 #40654380 未加载
评论 #40654832 未加载
评论 #40654365 未加载
e____g12 months ago
It&#x27;s worth mentioning AES-GCM-SIV[1], which is the fix for this issue.<p>[1] <a href="https:&#x2F;&#x2F;www.rfc-editor.org&#x2F;rfc&#x2F;rfc8452.html" rel="nofollow">https:&#x2F;&#x2F;www.rfc-editor.org&#x2F;rfc&#x2F;rfc8452.html</a>
评论 #40654935 未加载
评论 #40655079 未加载
评论 #40656711 未加载
api12 months ago
GCM is well known to have sudden death on nonce reuse, which is why we used GCM-SIV for the ZeroTier v1 protocol. (Our new protocol that stiiiil is not in product is Noise based.)<p>Nonce reuse in SIV is much less catastrophic. Reuse of a nonce can reveal if two packets are identical but doesn’t let you do anything else.<p>Of course there are categorically better modes than GCM but they are not widely supported. ChaChaPoly is better cryptographically but no hardware acceleration, which matters on small devices.
RA2lover12 months ago
If the attacker never gets a hold of a plaintext-ciphertext pair, how well does AES-GCM with nonce reuse hold up?
评论 #40682062 未加载
jobarion12 months ago
I understand that nonce reuse is catastrophic, but I don&#x27;t think I understand when it can be abused. Does the attacker have to know which two messages share a nonce? Is knowing that out of N messages, at least one pair shares a nonce already enough?
评论 #40657072 未加载
评论 #40659219 未加载
wigster12 months ago
nonce really should be renamed. if only for british slang avoidance.
评论 #40657742 未加载
commandersaki12 months ago
Excellent article was a very insightful read.
nckslvrmn12 months ago
alright, whomever owns this website got me with that &quot;Activate Windows&quot; footer.