Skip to content

Commit 51cae73

Browse files
tniessenTrott
authored andcommitted
crypto: simplify exportKeyingMaterial
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]>
1 parent 46b92c8 commit 51cae73

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
@@ -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)