Skip to content

Commit

Permalink
crypto: fix crypto.verify callback invocation with a private keyobject
Browse files Browse the repository at this point in the history
fixes #37794

PR-URL: #37795
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
panva authored and ruyadorno committed Mar 20, 2021
1 parent 505f9c9 commit bfe3f21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/crypto/crypto_sig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-crypto-async-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down

0 comments on commit bfe3f21

Please sign in to comment.