• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Test the API provided to compare OIDs
2 
3 extern crate alloc;
4 use der_parser::oid;
5 use der_parser::oid::Oid;
6 
7 const OID_RSA_ENCRYPTION: &[u8] = &oid!(raw 1.2.840.113549.1.1.1);
8 const OID_EC_PUBLIC_KEY: &[u8] = &oid!(raw 1.2.840.10045.2.1);
9 #[allow(clippy::match_like_matches_macro)]
compare_oid(oid: &Oid) -> bool10 fn compare_oid(oid: &Oid) -> bool {
11     match oid.bytes() {
12         OID_RSA_ENCRYPTION => true,
13         OID_EC_PUBLIC_KEY => true,
14         _ => false,
15     }
16 }
17 
18 #[rustfmt::skip::macros(oid)]
19 #[test]
test_compare_oid()20 fn test_compare_oid() {
21     let oid = Oid::from(&[1, 2, 840, 113_549, 1, 1, 1]).unwrap();
22     assert_eq!(oid, oid!(1.2.840.113549.1.1.1));
23     let oid = Oid::from(&[1, 2, 840, 113_549, 1, 1, 1]).unwrap();
24     assert!(compare_oid(&oid));
25 }
26