[][src]Crate oid_registry

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

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_RSA_DSI_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.

Structs

LoadedEntry

Temporary structure, created when reading a file containing OID declarations

OidEntry

An entry stored in the OID registry

OidRegistry

Registry of known OIDs

Constants

MS_CTL
OID_DOMAIN_COMPONENT
OID_KDF_SHA1_SINGLE
OID_KEY_TYPE_EC_PUBLIC_KEY
OID_NIST_ENC_AES256_CBC
OID_NIST_HASH_SHA256
OID_PKCS7_ID_DATA
OID_PKCS7_ID_DIGESTED_DATA
OID_PKCS7_ID_ENCRYPTED_DATA
OID_PKCS7_ID_ENVELOPED_DATA
OID_PKCS7_ID_SIGNED_DATA
OID_PKCS7_ID_SIGNED_ENVELOPED_DATA
OID_PKCS9_CONTENT_TYPE
OID_PKCS9_EMAIL_ADDRESS
OID_PKCS9_ID_MESSAGE_DIGEST
OID_PKCS9_SIGNING_TIME
OID_PKCS9_SMIME_CAPABILITIES
OID_PKCS9_UNSTRUCTURED_NAME
OID_RSA_DSI_PKCS1_MD2WITHRSAENC
OID_RSA_DSI_PKCS1_MD4WITHRSAENC
OID_RSA_DSI_PKCS1_MD5WITHRSAENC
OID_RSA_DSI_PKCS1_RSAENCRYPTION
OID_RSA_DSI_PKCS1_RSASSAPSS
OID_RSA_DSI_PKCS1_SHA1WITHRSA
OID_RSA_DSI_PKCS1_SHA224WITHRSA
OID_RSA_DSI_PKCS1_SHA256WITHRSA
OID_RSA_DSI_PKCS1_SHA384WITHRSA
OID_RSA_DSI_PKCS1_SHA512WITHRSA
OID_X500
OID_X509
OID_X509_ALIASED_ENTRY_NAME
OID_X509_COMMON_NAME
OID_X509_COUNTRY_NAME
OID_X509_DESCRIPTION
OID_X509_KNOWLEDGE_INFORMATION
OID_X509_OBJECT_CLASS
OID_X509_ORGANIZATIONAL_UNIT
OID_X509_ORGANIZATION_NAME
OID_X509_STATE_OR_PROVINCE_NAME
OID_X509_STREET_ADDRESS
OID_X509_SURNAME
OID_X509_TITLE
SPC_INDIRECT_DATA_OBJID
SPC_INDIVIDUAL_SP_KEY_PURPOSE_OBJID
SPC_PE_IMAGE_DATA
SPC_SP_OPUS_INFO_OBJID
SPC_STATEMENT_TYPE_OBJID

Functions

format_oid

Format a OID to a String, using the provided registry to get the short name if present.

generate_file

Generate a file containing a with_<feat> method for OidRegistry

load_file

Load a file to an OID description map

Type Definitions

LoadedMap

Temporary structure, created when reading a file containing OID declarations