Skip to content

Commit 0fc45f8

Browse files
tniessenMylesBorins
authored andcommittedMar 4, 2020
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>
1 parent ba3f7ff commit 0fc45f8

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed
 

‎src/node_crypto.cc

+7-11
Original file line numberDiff line numberDiff line change
@@ -2807,24 +2807,20 @@ void SSLWrap<Base>::ExportKeyingMaterial(
28072807

28082808
AllocatedBuffer out = env->AllocateManaged(olen);
28092809

2810-
ByteSource key;
2811-
2812-
int useContext = 0;
2813-
if (!args[2]->IsNull() && Buffer::HasInstance(args[2])) {
2814-
key = ByteSource::FromBuffer(args[2]);
2815-
2816-
useContext = 1;
2817-
}
2810+
ByteSource context;
2811+
bool use_context = !args[2]->IsUndefined();
2812+
if (use_context)
2813+
context = ByteSource::FromBuffer(args[2]);
28182814

28192815
if (SSL_export_keying_material(w->ssl_.get(),
28202816
reinterpret_cast<unsigned char*>(out.data()),
28212817
olen,
28222818
*label,
28232819
label.length(),
28242820
reinterpret_cast<const unsigned char*>(
2825-
key.get()),
2826-
key.size(),
2827-
useContext) != 1) {
2821+
context.get()),
2822+
context.size(),
2823+
use_context) != 1) {
28282824
return ThrowCryptoError(env, ERR_get_error(), "SSL_export_keying_material");
28292825
}
28302826

0 commit comments

Comments
 (0)
Please sign in to comment.