crypto: fix crypto.verify callback invocation with a private keyobject

fixes https://github.com/nodejs/node/issues/37794

PR-URL: https://github.com/nodejs/node/pull/37795
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Filip Skokan committed 2021-03-18 20:10:49 +01:00
1 parent c6855eb88f
commit 5e6386ec3f
2 files changed
+4 -2

No files matched your search

+1 -1
View File
@@ -847,7 +847,7 @@ bool SignTraits::DeriveBits(
}
break;
case SignConfiguration::kVerify:
CHECK_EQ(params.key->GetKeyType(), kKeyTypePublic);
CHECK_NE(params.key->GetKeyType(), kKeyTypeSecret);
if (!EVP_DigestVerifyInit(
context.get(),
&ctx,
@@ -52,7 +52,9 @@ function test(
}));
}
for (const key of [publicPem, publicKey, publicDer]) {
const verifyInputs = [
publicPem, publicKey, publicDer, privatePem, privateKey, privateDer];
for (const key of verifyInputs) {
crypto.verify(algorithm, data, key, expected, common.mustSucceed(
(verified) => assert.strictEqual(verified, true)));