Bug #13935 » ruby_2_3-0006-cipher-disallow-setting-AAD-for-non-AEAD-ciphers.patch
| ext/openssl/ossl_cipher.c | ||
|---|---|---|
|
in_len = RSTRING_LEN(data);
|
||
|
GetCipher(self, ctx);
|
||
|
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
|
||
|
ossl_raise(eCipherError, "AEAD not supported by this cipher");
|
||
|
if (!ossl_cipher_update_long(ctx, NULL, &out_len, in, in_len))
|
||
|
ossl_raise(eCipherError, "couldn't set additional authenticated data");
|
||
| test/openssl/test_cipher.rb | ||
|---|---|---|
|
assert_equal tag1, tag2
|
||
|
end if has_cipher?("aes-128-gcm")
|
||
|
def test_non_aead_cipher_set_auth_data
|
||
|
assert_raise(OpenSSL::Cipher::CipherError) {
|
||
|
cipher = OpenSSL::Cipher.new("aes-128-cfb").encrypt
|
||
|
cipher.auth_data = "123"
|
||
|
}
|
||
|
end
|
||
|
end
|
||
|
private
|
||
- « Previous
- 1
- …
- 6
- 7
- 8
- Next »