重构error code
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use rpki::data_model::common::{
|
||||
algorithm_params_absent_or_null, Asn1TimeEncoding, Asn1TimeUtc, BigUnsigned,
|
||||
Asn1TimeEncoding, Asn1TimeUtc, BigUnsigned, algorithm_params_absent_or_null,
|
||||
};
|
||||
use x509_parser::prelude::FromDer;
|
||||
use x509_parser::x509::AlgorithmIdentifier;
|
||||
use x509_parser::time::ASN1Time;
|
||||
use x509_parser::x509::AlgorithmIdentifier;
|
||||
|
||||
#[test]
|
||||
fn big_unsigned_helpers() {
|
||||
@@ -32,8 +32,11 @@ fn time_encoding_validation() {
|
||||
t.validate_encoding_rfc5280("t").expect("utc ok");
|
||||
|
||||
let t = Asn1TimeUtc {
|
||||
utc: time::OffsetDateTime::parse("2050-01-01T00:00:00Z", &time::format_description::well_known::Rfc3339)
|
||||
.unwrap(),
|
||||
utc: time::OffsetDateTime::parse(
|
||||
"2050-01-01T00:00:00Z",
|
||||
&time::format_description::well_known::Rfc3339,
|
||||
)
|
||||
.unwrap(),
|
||||
encoding: Asn1TimeEncoding::UtcTime,
|
||||
};
|
||||
assert!(t.validate_encoding_rfc5280("t").is_err());
|
||||
@@ -43,18 +46,12 @@ fn time_encoding_validation() {
|
||||
fn algorithm_params_absent_or_null_helper() {
|
||||
// AlgorithmIdentifier ::= SEQUENCE { algorithm OID, parameters ANY OPTIONAL }
|
||||
// Using sha256WithRSAEncryption with NULL parameters.
|
||||
let alg_null = hex::decode(
|
||||
"300D06092A864886F70D01010B0500",
|
||||
)
|
||||
.unwrap();
|
||||
let alg_null = hex::decode("300D06092A864886F70D01010B0500").unwrap();
|
||||
let (_rem, id) = AlgorithmIdentifier::from_der(&alg_null).expect("parse AlgorithmIdentifier");
|
||||
assert!(algorithm_params_absent_or_null(&id));
|
||||
|
||||
// Same OID, but parameters = INTEGER 1 (invalid for our helper).
|
||||
let alg_int = hex::decode(
|
||||
"300E06092A864886F70D01010B020101",
|
||||
)
|
||||
.unwrap();
|
||||
let alg_int = hex::decode("300E06092A864886F70D01010B020101").unwrap();
|
||||
let (_rem, id) = AlgorithmIdentifier::from_der(&alg_int).expect("parse AlgorithmIdentifier");
|
||||
assert!(!algorithm_params_absent_or_null(&id));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user