Skip to content

Commit cfaa156

Browse files
tniessentargos
authored andcommitted
crypto: simplify exportKeyingMaterial
PR-URL: nodejs#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]>
1 parent fcbb571 commit cfaa156

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/node_crypto.cc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,24 +2233,20 @@ void SSLWrap<Base>::ExportKeyingMaterial(
22332233

22342234
AllocatedBuffer out = env->AllocateManaged(olen);
22352235

2236-
ByteSource key;
2237-
2238-
int useContext = 0;
2239-
if (!args[2]->IsNull() && Buffer::HasInstance(args[2])) {
2240-
key = ByteSource::FromBuffer(args[2]);
2241-
2242-
useContext = 1;
2243-
}
2236+
ByteSource context;
2237+
bool use_context = !args[2]->IsUndefined();
2238+
if (use_context)
2239+
context = ByteSource::FromBuffer(args[2]);
22442240

22452241
if (SSL_export_keying_material(w->ssl_.get(),
22462242
reinterpret_cast<unsigned char*>(out.data()),
22472243
olen,
22482244
*label,
22492245
label.length(),
22502246
reinterpret_cast<const unsigned char*>(
2251-
key.get()),
2252-
key.size(),
2253-
useContext) != 1) {
2247+
context.get()),
2248+
context.size(),
2249+
use_context) != 1) {
22542250
return ThrowCryptoError(env, ERR_get_error(), "SSL_export_keying_material");
22552251
}
22562252

0 commit comments

Comments
 (0)