2
$\begingroup$

I was looking through Google's encryption flow and noticed that they split each file into chunks and then encrypt each chunk individually with AES-GCM with its own key.

Since AES-GCM starts to get vulnerable around $2^{48}$ messages (though, some people suggest $2^{36}$), how can they keep things secure if they have millions of users uploading files constantly?

I'm new to cryptography, so excuse my ignorance. Does the $2^{48}$ limit only actually matter on a per user basis or is it in general? I wanted to do try something similar using AES-CBC with a SecureRandom IV and HMAC for per chunk encryption since you don't have to worry about the collision. However, seeing their encryption flow, I wanted to learn more about what is the proper way of going about things.

$\endgroup$
3
  • 2
    $\begingroup$ The limit is on a per-key and nonce basis. $\endgroup$
    – forest
    Jul 25, 2019 at 6:48
  • $\begingroup$ Oh, so if you generate an entirely new key for each file, there is absolutely nothing to worry about. Sounds incredibly simple. $\endgroup$ Jul 25, 2019 at 7:53
  • $\begingroup$ Yes. I've wrote an answer to summarize it. $\endgroup$
    – forest
    Jul 25, 2019 at 7:56

1 Answer 1

1
$\begingroup$

The limit is on a per-key:nonce basis. As long as the key or nonce are changed between messages before the limit, there will not be any problems. Different users are using different TLS sessions (which uses 96-bit nonces), which means different keys and nonces. From Wikipedia's page on GCM:

GCM has been proven secure in the concrete security model. It is secure when it is used with a block cipher that is indistinguishable from a random permutation; however, security depends on choosing a unique initialization vector for every encryption performed with the same key (see stream cipher attack). For any given key and initialization vector combination, GCM is limited to encrypting 239−256 bits of plain text (64 GiB). NIST Special Publication 800-38D includes guidelines for initialization vector selection.

If TLS is not the protocol in use, then it depends on a few factors such as the size of the nonce (bigger is better) and whether or not it is random or sequential (sequential is better). In general, a competent cryptographer will not select insecure parameters. If you are trying to design your own encryption utility, you should be using an easy to use and foolproof library, such as libsodium.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.