Skip to content

Commit 77667df

Browse files
committed
crypto: fix crypto.verify callback invocation with a private keyobject
fixes #37794
1 parent a2fdef0 commit 77667df

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/crypto/crypto_sig.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ bool SignTraits::DeriveBits(
847847
}
848848
break;
849849
case SignConfiguration::kVerify:
850-
CHECK_EQ(params.key->GetKeyType(), kKeyTypePublic);
850+
CHECK(params.key->GetKeyType() != kKeyTypeSecret);
851851
if (!EVP_DigestVerifyInit(
852852
context.get(),
853853
&ctx,

test/parallel/test-crypto-async-sign-verify.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ function test(
5252
}));
5353
}
5454

55-
for (const key of [publicPem, publicKey, publicDer]) {
55+
const verifyInputs = [
56+
publicPem, publicKey, publicDer, privatePem, privateKey, privateDer];
57+
for (const key of verifyInputs) {
5658
crypto.verify(algorithm, data, key, expected, common.mustSucceed(
5759
(verified) => assert.strictEqual(verified, true)));
5860

0 commit comments

Comments
 (0)