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

Serialization decision needed at encryption time #53

Open
veselov opened this issue Jun 20, 2017 · 0 comments
Open

Serialization decision needed at encryption time #53

veselov opened this issue Jun 20, 2017 · 0 comments

Comments

@veselov
Copy link
Contributor

veselov commented Jun 20, 2017

As I'm going through the code, I also realized that there can be a problem with the sequence of encryption and serialization.

If there is only one recipient, and both protected and unprotected headers are given, then the compact serialization must join the headers into common headers, and use that as protected header values. However, JSON serialization must maintain the headers separately. Since the protected headers are used as part of the AAD, we can't decide which actual keys to authenticate, if it's not known what serialization is to be used. There are few solutions here, please let me know which one you would rather have:

  1. Serialization type must be known at the time of encryption
  2. Encryption must produce artifacts that can be used for both JSON and Compact (AFAIU, that means double the cipher text, because GCM blocks will be different if AAD is different)
  3. Shift actual encryption to the serialization phase. Re-encrypt on repeat calls, if serialization changes. The serialization can already fail, so the caller must check the return values anyway, I don't see this breaking compatibility.

Thank you.

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

No branches or pull requests

1 participant