9 releases

0.1.5 Jul 20, 2021
0.1.4 Jul 6, 2021
0.1.3 May 27, 2021
0.1.1 Nov 25, 2020
0.0.2 Oct 26, 2020

#58 in Database interfaces

Download history 4976/week @ 2021-04-09 5005/week @ 2021-04-16 6096/week @ 2021-04-23 5061/week @ 2021-04-30 4678/week @ 2021-05-07 4667/week @ 2021-05-14 4282/week @ 2021-05-21 4598/week @ 2021-05-28 4358/week @ 2021-06-04 5764/week @ 2021-06-11 5135/week @ 2021-06-18 4462/week @ 2021-06-25 5149/week @ 2021-07-02 6145/week @ 2021-07-09 7429/week @ 2021-07-16 6767/week @ 2021-07-23

21,480 downloads per month
Used in 58 crates (5 directly)

MIT/Apache

18KB
191 lines

License: MIT Apache License 2.0 docs.rs crates.io Github CI Minimum rustc version

OID Registry

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());
}

Extending the registry

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"));

Contributing OIDs

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.

Rust version requirements

oid-registry requires Rustc version 1.45 or greater, based on proc-macro attributes support.

License

Licensed under either of

at your option.

Contribution

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.

Dependencies

~3.5MB
~70K SLoC