-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add AD mode to Transit's AEAD ciphers #17638
Conversation
var factory interface{} | ||
|
||
if item.AssociatedData != "" { | ||
isAEAD := p.Type.String() == "aes128-gcm96" || p.Type.String() == "aes192-gcm96" || p.Type.String() == "aes256-gcm96" || p.Type.String() == "chacha20-poly1305" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we switch this to use the existing pattern of adding this test on the KeyType type in policy.go
around line 146, instead of using string tests? For example we seem to have added an "impossible" key type value in this test of aes192-gcm96
func (kt KeyType) AEADSupported() bool {
switch kt {
case KeyType_AES128_GCM96, KeyType_AES256_GCM96, KeyType_ChaCha20_Poly1305:
return true
}
return false
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I added it intentionally so we don't fail if we later introduce AES-192... This does seem cleaner since the change should be localized to KeyType.
This allows the high-level, algorithm-agnostic Encrypt/Decrypt with Factory to pass in AssociatedData, and potentially take multiple factories (to allow KMS keys to work). On AEAD ciphers with a relevant factory, an AssociatedData factory will be used to populate the AdditionalData field of the SymmetricOpts struct, using it in the AEAD Seal process. Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
This allows passing the associated_data (the last AD in AEAD) to Transit's encrypt/decrypt when using an AEAD cipher (currently aes128-gcm96, aes256-gcm96, and chacha20-poly1305). We err if this parameter is passed on non-AEAD ciphers presently. This associated data can be safely transited in plaintext, without risk of modifications. In the event of tampering with either the ciphertext or the associated data, decryption will fail. Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
67acbfa
to
234e129
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but will defer to others in the team to sign off on the new transit feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Project I started during hack week, but didn't quite finish... (something something, tests) :-)
This adds a new parameter,
associated_data
to be passed when using an AEAD cipher (AES+GCM, ChaCha20+Poly1305). This is authenticated, but need not be transited in ciphertext.