Lines 513-520
Link Here
|
513 |
GetCipher(self, ctx); |
513 |
GetCipher(self, ctx); |
514 |
|
514 |
|
515 |
#if defined(HAVE_AUTHENTICATED_ENCRYPTION) |
515 |
#if defined(HAVE_AUTHENTICATED_ENCRYPTION) |
516 |
if (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER) |
516 |
if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) |
517 |
iv_len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx); |
517 |
iv_len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx); |
518 |
#endif |
518 |
#endif |
519 |
if (!iv_len) |
519 |
if (!iv_len) |
520 |
iv_len = EVP_CIPHER_CTX_iv_length(ctx); |
520 |
iv_len = EVP_CIPHER_CTX_iv_length(ctx); |
Lines 542-548
Link Here
|
542 |
GetCipher(self, ctx); |
542 |
GetCipher(self, ctx); |
543 |
|
543 |
|
544 |
#if defined(HAVE_AUTHENTICATED_ENCRYPTION) |
544 |
#if defined(HAVE_AUTHENTICATED_ENCRYPTION) |
545 |
return (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER) ? Qtrue : Qfalse; |
545 |
return (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) ? Qtrue : Qfalse; |
546 |
#else |
546 |
#else |
547 |
return Qfalse; |
547 |
return Qfalse; |
548 |
#endif |
548 |
#endif |
Lines 617-623
Link Here
|
617 |
|
617 |
|
618 |
GetCipher(self, ctx); |
618 |
GetCipher(self, ctx); |
619 |
|
619 |
|
620 |
if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER)) |
620 |
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) |
621 |
ossl_raise(eCipherError, "authentication tag not supported by this cipher"); |
621 |
ossl_raise(eCipherError, "authentication tag not supported by this cipher"); |
622 |
|
622 |
|
623 |
ret = rb_str_new(NULL, tag_len); |
623 |
ret = rb_str_new(NULL, tag_len); |
Lines 654-660
Link Here
|
654 |
tag_len = RSTRING_LENINT(vtag); |
654 |
tag_len = RSTRING_LENINT(vtag); |
655 |
|
655 |
|
656 |
GetCipher(self, ctx); |
656 |
GetCipher(self, ctx); |
657 |
if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER)) |
657 |
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) |
658 |
ossl_raise(eCipherError, "authentication tag not supported by this cipher"); |
658 |
ossl_raise(eCipherError, "authentication tag not supported by this cipher"); |
659 |
|
659 |
|
660 |
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, tag)) |
660 |
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, tag)) |
Lines 681-687
Link Here
|
681 |
EVP_CIPHER_CTX *ctx; |
681 |
EVP_CIPHER_CTX *ctx; |
682 |
|
682 |
|
683 |
GetCipher(self, ctx); |
683 |
GetCipher(self, ctx); |
684 |
if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER)) |
684 |
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) |
685 |
ossl_raise(eCipherError, "AEAD not supported by this cipher"); |
685 |
ossl_raise(eCipherError, "AEAD not supported by this cipher"); |
686 |
|
686 |
|
687 |
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, NULL)) |
687 |
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, NULL)) |
Lines 708-714
Link Here
|
708 |
EVP_CIPHER_CTX *ctx; |
708 |
EVP_CIPHER_CTX *ctx; |
709 |
|
709 |
|
710 |
GetCipher(self, ctx); |
710 |
GetCipher(self, ctx); |
711 |
if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER)) |
711 |
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) |
712 |
ossl_raise(eCipherError, "cipher does not support AEAD"); |
712 |
ossl_raise(eCipherError, "cipher does not support AEAD"); |
713 |
|
713 |
|
714 |
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, len, NULL)) |
714 |
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, len, NULL)) |
Lines 807-813
Link Here
|
807 |
|
807 |
|
808 |
GetCipher(self, ctx); |
808 |
GetCipher(self, ctx); |
809 |
#if defined(HAVE_AUTHENTICATED_ENCRYPTION) |
809 |
#if defined(HAVE_AUTHENTICATED_ENCRYPTION) |
810 |
if (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER) |
810 |
if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) |
811 |
len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx); |
811 |
len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx); |
812 |
#endif |
812 |
#endif |
813 |
if (!len) |
813 |
if (!len) |