summaryrefslogtreecommitdiffstats
path: root/rust/vendor/der-parser-6.0.1/tests/oid.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:39:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:39:49 +0000
commita0aa2307322cd47bbf416810ac0292925e03be87 (patch)
tree37076262a026c4b48c8a0e84f44ff9187556ca35 /rust/vendor/der-parser-6.0.1/tests/oid.rs
parentInitial commit. (diff)
downloadsuricata-a0aa2307322cd47bbf416810ac0292925e03be87.tar.xz
suricata-a0aa2307322cd47bbf416810ac0292925e03be87.zip
Adding upstream version 1:7.0.3.upstream/1%7.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'rust/vendor/der-parser-6.0.1/tests/oid.rs')
-rw-r--r--rust/vendor/der-parser-6.0.1/tests/oid.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/rust/vendor/der-parser-6.0.1/tests/oid.rs b/rust/vendor/der-parser-6.0.1/tests/oid.rs
new file mode 100644
index 0000000..5cffad4
--- /dev/null
+++ b/rust/vendor/der-parser-6.0.1/tests/oid.rs
@@ -0,0 +1,25 @@
+//! Test the API provided to compare OIDs
+
+extern crate alloc;
+use der_parser::oid;
+use der_parser::oid::Oid;
+
+const OID_RSA_ENCRYPTION: &[u8] = &oid!(raw 1.2.840.113549.1.1.1);
+const OID_EC_PUBLIC_KEY: &[u8] = &oid!(raw 1.2.840.10045.2.1);
+#[allow(clippy::match_like_matches_macro)]
+fn compare_oid(oid: &Oid) -> bool {
+ match oid.bytes() {
+ OID_RSA_ENCRYPTION => true,
+ OID_EC_PUBLIC_KEY => true,
+ _ => false,
+ }
+}
+
+#[rustfmt::skip::macros(oid)]
+#[test]
+fn test_compare_oid() {
+ let oid = Oid::from(&[1, 2, 840, 113_549, 1, 1, 1]).unwrap();
+ assert_eq!(oid, oid!(1.2.840.113549.1.1.1));
+ let oid = Oid::from(&[1, 2, 840, 113_549, 1, 1, 1]).unwrap();
+ assert!(compare_oid(&oid));
+}