File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3764,6 +3764,7 @@ EVPKeyPointer::ParseKeyResult EVPKeyPointer::TryLoadPrivateKeyFromStore(
37643764
37653765 // missing_passphrase is sticky, so a key that loaded anyway wins over it.
37663766 if (pkey) {
3767+ ctx.reset ();
37673768 ERR_clear_error ();
37683769 return ParseKeyResult (std::move (pkey));
37693770 }
Original file line number Diff line number Diff line change @@ -1698,6 +1698,7 @@ class EVPMDCtxPointer final {
16981698 DataPointer sign (const Buffer<const unsigned char >& buf) const ;
16991699 bool verify (const Buffer<const unsigned char >& buf,
17001700 const Buffer<const unsigned char >& sig) const ;
1701+ // Unlike verify(), preserves EVP_DigestVerify()'s three-way result.
17011702 int verifyOneShot (const Buffer<const unsigned char >& buf,
17021703 const Buffer<const unsigned char >& sig) const ;
17031704
Original file line number Diff line number Diff line change @@ -1016,6 +1016,11 @@ bool SignTraits::DeriveBits(Environment* env,
10161016 case SignConfiguration::Mode::Verify: {
10171017 auto buf = DataPointer::Alloc (1 );
10181018 static_cast <char *>(buf.get ())[0 ] = 0 ;
1019+ // EVP_DigestVerify() documents 0 as a verification mismatch. In its
1020+ // Update/Final path, it maps a failed EVP_DigestVerifyUpdate() to -1.
1021+ // Some providers fail that combined operation but support raw
1022+ // verification of a precomputed digest, so only retry negative results.
1023+ // Retrying 0 would perform a second verification for every mismatch.
10191024 int verify_result = context.verifyOneShot (params.data , params.signature );
10201025 if (verify_result == 1 &&
10211026 !HasSmallOrderEdDsaPoint (key, params.signature )) {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ declare namespace InternalCryptoBinding {
1414 KeyFormatDER | KeyFormatPEM | KeyFormatJWK | KeyFormatRawPublic | undefined ;
1515 type PrivateKeyFormat =
1616 KeyFormatDER | KeyFormatPEM | KeyFormatJWK |
17- KeyFormatRawPrivate | KeyFormatRawSeed | KeyFormatStore | undefined ;
17+ KeyFormatRawPrivate | KeyFormatRawSeed | undefined ;
1818 type KeyFormat = PublicKeyFormat | PrivateKeyFormat ;
1919 type KeyEncoding = string | number | null | undefined ;
2020 type KeyPassphrase = ByteSource | null | undefined ;
@@ -132,7 +132,7 @@ declare namespace InternalCryptoBinding {
132132
133133 type PreparedAsymmetricKeyArgs = [
134134 keyData : PreparedAsymmetricKeyData ,
135- keyFormat : KeyFormat ,
135+ keyFormat : KeyFormat | KeyFormatStore ,
136136 keyType : KeyEncoding ,
137137 keyPassphrase : KeyPassphrase ,
138138 keyNamedCurve : NamedCurve ,
You can’t perform that action at this time.
0 commit comments