verdict_parser/x509/
attr_typ_val.rs

1use super::*;
2use vstd::prelude::*;
3
4verus! {
5
6// AttributeTypeAndValue in X.509:
7// AttributeTypeAndValue ::= SEQUENCE {
8//     type     AttributeType,
9//     value    AttributeValue
10// }
11//
12// AttributeType ::= OBJECT IDENTIFIER
13// AttributeValue ::= ANY DEFINED BY AttributeType
14//
15// where "in general AttributeValue will be a DirectoryString" (4.1.2.4, RFC 2459)
16asn1! {
17    seq AttributeTypeAndValue {
18        typ: ASN1<ObjectIdentifier> = ASN1(ObjectIdentifier),
19        value: DirectoryString = DirectoryString,
20    }
21}
22
23}
24
25#[cfg(test)]
26mod test {
27    use super::*;
28
29    verus! {
30        /// Check that all trait bounds and preconditions are satisfied
31        #[test]
32        fn is_combinator() {
33            let _ = ASN1(AttributeTypeAndValue).parse(&[]);
34        }
35    }
36
37    #[test]
38    fn sanity() {
39        assert!(ASN1(AttributeTypeAndValue)
40            .parse(&[
41                0x30, 0x17, 0x06, 0x0A, 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19,
42                0x16, 0x09, 0x72, 0x75, 0x62, 0x79, 0x2D, 0x6C, 0x61, 0x6E, 0x67,
43            ])
44            .is_ok());
45    }
46}