-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(ext/crypto) - support encrypt/decrypt with AES-CTR #13177
Conversation
ext/crypto/encrypt.rs
Outdated
let mut cipher = Ctr::<B, F>::new(key.into(), counter.into()); | ||
|
||
let mut ciphertext = data.to_vec(); | ||
cipher.apply_keystream(&mut ciphertext); |
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.
Just checking to see if my understanding is correct: it's okay to use apply_keystream()
instead of try_apply_keystream()
because the ciphertext is always a multiple of the block size?
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.
As a stream cipher, any length of text is allowed, not being restricted to multiples of the block-size. There is a case where apply_keystream
will throw, however, which is when the user tries to encrypt more than 2 ^ length x 16
bytes of data, which in our current worse case, is 128GB in a single call.
Altered to use try_apply_keystream
as excess of caution.
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.
Thanks for the PR!
Towards #11690. Adds support for
AES-CTR
algorithm inencrypt()
anddecrypt()
.Values of counter-length restricted to 32/64/128 as per common usage described in issue #13201.