重构error code

This commit is contained in:
2026-02-04 17:02:17 +08:00
parent cc9f3f21de
commit a58e507f92
44 changed files with 6095 additions and 1165 deletions

View File

@@ -53,8 +53,8 @@ fn der_null() -> Vec<u8> {
}
fn der_oid(oid: &str) -> Vec<u8> {
use std::str::FromStr;
use der_parser::asn1_rs::ToDer;
use std::str::FromStr;
let oid = der_parser::Oid::from_str(oid).unwrap();
oid.to_der_vec().unwrap()
}
@@ -140,10 +140,11 @@ fn verify_rejects_spki_der_with_trailing_bytes() {
let mut spki_der = so.signed_data.certificates[0].spki_der.clone();
spki_der.push(0);
let err = so
.verify_signature_with_ee_spki_der(&spki_der)
.unwrap_err();
assert!(matches!(err, SignedObjectVerifyError::EeSpkiTrailingBytes(1)));
let err = so.verify_signature_with_ee_spki_der(&spki_der).unwrap_err();
assert!(matches!(
err,
SignedObjectVerifyError::EeSpkiTrailingBytes(1)
));
}
#[test]
@@ -157,8 +158,6 @@ fn verify_with_all_zero_modulus_exercises_strip_leading_zeros_fallback() {
// modulus INTEGER 0, exponent 65537 (valid exponent encoding); signature verification must fail
// but the SPKI parsing path should succeed.
let spki_der = rsa_spki_der_with_modulus_bytes(&[0x00], 65537);
let err = so
.verify_signature_with_ee_spki_der(&spki_der)
.unwrap_err();
let err = so.verify_signature_with_ee_spki_der(&spki_der).unwrap_err();
assert!(matches!(err, SignedObjectVerifyError::InvalidSignature));
}