Skip to content

Commit 05409c9

Browse files
codebytereMylesBorins
authored andcommitted
src: remove OCB support ifdef OPENSSL_NO_OCB
Electron uses BoringSSL which does not support OCB . It is also possible to build OpenSSL without support for OCB for Node.js. This commit disables OCB if OPENSSL_NO_OCB is defined. PR-URL: #23635 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent e1f7924 commit 05409c9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/node_crypto.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ using v8::Uint32;
8484
using v8::Undefined;
8585
using v8::Value;
8686

87+
#ifdef OPENSSL_NO_OCB
88+
# define IS_OCB_MODE(mode) false
89+
#else
90+
# define IS_OCB_MODE(mode) ((mode) == EVP_CIPH_OCB_MODE)
91+
#endif
8792

8893
struct StackOfX509Deleter {
8994
void operator()(STACK_OF(X509)* p) const { sk_X509_pop_free(p, X509_free); }
@@ -2540,7 +2545,7 @@ int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx) {
25402545
static bool IsSupportedAuthenticatedMode(int mode) {
25412546
return mode == EVP_CIPH_CCM_MODE ||
25422547
mode == EVP_CIPH_GCM_MODE ||
2543-
mode == EVP_CIPH_OCB_MODE;
2548+
IS_OCB_MODE(mode);
25442549
}
25452550

25462551
void CipherBase::Initialize(Environment* env, Local<Object> target) {
@@ -2765,7 +2770,7 @@ bool CipherBase::InitAuthenticated(const char* cipher_type, int iv_len,
27652770
}
27662771

27672772
const int mode = EVP_CIPHER_CTX_mode(ctx_.get());
2768-
if (mode == EVP_CIPH_CCM_MODE || mode == EVP_CIPH_OCB_MODE) {
2773+
if (mode == EVP_CIPH_CCM_MODE || IS_OCB_MODE(mode)) {
27692774
if (auth_tag_len == kNoAuthTagLength) {
27702775
char msg[128];
27712776
snprintf(msg, sizeof(msg), "authTagLength required for %s", cipher_type);
@@ -2893,7 +2898,7 @@ void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) {
28932898
} else if (mode == EVP_CIPH_OCB_MODE) {
28942899
// At this point, the tag length is already known and must match the
28952900
// length of the given authentication tag.
2896-
CHECK(mode == EVP_CIPH_CCM_MODE || mode == EVP_CIPH_OCB_MODE);
2901+
CHECK(mode == EVP_CIPH_CCM_MODE || IS_OCB_MODE(mode));
28972902
CHECK_NE(cipher->auth_tag_len_, kNoAuthTagLength);
28982903
if (cipher->auth_tag_len_ != tag_len) {
28992904
char msg[50];

0 commit comments

Comments
 (0)