Skip to content
Permalink
Browse files

crypto: simplify exportKeyingMaterial

PR-URL: #31922
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
  • Loading branch information
tniessen authored and MylesBorins committed Feb 23, 2020
1 parent ba3f7ff commit 0fc45f80b59db586c46d8b0fca265446a46ed121
Showing with 7 additions and 11 deletions.
  1. +7 −11 src/node_crypto.cc
@@ -2807,24 +2807,20 @@ void SSLWrap<Base>::ExportKeyingMaterial(

AllocatedBuffer out = env->AllocateManaged(olen);

ByteSource key;

int useContext = 0;
if (!args[2]->IsNull() && Buffer::HasInstance(args[2])) {
key = ByteSource::FromBuffer(args[2]);

useContext = 1;
}
ByteSource context;
bool use_context = !args[2]->IsUndefined();
if (use_context)
context = ByteSource::FromBuffer(args[2]);

if (SSL_export_keying_material(w->ssl_.get(),
reinterpret_cast<unsigned char*>(out.data()),
olen,
*label,
label.length(),
reinterpret_cast<const unsigned char*>(
key.get()),
key.size(),
useContext) != 1) {
context.get()),
context.size(),
use_context) != 1) {
return ThrowCryptoError(env, ERR_get_error(), "SSL_export_keying_material");
}

0 comments on commit 0fc45f8

Please sign in to comment.
You can’t perform that action at this time.