Crate oid_registry

source ·
Expand description

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 asn1_rs::oid;
use oid_registry::{OidEntry, OidRegistry};

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.

Re-exports

pub use asn1_rs;

Structs

Temporary structure, created when reading a file containing OID declarations
Object ID (OID) representation which can be relative or non-relative. An example for an OID in string representation is "1.2.840.113549.1.1.5".
An entry stored in the OID registry
Registry of known OIDs

Constants

1.3.6.1.4.1.311.10.1
1.3.6.1.4.1.311.60.2.1.3
1.3.6.1.4.1.311.60.2.1.1
1.3.6.1.4.1.311.60.2.1.2
1.3.6.1.4.1.11129.2.4.2
0.9.2342.19200300.100.1.25
1.2.840.10045.3.1.7
1.2.643.2.2.19
1.3.14.3.2.26
1.3.133.16.840.63.0.2
1.2.840.10040.4.1
1.3.14.3.2.25
1.3.132.0.34
1.3.132.0.35
2.16.840.1.101.3.4.1.42
2.16.840.1.101.3.4.2.1
2.16.840.1.101.3.4.2.2
2.16.840.1.101.3.4.2.3
1.2.840.113549.1.1.2
1.2.840.113549.1.1.3
1.2.840.113549.1.1.4
1.2.840.113549.1.1.1
1.2.840.113549.1.1.10
1.2.840.113549.1.1.5
1.2.840.113549.1.1.14
1.2.840.113549.1.1.11
1.2.840.113549.1.1.12
1.2.840.113549.1.1.13
1.2.840.113549.1.7.1
1.2.840.113549.1.7.5
1.2.840.113549.1.7.6
1.2.840.113549.1.7.3
1.2.840.113549.1.7.2
1.2.840.113549.1.9.7
1.2.840.113549.1.9.3
1.2.840.113549.1.9.1
1.2.840.113549.1.9.14
1.2.840.113549.1.9.20
1.2.840.113549.1.9.4
1.2.840.113549.1.9.5
1.2.840.113549.1.9.15
1.2.840.113549.1.9.2
1.2.840.113549.1.12
1.2.840.113549.1.12.1
1.2.840.113549.1.12.1.4
1.2.840.113549.1.12.1.3
1.2.840.113549.1.12.1.6
1.2.840.113549.1.12.1.2
1.2.840.113549.1.12.1.5
1.2.840.113549.1.12.1.1
1.3.14.3.2.29
1.2.840.10040.4.3
1.2.840.10045.4.3.1
1.2.840.10045.4.3.2
1.2.840.10045.4.3.3
1.2.840.10045.4.3.4
1.3.101.113
1.3.101.112
0.9.2342.19200300.100.1.1
2.16.840.1.113730.1.2
2.16.840.1.113730.1.6
2.16.840.1.113730.1.5
2.16.840.1.113730.1.8
2.16.840.1.113730.1.4
2.16.840.1.113730.1.13
2.16.840.1.113730.1.1
2.16.840.1.113730.1.10
2.16.840.1.113730.1.9
2.16.840.1.113730.1.7
2.16.840.1.113730.1.3
2.16.840.1.113730.1.12
2.16.840.1.113730.1.11
1.3.6.1.4.1.311.2.1.4
1.3.6.1.4.1.311.2.1.15
1.3.6.1.4.1.311.2.1.12
1.3.6.1.4.1.311.2.1.11

Functions

Format a OID to a String, using the provided registry to get the short name if present.
Generate a file containing a with_<feat> method for OidRegistry
Load a file to an OID description map

Type Definitions

Temporary structure, created when reading a file containing OID declarations