Repository navigation
Conversation
|
Out of curiosity, did you find this through code inspection, or is there a use case for it?
https://docs.openssl.org/master/man3/EVP_EncryptInit/#flags I suspect there's a reason this required an explicit flag, perhaps because it changed the semantics of |
OpenSSL 1.1.1 and LibreSSL reject key wrap ciphers in EVP_CipherInit_ex() unless the context has EVP_CIPHER_CTX_FLAG_WRAP_ALLOW set. Set the flag when the EVP_CIPHER_CTX is allocated. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
I don't use the key wrap ciphers, so this is not a priority. I found it while comparing the gem's behavior on OpenSSL and LibreSSL.
|
|
Regarding safety: the flag only affects OpenSSL added the flag in 1.0.2 "to avoid problems with existing code" (CHANGES.md). I think the problems are: With the patch, one behavior differs between libraries. With a key wrap cipher, one c = OpenSSL::Cipher.new("id-aes128-wrap").encrypt
c.key = kek
c.update(key1) #=> wrap of key1
c.update(key2)
#=> OpenSSL 3.x: CipherError: update call out of order
#=> OpenSSL 1.1.1, LibreSSL: wrap of key2 only |
With OpenSSL 1.1.1 and LibreSSL, the AES key wrap ciphers can't be used.
OpenSSL::Cipher.cipherslistsid-aes128-wrap, but creating the cipher raises an error:OpenSSL 1.1.1 and LibreSSL only allow a key wrap cipher when the cipher context has the
EVP_CIPHER_CTX_FLAG_WRAP_ALLOWflag. OpenSSL 3.0 and later don't need the flag.The OpenSSL 1.1.1 CI job reports
test_aes_keywrap_padas omitted. The test rescuesCipherErrorfromOpenSSL::Cipher.new("id-aes192-wrap-pad")and callsomit, and on OpenSSL 1.1.1 theCipherErroris "wrap mode not allowed".Fix
OpenSSL::Ciphernow setsEVP_CIPHER_CTX_FLAG_WRAP_ALLOWwhen it creates the cipher context.