Skip to content

Commit 8176164

Browse files
committed
fixup! crypto: add optional callback to crypto.sign and crypto.verify
1 parent 5673dcb commit 8176164

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/crypto/crypto_sig.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,15 @@ bool IsOneShot(const ManagedEVPPKey& key) {
234234
}
235235
}
236236

237-
bool UseP1363Encoding(const SignConfiguration& params) {
238-
switch (EVP_PKEY_id(params.key->GetAsymmetricKey().get())) {
237+
bool UseP1363Encoding(const ManagedEVPPKey& key,
238+
const DSASigEnc& dsa_encoding) {
239+
switch (EVP_PKEY_id(key.get())) {
239240
case EVP_PKEY_EC:
240-
case EVP_PKEY_DSA: return params.dsa_encoding == kSigEncP1363;
241+
case EVP_PKEY_DSA:
242+
return dsa_encoding == kSigEncP1363;
243+
default:
244+
return false;
241245
}
242-
return false;
243246
}
244247
} // namespace
245248

@@ -775,7 +778,7 @@ Maybe<bool> SignTraits::AdditionalConfig(
775778
// the signature from WebCrypto format into DER format...
776779
ManagedEVPPKey m_pkey = params->key->GetAsymmetricKey();
777780
Mutex::ScopedLock lock(*m_pkey.mutex());
778-
if (UseP1363Encoding(*params)) {
781+
if (UseP1363Encoding(m_pkey, params->dsa_encoding)) {
779782
params->signature =
780783
ConvertFromWebCryptoSignature(m_pkey, signature.ToByteSource());
781784
} else {
@@ -872,7 +875,7 @@ bool SignTraits::DeriveBits(
872875
if (!EVP_DigestSignFinal(context.get(), data, &len))
873876
return false;
874877

875-
if (UseP1363Encoding(params)) {
878+
if (UseP1363Encoding(m_pkey, params.dsa_encoding)) {
876879
*out = ConvertToWebCryptoSignature(
877880
params.key->GetAsymmetricKey(), buf);
878881
} else {

0 commit comments

Comments
 (0)