Skip to content

Commit

Permalink
crypto: simplify exportKeyingMaterial
Browse files Browse the repository at this point in the history
PR-URL: #31922
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: David Carlier <[email protected]>
  • Loading branch information
tniessen authored and MylesBorins committed Mar 4, 2020
1 parent ba3f7ff commit 0fc45f8
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit 0fc45f8

Please sign in to comment.