commit | ff8ded613685a7e4b022c659fd0a0cf1f4b587e1 | [log] [tgz] |
---|---|---|
author | Xin Li <delphij@google.com> | Sat Aug 14 07:18:21 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Sat Aug 14 07:18:21 2021 +0000 |
tree | 7b59395b9dba8ead61600b33932a2bd995dd65fc | |
parent | cc07eae098c7c99c70a2d2cde21c2868d226d1ad [diff] | |
parent | 1bca766a9811dfe91ee67f34a1cd1966d2c8260b [diff] |
[automerger skipped] Mark sc-dev-plus-aosp-without-vendor@7634622 as merged am: fe39032f8c -s ours am: 25aaef3ac7 -s ours am: 9de0fe3489 -s ours am: 1bca766a98 -s ours am skip reason: Merged-In Id07d360178328965c2bc7b975ef72c29c4fc2e14 with SHA-1 51c2dc1c4e is already in history Original change: https://googleplex-android-review.googlesource.com/c/platform/external/rust/crates/oid-registry/+/15568686 Change-Id: I3dc5865f3e29e4e8b2db8b14ffcdbda0c05110eb
This crate is a helper crate, containing a database of OID objects. These objects are intended for use when manipulating ASN.1 grammars and BER/DER encodings, for example.
This crate provides only a simple registry (similar to a HashMap
) by default. This object can be used to get names and descriptions from OID.
This crate provides default lists of known OIDs, that can be selected using the build features. By default, the registry has no feature enabled, to avoid embedding a huge database in crates.
It also declares constants for most of these OIDs.
use oid_registry::OidRegistry; let mut registry = OidRegistry::default() .with_crypto() // only if the 'crypto' feature is enabled ; let e = registry.get(&oid_registry::OID_PKCS1_SHA256WITHRSA); if let Some(entry) = e { // get sn: sha256WithRSAEncryption println!("sn: {}", entry.sn()); // get description: SHA256 with RSA encryption println!("description: {}", entry.description()); }
These provided lists are often incomplete, or may lack some specific OIDs. This is why the registry allows adding new entries after construction:
use oid_registry::{OidEntry, OidRegistry}; use der_parser::oid; let mut registry = OidRegistry::default(); // entries can be added by creating an OidEntry object: let entry = OidEntry::new("shortName", "description"); registry.insert(oid!(1.2.3.4), entry); // when using static strings, a tuple can also be used directly for the entry: registry.insert(oid!(1.2.3.5), ("shortName", "A description"));
All OID values, constants, and features are derived from files in the assets
directory in the build script (see build.rs
). See load_file
for documentation of the file format.
oid-registry
requires Rustc version 1.45 or greater, based on proc-macro attributes support.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.