-
-
Save Albibek/bdfaa3464ac7b8f009865b3426164a68 to your computer and use it in GitHub Desktop.
Parsing CRL DP extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod test { | |
// rasn = { git = "https://github.com/XAMPPRocky/rasn.git", branch = "main" } | |
use rasn::types::*; | |
// rasn-pkix = { git = "https://github.com/XAMPPRocky/rasn.git", branch = "main" } | |
use rasn_pkix::*; | |
#[rustfmt::skip] | |
fn encoded() -> Vec<u8> { | |
[ | |
0x30, 0x78, 0x30, 0x3a, 0xa0, 0x38, 0xa0, 0x36, 0x86, 0x34, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, // 0x0:.8.6.4http:/ | |
0x2f, 0x63, 0x72, 0x6c, 0x33, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, // /crl3.digicert.c | |
0x6f, 0x6d, 0x2f, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x41, 0x73, 0x73, 0x75, 0x72, // om/DigiCertAssur | |
0x65, 0x64, 0x49, 0x44, 0x52, 0x6f, 0x6f, 0x74, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x6c, 0x30, 0x3a, // edIDRootCA.crl0: | |
0xa0, 0x38, 0xa0, 0x36, 0x86, 0x34, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x6c, // .8.6.4http://crl | |
0x34, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, // 4.digicert.com/D | |
0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x41, 0x73, 0x73, 0x75, 0x72, 0x65, 0x64, 0x49, 0x44, // igiCertAssuredID | |
0x52, 0x6f, 0x6f, 0x74, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x6c, // RootCA.crl | |
].into() | |
} | |
#[test] | |
fn test_encode_decode() { | |
let encoded = encoded(); | |
let dps: CrlDistributionPoints = rasn::der::decode(&encoded).unwrap(); | |
let enc = rasn::der::encode(&dps).unwrap(); | |
assert_eq!(enc, encoded); | |
} | |
#[test] | |
fn test_encode_by_hand() { | |
let name: Utf8String = "http://crl3.digicert.com/DigiCertAssuredIDRootCA.crl".into(); | |
let name = GeneralName::Uri(name.into()); | |
let name = DistributionPointName::FullName(vec![name]); | |
let dp1 = DistributionPoint { | |
distribution_point: Some(name), | |
reasons: None, | |
crl_issuer: None, | |
}; | |
let name: Utf8String = "http://crl4.digicert.com/DigiCertAssuredIDRootCA.crl".into(); | |
let name = GeneralName::Uri(name.into()); | |
let name = DistributionPointName::FullName(vec![name]); | |
let dp2 = DistributionPoint { | |
distribution_point: Some(name), | |
reasons: None, | |
crl_issuer: None, | |
}; | |
let dps = vec![dp1, dp2]; | |
let enc = rasn::der::encode(&dps).unwrap(); | |
let expected = encoded(); | |
assert_eq!(enc, expected); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment