Galois/Counter Mode and random nonces
neilmadden.blog
neilmadden.blog
The paper is also extremely approachable.
https://cr.yp.to/snuffle/xsalsa-20110204.pdf
I wonder if processes like this extend cryptographically in most symmetric ciphers. To add more nonce, encrypt your nonce, output becomes key for next round, add more nonce, repeat. Like all things crypto though, your search space could absolutely collapse if the cipher doesn't have the right properties.
It stems from hubris I see repeatedly in the software engineering industry. "I know the constraints and am capable of engineering to them, so don't lecture me about the potential dangers. I'll just make sure we do it right, because I'm smart and capable and can do it right."
They think the problem they need to solve is to write code that's correct today, while the actual problem they need to solve is that it remains correct tomorrow, next quarter, next year, and next decade. Based on repeated failures in this category I've personally witnessed, the majority of software engineers with fewer than ~10 years of industry experience lack an intuition about how software changes over time as people come and go.
I find it amusing in spite of the various words that have fallen out of favour in recent times for political reasons, "nonce" continues to soldier on.
I am in no great hurry to change the word though. It's not something that comes up much outside of extremely technical contexts, and whilst it's a bad word, its regional character and multiple meanings kinda make it fine. It's not like it is being used for the meaning that's offensive, the meanings have unrelated histories (and the offensive one is much newer).
I don't think it would be right to change an ordinary English word because it sounded similar to an offensive word in a foreign language, and I think that's essentially what's happened here.
See also “Fanny pack” which has made its way into British English despite the crudeness.
I do wish there was some alternative word so that I can discuss cryptography with my countryfolk.
They already special-cased 96 bits, so couldn't they have special-cased 128 bits to be direct addition, without concatenation?
Except for subsequent experiences showing us that reliably keeping track of a counter can be a lot harder than it first appears, hence the attractiveness of randomized nonces.
There is also an internet draft on it: https://datatracker.ietf.org/doc/draft-gueron-cfrg-dndkgcm/
> AES-GCM-SIV is a mode of operation for the Advanced Encryption Standard which provides similar performance to Galois/Counter Mode as well as misuse resistance in the event of the reuse of a cryptographic nonce. The construction is defined in RFC 8452.[1]
> The solution they designed is described in that linked paper: AES-GCM-SIV, which is able to tolerate some number of nonce collisions, but under a weaker notion of security that is only really applicable to that use-case (where the data being encrypted is itself random).
AES-GCM breaks catastrophically if you reuse a nonce; but the only thing that happens if you reuse a nonce with AES-GCM-SIV for two messages is that an attacker can see if the messages are equal (since AES-GCM-SIV is a deterministic algorithm, this is pretty much unavoidable). So yes, "weaker notion of security", but still applicable to a lot more than just that use-case. I wonder why AES-GCM-SIV is not used more, since it's so developer-friendly and misuse resistant.
Being able to see if two messages are equal means that it doesn’t even achieve IND-CPA security (when nonces repeat). Although this may seem like a small loss of security, it can have significant consequences. For example, when you are performing encryption of long messages, you generally want to split them into smallish chunks -- otherwise you’ll likely have to release unverified plaintext during decryption unless you buffer the entire message in memory. But now if your AEAD reveals message equality, like AES-GCM-SIV does under nonce reuse, then an attacker can see when chunks are equal if you are not careful. So you can end up vulnerable to the kind of chosen plaintext attacks that are devastating against ECB encryption.
Phillip Rogaway, co-inventor of the original SIV mode and the MRAE security model, discusses BEAST-style chosen plaintext attacks against online encryption modes using MRAE schemes in https://eprint.iacr.org/2015/189.pdf. As he says in that paper: "The paper defining MRAE never suggested that nonce-reuse was OK.” It leads to security weaknesses, and AES-GCM-SIV has increasing likelihood of nonce reuse after 2^32 messages.
So, yes, AES-GCM-SIV is a lovely piece of work, but if you want to encrypt large numbers of messages with a single key, then you need to be very aware of the security definitions. I wouldn’t recommend it for general use.
While I agree on your cautions, this is still an exceptionally large number. Also AFAIK the actual bound depends on the message size, e.g. you can "safely" encrypt 2^64 messages of ~128 KiB each with the identical key but random nonce. So as long as one keep using as random nonce as possible but allowing for a few exceptional reuses, casual developers indeed have a very low chance to actually reach that threshold.
Could it be extended in a similar way to be more like xchacha with 192 bit nonces where using random nonces are easier?
It’s the same reason salts are used in passwords - there will be people using the equivalent of ‘password’, and without a salt it would be trivial to find them with just a lookup table (often in nearly O(1) time). With a salt it at least requires per-entry hashing of possible values per user, with no re-usability between users. So O(n^p) time (worst case) where n == number of users, p == number of possible values to test. A pretty huge difference.
Without the person on the other end having the value of the IV/nonce/salt, you might as well just stuff random bytes into the cyphertext field instead of the actual cyphertext, as if the algorithms are designed correctly they would be indistinguishable anyway.
There are two standardized ways (from NIST’s SP 800-38D) of ensuring unique (key,IV) pairs:
1. Use either a random number generator to make a nonce for the entire IV, or 2. Construct an IV by concatenating two fields, one field for the most significant bits set it to zero and increment it every time the key is used, the other is simply a fixed at zero.
With the second option, some new limitations exist to maintain the constructed IV’s uniqueness. The first being how many blocks of data you can encrypt in an operation (2^(size(fixedfield)) because you don’t want to overflow into your key-reuse field. The second is being the number of times you can reuse the key is now limited to 2^size(keyreusefield).
Sure don't reuse the IV and make sure it can't be easily derived or guessed, but if I'm looking for problems in an implementation, my point was that counter usage is one of the low-entropy threads to pull.
It's simple enough to implement as well, it's just two 64-bit additions with a check for wraparound on one of them.