• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# [RustCrypto]: Object Identifiers (OIDs)
2
3[![crate][crate-image]][crate-link]
4[![Docs][docs-image]][docs-link]
5[![Build Status][build-image]][build-link]
6![Apache2/MIT licensed][license-image]
7![Rust Version][rustc-image]
8[![Project Chat][chat-image]][chat-link]
9
10Const-friendly implementation of the ISO/IEC Object Identifier (OID) standard
11as defined in ITU [X.660], with support for BER/DER encoding/decoding as well
12as heapless `no_std` (i.e. embedded) environments.
13
14[Documentation][docs-link]
15
16## About OIDs
17
18Object Identifiers, a.k.a. OIDs, are an International Telecommunications
19Union (ITU) and ISO/IEC standard for naming any object, concept, or "thing"
20with a globally unambiguous persistent name.
21
22The ITU's [X.660] standard provides the OID specification. Every OID is part of
23a hierarchical namespace which begins with a *root OID*, which is either the
24ITU's root OID (0), the ISO's root OID (1), or the joint ISO/ITU root OID (2).
25
26The following is an example of an OID, in this case identifying the
27`rsaEncryption` algorithm:
28
29```text
301.2.840.113549.1.1.1
31```
32
33For more information, see: <https://en.wikipedia.org/wiki/Object_identifier>
34
35## Implementation
36
37This library supports parsing OIDs in const contexts, e.g.:
38
39```rust
40use const_oid::ObjectIdentifier;
41
42pub const MY_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.1");
43```
44
45The OID parser is implemented entirely in terms of `const fn` and without the
46use of proc macros.
47
48Additionally, it also includes a `const fn` OID serializer, and stores the OIDs
49parsed from const contexts encoded using the BER/DER serialization
50(sans header).
51
52This allows `ObjectIdentifier` to impl `AsRef<[u8]>` which can be used to
53obtain the BER/DER serialization of an OID, even one declared `const`.
54
55Additionally, it impls `FromStr` and `TryFrom<&[u8]>` and functions just as
56well as a runtime OID library.
57
58## Minimum Supported Rust Version
59
60This crate requires **Rust 1.57** at a minimum.
61
62We may change the MSRV in the future, but it will be accompanied by a minor
63version bump.
64
65## License
66
67Licensed under either of:
68
69* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
70* [MIT license](http://opensource.org/licenses/MIT)
71
72at your option.
73
74### Contribution
75
76Unless you explicitly state otherwise, any contribution intentionally submitted
77for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
78dual licensed as above, without any additional terms or conditions.
79
80[//]: # (badges)
81
82[crate-image]: https://buildstats.info/crate/const-oid
83[crate-link]: https://crates.io/crates/const-oid
84[docs-image]: https://docs.rs/const-oid/badge.svg
85[docs-link]: https://docs.rs/const-oid/
86[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
87[rustc-image]: https://img.shields.io/badge/rustc-1.57+-blue.svg
88[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
89[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/300570-formats
90[build-image]: https://github.com/RustCrypto/formats/workflows/const-oid/badge.svg?branch=master&event=push
91[build-link]: https://github.com/RustCrypto/formats/actions
92
93[//]: # (links)
94
95[RustCrypto]: https://github.com/rustcrypto
96[X.660]: https://www.itu.int/rec/T-REC-X.660
97