You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe
Some encryption algorithms (for example AES/GCM) require an initialization vector that is unique for each message. The typical way to work this this is to store the IV alongside the ciphertext.
However, doing this with Lettuce is somewhat complicated since CipherCodec doesn't have native support for it.
I'd like CipherCodec (or possibly a subclass of it?) to support storing the IV as a prefix during encoding, and extracting the IV from the prefix when decoding.
Describe the solution you'd like
Add an API that would allow including the IV in the serialized value.
It could probably be implemented with something like:
In encodeValue, right before callin doWithCipher:
byte[] iv = cipher.getIV();
if (iv != null) {
target.writeBytes(iv);
}
decoding is a little more complicated, since the IV is needed for initializing the Cipher.
Probably there would need to be a way for the CipherSupplier to specify the size of the IV nad for decrypting get access to that the bytes for the IV during creation.
Alternatively, add a field to the KeyDescriptor for the IV.
Describe alternatives you've considered
Encoding the IV in as part of the "name" of the KeyDescriptor. This is kind of awkward, and requires Base64 encoding the IV, or similar, which is a little wasteful.
Wrapping a CipherSupplier, so that I can write/read the IV myself. Which involves a fair amount of boilerplate.
Not using the CipherCodec, and encrypting/decrypting the data before passing it in.
The text was updated successfully, but these errors were encountered:
Seems like a reasonable improvement, but currently I can commit to implementing it in a specific timeline.
Meanwhile community contributions are welcome.
Feature Request
Is your feature request related to a problem? Please describe
Some encryption algorithms (for example AES/GCM) require an initialization vector that is unique for each message. The typical way to work this this is to store the IV alongside the ciphertext.
However, doing this with Lettuce is somewhat complicated since CipherCodec doesn't have native support for it.
I'd like
CipherCodec
(or possibly a subclass of it?) to support storing the IV as a prefix during encoding, and extracting the IV from the prefix when decoding.Describe the solution you'd like
Add an API that would allow including the IV in the serialized value.
It could probably be implemented with something like:
In encodeValue, right before callin
doWithCipher
:decoding is a little more complicated, since the IV is needed for initializing the Cipher.
Probably there would need to be a way for the CipherSupplier to specify the size of the IV nad for decrypting get access to that the bytes for the IV during creation.
Alternatively, add a field to the KeyDescriptor for the IV.
Describe alternatives you've considered
Encoding the IV in as part of the "name" of the KeyDescriptor. This is kind of awkward, and requires Base64 encoding the IV, or similar, which is a little wasteful.
Wrapping a CipherSupplier, so that I can write/read the IV myself. Which involves a fair amount of boilerplate.
Not using the CipherCodec, and encrypting/decrypting the data before passing it in.
The text was updated successfully, but these errors were encountered: