Skip to main content

tc_asn1_x500/
lib.rs

1//! X.500 distinguished names on [`tc_asn1`], as used for the subject and
2//! issuer of X.509 certificates.
3//!
4//! A [`Name`] is a sequence of [`RelativeDistinguishedName`]s, each a set of
5//! [`AttributeTypeAndValue`] pairs whose values are mostly
6//! [`DirectoryString`]s; [`AttributeType`] has the OIDs that occur in names,
7//! and [`Attribute`] carries a set of values, as in certificate requests.
8//! Every type decodes any BER and encodes under BER, CER or DER through the
9//! `tc_asn1` traits. A `Name` also parses from and prints as RFC 4514 text,
10//! and compares strictly with `==` or with the relaxed matching of RFC 5280
11//! ยง7.1 through `equivalent`.
12//!
13//! ```
14//! use tc_asn1::{Decode, DecodingOptions, Encode, EncodingOptions};
15//! use tc_asn1_x500::Name;
16//!
17//! let name: Name = "CN=Alice,O=Example,C=TW".parse()?;
18//! let der = name.encode_to_vec(&EncodingOptions::DER)?;
19//! let (_, decoded) = Name::decode(&der, &DecodingOptions::default())?;
20//! assert_eq!(decoded.to_string(), "CN=Alice,O=Example,C=TW");
21//! assert!(decoded.equivalent(&"cn=alice, o=EXAMPLE, c=TW".parse()?));
22//! # Ok::<(), tc_asn1::Asn1Error>(())
23//! ```
24
25#![no_std]
26#![deny(missing_docs)]
27
28extern crate alloc;
29
30mod attribute;
31mod attribute_type;
32mod attribute_type_and_value;
33mod directory_string;
34mod name;
35mod relative_distinguished_name;
36mod string_prep;
37
38pub use attribute::Attribute;
39pub use attribute_type::AttributeType;
40pub use attribute_type_and_value::{AttributeTypeAndValue, AttributeValue};
41pub use directory_string::DirectoryString;
42pub use name::Name;
43pub use relative_distinguished_name::RelativeDistinguishedName;