crypto: avoid taking ownership of OpenSSL objects · nodejs/node@f82e20f · GitHub
Skip to content

Commit f82e20f

Browse files
tniessenaduh95
authored andcommitted
crypto: avoid taking ownership of OpenSSL objects
It is often unnecessary to obtain (shared) ownership of OpenSSL objects in this code, and it generally is more costly to do so as opposed to just obtaining a pointer to the respective OpenSSL object. Therefore, this patch replaces various OpenSSL function calls that take ownership with ones that do not. Refs: #53436 PR-URL: #53460 Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 8743c4d commit f82e20f

3 files changed

Lines changed: 34 additions & 34 deletions

File tree

src/crypto/crypto_common.cc

Lines changed: 0 additions & 8 deletions

src/crypto/crypto_common.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
#include <string>
1212

13+
// Some OpenSSL 1.1.1 functions unnecessarily operate on and return non-const
14+
// pointers, whereas the same functions in OpenSSL 3 use const pointers.
15+
#if OPENSSL_VERSION_MAJOR >= 3
16+
#define OSSL3_CONST const
17+
#else
18+
#define OSSL3_CONST
19+
#endif
20+
1321
namespace node {
1422
namespace crypto {
1523

src/crypto/crypto_keys.cc

Lines changed: 26 additions & 26 deletions

0 commit comments

Comments
 (0)