Clean ups to the error codes in CMS signature parsing

This commit is contained in:
Richard van der Hoff
2026-07-02 22:18:40 +01:00
parent fd64849785
commit 7fdb284db3
2 changed files with 6 additions and 6 deletions

View File

@@ -108,8 +108,8 @@ pub enum RawX509SignatureParseError {
#[error("could not parse SignatureAlgorithm.parameters")]
SignatureAlgorithmParametersParseError(#[source] der::Error),
#[error("SignatureAlgorithm hash type does not match digest algorithm")]
UnexpectedSignatureAlgorithmHash,
#[error("unsupported SignatureAlgorithm hash algorithm: {}", .0.actual)]
UnsupportedSignatureAlgorithmHash(OidMismatch),
#[error("unsupported SignatureAlgorithm mask generation function: {}", .0.actual)]
UnsupportedSignatureAlgorithmMaskGen(OidMismatch),
@@ -118,9 +118,9 @@ pub enum RawX509SignatureParseError {
SignatureAlgorithmMaskGenParametersNotSet,
#[error(
"SignatureAlgorithm mask generation function hash type does not match digest algorithm"
"unsupported SignatureAlgorithm mask generation function hash algorithm: {}", .0.actual
)]
UnexpectedSignatureAlgorithmMaskGenHash,
UnsupportedSignatureAlgorithmMaskGenHash(OidMismatch),
#[error("SignatureAlgorithm salt length is not 64: {0}")]
UnsupportedSignatureAlgorithmSaltLen(u8),

View File

@@ -333,7 +333,7 @@ fn map_signer_info_algorithms_to_signature_scheme(
.map_err(RawX509SignatureParseError::SignatureAlgorithmParametersParseError)?;
assert_oid_matches(&signature_algorithm_params.hash.oid, &const_oid::db::rfc5912::ID_SHA_512)
.map_err(RawX509SignatureParseError::UnsupportedDigestAlgorithm)?;
.map_err(RawX509SignatureParseError::UnsupportedSignatureAlgorithmHash)?;
assert_digest_alg_params_null_or_absent(&signature_algorithm_params.hash.parameters)?;
assert_oid_matches(&signature_algorithm_params.mask_gen.oid, &const_oid::db::rfc5912::ID_MGF_1)
@@ -345,7 +345,7 @@ fn map_signer_info_algorithms_to_signature_scheme(
.ok_or(RawX509SignatureParseError::SignatureAlgorithmMaskGenParametersNotSet)?;
assert_oid_matches(&mask_gen_params.oid, &const_oid::db::rfc5912::ID_SHA_512)
.map_err(RawX509SignatureParseError::UnsupportedDigestAlgorithm)?;
.map_err(RawX509SignatureParseError::UnsupportedSignatureAlgorithmMaskGenHash)?;
assert_digest_alg_params_null_or_absent(&mask_gen_params.parameters)?;
if signature_algorithm_params.salt_len != 64 {