Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING] AES GCM encryption now requires a user provided nonce #84

Merged
merged 4 commits into from
Jul 26, 2017

Conversation

lawliet89
Copy link
Owner

@lawliet89 lawliet89 commented Jul 26, 2017

Fixes #70

I understand that wrt Content encryption, the RFC for JWE literally says:

    Generate a random JWE Initialization Vector of the correct size
    for the content encryption algorithm (if required for the
    algorithm); otherwise, let the JWE Initialization Vector be the
    empty octet sequence.

and nothing on the CEK:

    When Key Wrapping, Key Encryption, or Key Agreement with Key
    Wrapping are employed, encrypt the CEK to the recipient and let
    the result be the JWE Encrypted Key.

but in the JWA RFC, it says the following wrt to AES GCM

Keys used with AES GCM must follow the constraints in Section 8.3 of
[NIST.800-38D], which states: "The total number of invocations of the
authenticated encryption function shall not exceed 2^32, including
all IV lengths and all instances of the authenticated encryption
function with the given key". In accordance with this rule, AES GCM
MUST NOT be used with the same key value more than 2^32 times.

An IV value MUST NOT ever be used multiple times with the same AES
GCM key. One way to prevent this is to store a counter with the key
and increment it with every use. The counter can also be used to
prevent exceeding the 2^32 limit above.

This security consideration does not apply to the composite AES-CBC
HMAC SHA-2 or AES Key Wrap algorithms.

So I am implementing this and if anyone has any feedback, we can discuss.

@lawliet89 lawliet89 merged commit 0e0da7d into master Jul 26, 2017
@lawliet89 lawliet89 deleted the harden-nonce branch July 26, 2017 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant