Skip to content
/ node Public
forked from nodejs/node

Commit

Permalink
crypto: fix crypto.verify callback invocation with a private keyobject
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Mar 18, 2021
1 parent a2fdef0 commit 77667df
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(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 77667df

Please sign in to comment.