crypto: simplify exportKeyingMaterial

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Tobias Nießen authored and Michaël Zasso committed 2020-04-28 16:00:48 +02:00
1 parent b62db597af
commit 0847bc3788
1 file changed
+7 -11
+7 -11
View File
@@ -2233,14 +2233,10 @@ 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()),
@@ -2248,9 +2244,9 @@ void SSLWrap<Base>::ExportKeyingMaterial(
*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");
}