Skip to content

Commit c7ab3cf

Browse files
committed
crypto: use new OpenSSL constants in CipherBase
This change replaces some constants with better alternatives which were unavailable in OpenSSL 1.0.2. Refs: nodejs#19794 Refs: nodejs#18138
1 parent f9b9974 commit c7ab3cf

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

src/node_crypto.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,10 +2798,7 @@ bool CipherBase::InitAuthenticated(const char *cipher_type, int iv_len,
27982798
unsigned int auth_tag_len) {
27992799
CHECK(IsAuthenticatedMode());
28002800

2801-
// TODO(tniessen) Use EVP_CTRL_AEAD_SET_IVLEN when migrating to OpenSSL 1.1.0
2802-
static_assert(EVP_CTRL_CCM_SET_IVLEN == EVP_CTRL_GCM_SET_IVLEN,
2803-
"OpenSSL constants differ between GCM and CCM");
2804-
if (!EVP_CIPHER_CTX_ctrl(ctx_, EVP_CTRL_GCM_SET_IVLEN, iv_len, nullptr)) {
2801+
if (!EVP_CIPHER_CTX_ctrl(ctx_, EVP_CTRL_AEAD_SET_IVLEN, iv_len, nullptr)) {
28052802
env()->ThrowError("Invalid IV length");
28062803
return false;
28072804
}
@@ -3111,10 +3108,7 @@ bool CipherBase::Final(unsigned char** out, int *out_len) {
31113108
// be given by the user.
31123109
if (mode == EVP_CIPH_GCM_MODE && auth_tag_len_ == kNoAuthTagLength)
31133110
auth_tag_len_ = sizeof(auth_tag_);
3114-
// TOOD(tniessen) Use EVP_CTRL_AEAP_GET_TAG in OpenSSL 1.1.0
3115-
static_assert(EVP_CTRL_CCM_GET_TAG == EVP_CTRL_GCM_GET_TAG,
3116-
"OpenSSL constants differ between GCM and CCM");
3117-
CHECK_EQ(1, EVP_CIPHER_CTX_ctrl(ctx_, EVP_CTRL_GCM_GET_TAG, auth_tag_len_,
3111+
CHECK_EQ(1, EVP_CIPHER_CTX_ctrl(ctx_, EVP_CTRL_AEAD_GET_TAG, auth_tag_len_,
31183112
reinterpret_cast<unsigned char*>(auth_tag_)));
31193113
}
31203114
}

0 commit comments

Comments
 (0)