Skip to content

Commit cca3371

Browse files
committed
Support NoDigestInfo in recover_data_from_signature
1 parent e08560e commit cca3371

File tree

2 files changed

+6
-1
lines changed
  • src
    • cryptography/hazmat/primitives/asymmetric
    • rust/src/backend

2 files changed

+6
-1
lines changed

src/cryptography/hazmat/primitives/asymmetric/rsa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def recover_data_from_signature(
123123
self,
124124
signature: bytes,
125125
padding: AsymmetricPadding,
126-
algorithm: hashes.HashAlgorithm | None,
126+
algorithm: hashes.HashAlgorithm | asym_utils.NoDigestInfo | None,
127127
) -> bytes:
128128
"""
129129
Recovers the original data from the signature.

src/rust/src/backend/rsa.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@ impl RsaPublicKey {
497497
padding: &pyo3::Bound<'_, pyo3::PyAny>,
498498
algorithm: &pyo3::Bound<'_, pyo3::PyAny>,
499499
) -> CryptographyResult<pyo3::Bound<'p, pyo3::types::PyBytes>> {
500+
let algorithm = if algorithm.is_instance(&types::NO_DIGEST_INFO.get(py)?)? {
501+
&pyo3::types::PyNone::get(py).to_owned().into_any()
502+
} else {
503+
algorithm
504+
};
500505
if algorithm.is_instance(&types::PREHASHED.get(py)?)? {
501506
return Err(CryptographyError::from(
502507
pyo3::exceptions::PyTypeError::new_err(

0 commit comments

Comments
 (0)