1use super::*;
2use vstd::prelude::*;
3
4verus! {
5
6asn1! {
25 choice GeneralName {
26 Other(placeholder!(EXPLICIT 0)): placeholder_type!(),
27 RFC822(ASN1(ImplicitTag(tag_of!(IMPLICIT 1), IA5String))): ASN1<ImplicitTag<IA5String>>,
28 DNS(ASN1(ImplicitTag(tag_of!(IMPLICIT 2), IA5String))): ASN1<ImplicitTag<IA5String>>,
29 X400(placeholder!(IMPLICIT 3)): placeholder_type!(),
30 Directory(ASN1(ExplicitTag(tag_of!(EXPLICIT 4), ASN1(Name)))): ASN1<ExplicitTag<ASN1<Name>>>,
31 EDIParty(placeholder!(IMPLICIT 5)): placeholder_type!(),
32 URI(ASN1(ImplicitTag(tag_of!(IMPLICIT 6), IA5String))): ASN1<ImplicitTag<IA5String>>,
33 IP(ASN1(ImplicitTag(tag_of!(IMPLICIT 7), OctetString))): ASN1<ImplicitTag<OctetString>>,
34 RegisteredID(ASN1(ImplicitTag(tag_of!(IMPLICIT 8), ObjectIdentifier))): ASN1<ImplicitTag<ObjectIdentifier>>,
35 }
36
37 seq of GeneralNames(GeneralName): GeneralName;
38}
39
40}
41
42#[cfg(test)]
43mod test {
44 use super::*;
45
46 verus! {
47 #[test]
49 fn is_combinator() {
50 let _ = GeneralName.parse(&[]);
51 }
52 }
53
54 #[test]
55 fn rfc822() {
56 assert_eq!(
57 GeneralName
58 .parse(&[
59 0x82, 0x0C, 0x2A, 0x2E, 0x67, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x2E, 0x63, 0x6F,
60 0x6D,
61 ])
62 .unwrap()
63 .1,
64 GeneralNameValue::DNS("*.google.com")
65 );
66 }
67
68 #[test]
69 fn directory_name() {
70 assert!(GeneralName
71 .parse(&[
72 0xA4, 0x81, 0x91, 0x30, 0x81, 0x8E, 0x31, 0x47, 0x30, 0x45, 0x06, 0x03, 0x55, 0x04,
73 0x0A, 0x0C, 0x3E, 0x49, 0x5A, 0x45, 0x4E, 0x50, 0x45, 0x20, 0x53, 0x2E, 0x41, 0x2E,
74 0x20, 0x2D, 0x20, 0x43, 0x49, 0x46, 0x20, 0x41, 0x30, 0x31, 0x33, 0x33, 0x37, 0x32,
75 0x36, 0x30, 0x2D, 0x52, 0x4D, 0x65, 0x72, 0x63, 0x2E, 0x56, 0x69, 0x74, 0x6F, 0x72,
76 0x69, 0x61, 0x2D, 0x47, 0x61, 0x73, 0x74, 0x65, 0x69, 0x7A, 0x20, 0x54, 0x31, 0x30,
77 0x35, 0x35, 0x20, 0x46, 0x36, 0x32, 0x20, 0x53, 0x38, 0x31, 0x43, 0x30, 0x41, 0x06,
78 0x03, 0x55, 0x04, 0x09, 0x0C, 0x3A, 0x41, 0x76, 0x64, 0x61, 0x20, 0x64, 0x65, 0x6C,
79 0x20, 0x4D, 0x65, 0x64, 0x69, 0x74, 0x65, 0x72, 0x72, 0x61, 0x6E, 0x65, 0x6F, 0x20,
80 0x45, 0x74, 0x6F, 0x72, 0x62, 0x69, 0x64, 0x65, 0x61, 0x20, 0x31, 0x34, 0x20, 0x2D,
81 0x20, 0x30, 0x31, 0x30, 0x31, 0x30, 0x20, 0x56, 0x69, 0x74, 0x6F, 0x72, 0x69, 0x61,
82 0x2D, 0x47, 0x61, 0x73, 0x74, 0x65, 0x69, 0x7A,
83 ])
84 .is_ok());
85 }
86}