Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShelley Vohr <shelley.vohr@gmail.com>2019-08-26 22:18:50 +0300
committerUjjwal Sharma <usharma1998@gmail.com>2019-08-29 07:42:58 +0300
commit17a697c794f2525c9789fd92c2206a1b634cf473 (patch)
tree24edd2d6dc2c1f7eaa8ba8fb8c117cfb8fa1f329 /src/node_crypto.cc
parent8675152f0f15002915225216f48e8bdd39612a81 (diff)
crypto: don't expose openssl internals
PR-URL: https://github.com/nodejs/node/pull/29325 Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r--src/node_crypto.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 5634d8b1dc5..65683b70d84 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5203,7 +5203,7 @@ template <PublicKeyCipher::Operation operation,
bool PublicKeyCipher::Cipher(Environment* env,
const ManagedEVPPKey& pkey,
int padding,
- const char* oaep_hash,
+ const EVP_MD* digest,
const unsigned char* data,
int len,
AllocatedBuffer* out) {
@@ -5215,9 +5215,8 @@ bool PublicKeyCipher::Cipher(Environment* env,
if (EVP_PKEY_CTX_set_rsa_padding(ctx.get(), padding) <= 0)
return false;
- if (oaep_hash != nullptr) {
- if (!EVP_PKEY_CTX_md(ctx.get(), EVP_PKEY_OP_TYPE_CRYPT,
- EVP_PKEY_CTRL_RSA_OAEP_MD, oaep_hash))
+ if (digest != nullptr) {
+ if (!EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest))
return false;
}
@@ -5259,6 +5258,12 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
const node::Utf8Value oaep_str(env->isolate(), args[offset + 2]);
const char* oaep_hash = args[offset + 2]->IsString() ? *oaep_str : nullptr;
+ const EVP_MD* digest = nullptr;
+ if (oaep_hash != nullptr) {
+ digest = EVP_get_digestbyname(oaep_hash);
+ if (digest == nullptr)
+ return THROW_ERR_OSSL_EVP_INVALID_DIGEST(env);
+ }
AllocatedBuffer out;
@@ -5268,7 +5273,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
env,
pkey,
padding,
- oaep_hash,
+ digest,
buf.data(),
buf.length(),
&out);