pss: expose a get_default_pss_signature_algo_id helper (#393)

This returns the `AlgorithmIdentifierOwned` assuming the default
situation where the salt_len is the `output_size` of the `Digest`.

This is meant to be used by HSM where the private key is hidden behind
an abstraction but to still expose a `DynSignatureAlgorithmIdentifier`
trait.
This commit is contained in:
Arthur Gautier 2023-11-29 13:54:56 -08:00 committed by GitHub
parent 5d45065bd8
commit 7341cd0159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -227,6 +227,15 @@ fn sign_pss_with_salt_digest<T: CryptoRngCore + ?Sized, D: Digest + FixedOutputR
)
}
/// Returns the [`AlgorithmIdentifierOwned`] associated with PSS signature using a given digest.
pub fn get_default_pss_signature_algo_id<D>() -> pkcs8::spki::Result<AlgorithmIdentifierOwned>
where
D: Digest + AssociatedOid,
{
let salt_len: u8 = <D as Digest>::output_size() as u8;
get_pss_signature_algo_id::<D>(salt_len)
}
fn get_pss_signature_algo_id<D>(salt_len: u8) -> pkcs8::spki::Result<AlgorithmIdentifierOwned>
where
D: Digest + AssociatedOid,