Skip to content

Commit 3322a3f

Browse files
committed
fixup! crypto: add support for OCB mode for AEAD
1 parent 501017a commit 3322a3f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/node_crypto.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -2683,9 +2683,11 @@ void CipherBase::Init(const FunctionCallbackInfo<Value>& args) {
26832683
cipher->Init(*cipher_type, key_buf, key_buf_len, auth_tag_len);
26842684
}
26852685

2686-
#define IS_SUPPORTED_AUTHENTICATED_MODE(mode) ((mode) == EVP_CIPH_CCM_MODE || \
2687-
(mode) == EVP_CIPH_GCM_MODE || \
2688-
(mode) == EVP_CIPH_OCB_MODE)
2686+
static bool IsSupportedAuthenticatedMode(int mode) {
2687+
return mode == EVP_CIPH_CCM_MODE ||
2688+
mode == EVP_CIPH_GCM_MODE ||
2689+
mode == EVP_CIPH_OCB_MODE;
2690+
}
26892691

26902692
void CipherBase::InitIv(const char* cipher_type,
26912693
const char* key,
@@ -2703,7 +2705,7 @@ void CipherBase::InitIv(const char* cipher_type,
27032705

27042706
const int expected_iv_len = EVP_CIPHER_iv_length(cipher);
27052707
const int mode = EVP_CIPHER_mode(cipher);
2706-
const bool is_authenticated_mode = IS_SUPPORTED_AUTHENTICATED_MODE(mode);
2708+
const bool is_authenticated_mode = IsSupportedAuthenticatedMode(mode);
27072709
const bool has_iv = iv_len >= 0;
27082710

27092711
// Throw if no IV was passed and the cipher requires an IV
@@ -2876,7 +2878,7 @@ bool CipherBase::IsAuthenticatedMode() const {
28762878
// Check if this cipher operates in an AEAD mode that we support.
28772879
CHECK(ctx_);
28782880
const int mode = EVP_CIPHER_CTX_mode(ctx_.get());
2879-
return IS_SUPPORTED_AUTHENTICATED_MODE(mode);
2881+
return IsSupportedAuthenticatedMode(mode);
28802882
}
28812883

28822884

0 commit comments

Comments
 (0)