pax_global_header00006660000000000000000000000064147503540500014515gustar00rootroot0000000000000052 comment=33b20513b73ce04e1de48232beba3fa89df33b1d rusticata-oid-registry-c3c015b/000077500000000000000000000000001475035405000165355ustar00rootroot00000000000000rusticata-oid-registry-c3c015b/.github/000077500000000000000000000000001475035405000200755ustar00rootroot00000000000000rusticata-oid-registry-c3c015b/.github/dependabot.yml000066400000000000000000000003121475035405000227210ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: "cargo" directory: "/" schedule: interval: "daily" - package-ecosystem: github-actions directory: "/" schedule: interval: weekly rusticata-oid-registry-c3c015b/.github/workflows/000077500000000000000000000000001475035405000221325ustar00rootroot00000000000000rusticata-oid-registry-c3c015b/.github/workflows/rust.yml000066400000000000000000000047521475035405000236620ustar00rootroot00000000000000name: Continuous integration on: push: pull_request: merge_group: schedule: - cron: '0 18 * * *' env: check_ext_rust_version: nightly-2024-06-30 # ^ sync with https://github.com/awslabs/cargo-check-external-types/blob/main/rust-toolchain.toml jobs: check: name: Check runs-on: ubuntu-latest strategy: matrix: rust: - stable - 1.63.0 - nightly steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - name: Cargo update run: cargo update - run: RUSTFLAGS="-D warnings" cargo check test: name: Test Suite runs-on: ubuntu-latest strategy: matrix: features: - --no-default-features - --features=default - --all-features steps: - uses: actions/checkout@v4 - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable - run: cargo test ${{ matrix.features }} fmt: name: Rustfmt runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: rustfmt - run: cargo fmt --all -- --check clippy: name: Clippy runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly with: components: clippy - run: cargo clippy -- -D warnings - run: cargo clippy --all-features -- -D warnings - run: cargo clippy --no-default-features -- -D warnings doc: name: Build documentation runs-on: ubuntu-latest env: RUSTDOCFLAGS: --cfg docsrs steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - run: cargo doc --workspace --no-deps --all-features semver: name: Check semver compatibility runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v4 - name: Check semver uses: obi1kenobi/cargo-semver-checks-action@v2 check-external-types: name: Validate external types appearing in public API runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v4 - name: Install rust toolchain uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.check_ext_rust_version }} - run: cargo install --locked cargo-check-external-types - run: cargo check-external-types rusticata-oid-registry-c3c015b/.github/workflows/security-audit.yml000066400000000000000000000004451475035405000256330ustar00rootroot00000000000000name: Security audit on: schedule: - cron: "0 8 * * *" push: paths: - "**/Cargo.*" jobs: security_audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: rustsec/audit-check@v2 with: token: ${{ secrets.GITHUB_TOKEN }} rusticata-oid-registry-c3c015b/.gitignore000066400000000000000000000000171475035405000205230ustar00rootroot00000000000000/target /.idea rusticata-oid-registry-c3c015b/.rustfmt.toml000066400000000000000000000000201475035405000212040ustar00rootroot00000000000000max_width = 140 rusticata-oid-registry-c3c015b/Cargo.lock000066400000000000000000000101251475035405000204410ustar00rootroot00000000000000# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "asn1-rs" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "607495ec7113b178fbba7a6166a27f99e774359ef4823adbefd756b5b81d7970" dependencies = [ "asn1-rs-derive", "asn1-rs-impl", "displaydoc", "nom", "num-traits", "rusticata-macros", "thiserror", ] [[package]] name = "asn1-rs-derive" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" dependencies = [ "proc-macro2", "quote", "syn", "synstructure", ] [[package]] name = "asn1-rs-impl" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "autocfg" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "displaydoc" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "nom" version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", ] [[package]] name = "num-traits" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "oid-registry" version = "0.8.1" dependencies = [ "asn1-rs", ] [[package]] name = "proc-macro2" version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] [[package]] name = "rusticata-macros" version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" dependencies = [ "nom", ] [[package]] name = "syn" version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "synstructure" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "thiserror" version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "unicode-ident" version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" rusticata-oid-registry-c3c015b/Cargo.toml000066400000000000000000000017531475035405000204730ustar00rootroot00000000000000[package] name = "oid-registry" version = "0.8.1" authors = ["Pierre Chifflier "] license = "MIT OR Apache-2.0" description = "Object Identifier (OID) database" keywords = ["BER", "DER", "OID"] homepage = "https://github.com/rusticata/oid-registry" repository = "https://github.com/rusticata/oid-registry.git" edition = "2018" build = "build.rs" readme = "README.md" rust-version = "1.63" include = [ "LICENSE-*", "README.md", ".gitignore", "Cargo.toml", "assets/*.txt", "build.rs", "src/*.rs", ] [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] default = ["registry"] registry = [] crypto = ["kdf","pkcs1","pkcs7","pkcs9","pkcs12","nist_algs","x962"] kdf = [] ms_spc = [] nist_algs = [] pkcs1 = [] pkcs7 = [] pkcs9 = [] pkcs12 = [] x500 = [] x509 = [] x962 = [] [dependencies] asn1-rs = "0.7" [package.metadata.cargo_check_external_types] allowed_external_types = [ "asn1_rs", "asn1_rs::asn1_types::oid::Oid", ] rusticata-oid-registry-c3c015b/LICENSE-APACHE000066400000000000000000000251371475035405000204710ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. rusticata-oid-registry-c3c015b/LICENSE-MIT000066400000000000000000000020441475035405000201710ustar00rootroot00000000000000Copyright (c) 2017 Pierre Chifflier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rusticata-oid-registry-c3c015b/README.md000066400000000000000000000066511475035405000200240ustar00rootroot00000000000000 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE-MIT) [![Apache License 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](./LICENSE-APACHE) [![docs.rs](https://docs.rs/oid-registry/badge.svg)](https://docs.rs/oid-registry) [![crates.io](https://img.shields.io/crates/v/oid-registry.svg)](https://crates.io/crates/oid-registry) [![Github CI](https://github.com/rusticata/oid-registry/workflows/Continuous%20integration/badge.svg)](https://github.com/rusticata/oid-registry/actions) [![Minimum rustc version](https://img.shields.io/badge/rustc-1.63.0+-lightgray.svg)](#rust-version-requirements) # 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. ```rust 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: ```rust 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")); ``` ## Versions and compatibility with `asn1-rs` Versions of `oid-registry` must be chosen specifically, to depend on a precise version of `asn1-rs`. The following table summarizes the matching versions: - `oid-registry` 0.7.x depends on `asn1-rs` 0.6.0 - `oid-registry` 0.6.x depends on `asn1-rs` 0.5.0 - `oid-registry` 0.5.x depends on `asn1-rs` 0.4.0 ## 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.63 or greater**, based on proc-macro attributes support and `asn1-rs`. # License Licensed under either of * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 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. rusticata-oid-registry-c3c015b/assets/000077500000000000000000000000001475035405000200375ustar00rootroot00000000000000rusticata-oid-registry-c3c015b/assets/oid_db.txt000066400000000000000000000376271475035405000220370ustar00rootroot00000000000000# # format: tab-separated values # # # if is "" then no constant will be written # x509 OID_USERID 0.9.2342.19200300.100.1.1 uid User ID x509 OID_DOMAIN_COMPONENT 0.9.2342.19200300.100.1.25 domainComponent Domain component x509 OID_SIG_GOST_R3411_94_WITH_R3410_2001 1.2.643.2.2.3 id-GostR3411-94-with-GostR3410-2001 GOST R 3411-94 with GOST R 3410-2001 x509 OID_GOST_R3410_2001 1.2.643.2.2.19 gostR3410-2001 GOST R 34.10-2001 x509 OID_KEY_TYPE_GOST_R3410_2012_256 1.2.643.7.1.1.1.1 gost3410-2012-256 GOST R 34.10-2012 public keys with 256 bits private key length x509 OID_KEY_TYPE_GOST_R3410_2012_512 1.2.643.7.1.1.1.2 gost3410-2012-512 GOST R 34.10-2012 public keys with 512 bits private key length x509 OID_SIG_GOST_R3410_2012_256 1.2.643.7.1.1.3.2 id-tc26-signwithdigest-gost3410-12-256 GOST R 34.10-2012 signature algorithm with 256-bit key length and GOST R 34.11-2012 hash function with 256-bit hash code x509 OID_SIG_GOST_R3410_2012_512 1.2.643.7.1.1.3.3 id-tc26-signwithdigest-gost3410-12-512 GOST R 34.10-2012 signature algorithm with 512-bit key length and GOST R 34.11-2012 hash function with 512-bit hash code x509 OID_KEY_TYPE_DSA 1.2.840.10040.4.1 id-dsa DSA subject public key x509 OID_SIG_DSA_WITH_SHA1 1.2.840.10040.4.3 dsa-with-sha1 DSA signature generated with SHA-1 algorithm x962 OID_KEY_TYPE_EC_PUBLIC_KEY 1.2.840.10045.2.1 id-ecPublicKey Elliptic curve public key cryptography x962 OID_SIG_ECDSA_WITH_SHA224 1.2.840.10045.4.3.1 ecdsa-with-SHA224 Elliptic curve Digital Signature Algorithm (DSA) coupled with the Secure Hash Algorithm 224 (SHA224) algorithm x962 OID_SIG_ECDSA_WITH_SHA256 1.2.840.10045.4.3.2 ecdsa-with-SHA256 Elliptic curve Digital Signature Algorithm (DSA) coupled with the Secure Hash Algorithm 256 (SHA256) algorithm x962 OID_SIG_ECDSA_WITH_SHA384 1.2.840.10045.4.3.3 ecdsa-with-SHA384 Elliptic curve Digital Signature Algorithm (DSA) coupled with the Secure Hash Algorithm 384 (SHA384) algorithm x962 OID_SIG_ECDSA_WITH_SHA512 1.2.840.10045.4.3.4 ecdsa-with-SHA512 Elliptic curve Digital Signature Algorithm (DSA) coupled with the Secure Hash Algorithm 512 (SHA512) algorithm x962 OID_EC_P256 1.2.840.10045.3.1.7 prime256v1 P-256 elliptic curve parameter pkcs1 OID_PKCS1_RSAENCRYPTION 1.2.840.113549.1.1.1 rsaEncryption RSAES-PKCS1-v1_5 encryption scheme pkcs1 OID_PKCS1_MD2WITHRSAENC 1.2.840.113549.1.1.2 md2WithRSAEncryption MD2 with RSA encryption pkcs1 OID_PKCS1_MD4WITHRSAENC 1.2.840.113549.1.1.3 md4WithRSAEncryption MD4 with RSA encryption pkcs1 OID_PKCS1_MD5WITHRSAENC 1.2.840.113549.1.1.4 md5WithRSAEncryption MD5 with RSA encryption pkcs1 OID_PKCS1_SHA1WITHRSA 1.2.840.113549.1.1.5 sha1WithRSAEncryption SHA1 with RSA encryption pkcs1 OID_PKCS1_RSASSAPSS 1.2.840.113549.1.1.10 rsassa-pss RSA Signature Scheme with Probabilistic Signature Scheme (RSASSA-PSS) pkcs1 OID_PKCS1_SHA256WITHRSA 1.2.840.113549.1.1.11 sha256WithRSAEncryption SHA256 with RSA encryption pkcs1 OID_PKCS1_SHA384WITHRSA 1.2.840.113549.1.1.12 sha384WithRSAEncryption SHA384 with RSA encryption pkcs1 OID_PKCS1_SHA512WITHRSA 1.2.840.113549.1.1.13 sha512WithRSAEncryption SHA512 with RSA encryption pkcs1 OID_PKCS1_SHA224WITHRSA 1.2.840.113549.1.1.14 sha224WithRSAEncryption SHA224 with RSA encryption pkcs7 OID_PKCS7_ID_DATA 1.2.840.113549.1.7.1 pkcs7-data pkcs7-data pkcs7 OID_PKCS7_ID_SIGNED_DATA 1.2.840.113549.1.7.2 pkcs7-signedData PKCS#7 Signed Data pkcs7 OID_PKCS7_ID_ENVELOPED_DATA 1.2.840.113549.1.7.3 pkcs7-envelopedData PKCS#7 Enveloped Data pkcs7 OID_PKCS7_ID_SIGNED_ENVELOPED_DATA 1.2.840.113549.1.7.4 pkcs7-signedAndEnvelopedData PKCS#7 Signed and Enveloped Data pkcs7 OID_PKCS7_ID_DIGESTED_DATA 1.2.840.113549.1.7.5 pkcs7-digestedData PKCS#7 Digested Data pkcs7 OID_PKCS7_ID_ENCRYPTED_DATA 1.2.840.113549.1.7.6 pkcs7-encryptedData PKCS#7 Encrypted Data pkcs9 OID_PKCS9_EMAIL_ADDRESS 1.2.840.113549.1.9.1 emailAddress Email Address attribute for use in signatures pkcs9 OID_PKCS9_UNSTRUCTURED_NAME 1.2.840.113549.1.9.2 unstructuredName PKCS#9 unstructuredName pkcs9 OID_PKCS9_CONTENT_TYPE 1.2.840.113549.1.9.3 contentType id-contentType pkcs9 OID_PKCS9_ID_MESSAGE_DIGEST 1.2.840.113549.1.9.4 id-messageDigest id-messageDigest pkcs9 OID_PKCS9_SIGNING_TIME 1.2.840.113549.1.9.5 signing-time id-signingTime pkcs9 OID_PKCS9_CHALLENGE_PASSWORD 1.2.840.113549.1.9.7 challengePassword PKCS #9 challenge password (as specified for PKSC#10 in RFC2986) pkcs9 OID_PKCS9_EXTENSION_REQUEST 1.2.840.113549.1.9.14 extensionRequest Extension list for Certification Requests pkcs9 OID_PKCS9_SMIME_CAPABILITIES 1.2.840.113549.1.9.15 smimeCapabilities aa-smimeCapabilities pkcs9 OID_PKCS9_FRIENDLY_NAME 1.2.840.113549.1.9.20 friendlyName PKCS #9 attribute friendlyName (for PKCS #12) pkcs12 OID_PKCS12 1.2.840.113549.1.12 pkcs-12 Public-Key Cryptography Standard (PKCS) #12 pkcs12 OID_PKCS12_PBEIDS 1.2.840.113549.1.12.1 pkcs-12PbeIds PKCS #12 Password Based Encryption IDs pkcs12 OID_PKCS12_PBE_SHA1_128RC4 1.2.840.113549.1.12.1.1 pbeWithSHAAnd128BitRC4 PKCS #12 Password Based Encryption With SHA-1 and 128-bit RC4 pkcs12 OID_PKCS12_PBE_SHA1_40RC4 1.2.840.113549.1.12.1.2 pbeWithSHAAnd40BitRC4 PKCS #12 Password Based Encryption With SHA-1 and 40-bit RC4 pkcs12 OID_PKCS12_PBE_SHA1_3K_3DES_CBC 1.2.840.113549.1.12.1.3 pbeWithSHAAnd3-KeyTripleDES-CBC PKCS #12 Password Based Encryption With SHA-1 and 3-key Triple DES in CBC mode pkcs12 OID_PKCS12_PBE_SHA1_2K_3DES_CBC 1.2.840.113549.1.12.1.4 pbeWithSHAAnd2-KeyTripleDES-CBC PKCS #12 Password Based Encryption With SHA-1 and 2-key Triple DES in CBC mode pkcs12 OID_PKCS12_PBE_SHA1_128RC2_CBC 1.2.840.113549.1.12.1.5 pbeWithSHAAnd128BitRC2-CBC PKCS #12 Password Based Encryption With SHA-1 and 128-bit RC2-CBC pkcs12 OID_PKCS12_PBE_SHA1_40RC2_CBC 1.2.840.113549.1.12.1.6 pbeWithSHAAnd40BitRC2-CBC PKCS #12 Password Based Encryption With SHA-1 and 40-bit RC2-CBC x509 OID_SIG_RSA_RIPE_MD160 1.3.36.3.3.1.2 rsaSignatureWithripemd160 RSA signature in combination with hash algorithm RIPEMD-160 x509 OID_SIG_ED25519 1.3.101.112 ed25519 Edwards-curve Digital Signature Algorithm (EdDSA) Ed25519 x509 OID_SIG_ED448 1.3.101.113 ed448 Edwards-curve Digital Signature Algorithm (EdDSA) Ed448 nist-algs OID_NIST_EC_P384 1.3.132.0.34 secp384r1 P-384 elliptic curve parameter nist-algs OID_NIST_EC_P521 1.3.132.0.35 secp521r1 P-521 elliptic curve parameter kdf OID_KDF_SHA1_SINGLE 1.3.133.16.840.63.0.2 dhSinglePass-stdDH-sha1kdf-scheme Single pass Secure Hash Algorithm 1 (SHA1) key derivation ms-spc SPC_INDIRECT_DATA_OBJID 1.3.6.1.4.1.311.2.1.4 spcIndirectData The SPC_INDIRECT_DATA_CONTENT structure is used in Authenticode signatures to store the digest and other attributes of the signed file ms-spc SPC_STATEMENT_TYPE_OBJID 1.3.6.1.4.1.311.2.1.11 spcStatementType spcStatementType ms-spc SPC_SP_OPUS_INFO_OBJID 1.3.6.1.4.1.311.2.1.12 spcSpOpusInfo SpcSpOpusInfo ms-spc SPC_PE_IMAGE_DATA 1.3.6.1.4.1.311.2.1.15 spcPEImageData spcPEImageData ms-spc SPC_INDIVIDUAL_SP_KEY_PURPOSE_OBJID 1.3.6.1.4.1.311.2.1.21 msCodeInd MsCodeInd (SPC_INDIVIDUAL_SP_KEY_PURPOSE_OBJID) is a ExtendedKeyUsage for Certificate Extensions which indicates Microsoft Individual Code Signing (authenticode) ms-spc MS_CTL 1.3.6.1.4.1.311.10.1 szOID_CTL MS_CTL x509 MS_JURISDICTION_LOCALITY 1.3.6.1.4.1.311.60.2.1.1 msJurisdictionLocality X520LocalityName as specified in RFC 3280 x509 MS_JURISDICTION_STATE_OR_PROVINCE 1.3.6.1.4.1.311.60.2.1.2 msJurisdictionStateOrProvince X520StateOrProvinceName as specified in RFC 3280 x509 MS_JURISDICTION_COUNTRY 1.3.6.1.4.1.311.60.2.1.3 msJurisdictionCountry X520countryName as specified in RFC 3280 # Certificate Transparency: https://tools.ietf.org/html/rfc6962#section-3.3 x509 OID_CT_LIST_SCT 1.3.6.1.4.1.11129.2.4.2 ctSCTList Certificate Transparency Signed Certificate Timestamp List # PKIX Certificate Extension # https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-1.3.6.1.5.5.7.1 x509 OID_PKIX_AUTHORITY_INFO_ACCESS 1.3.6.1.5.5.7.1.1 authorityInfoAccess Certificate Authority Information Access x509 OID_PKIX_SUBJECT_INFO_ACCESS 1.3.6.1.5.5.7.1.11 subjectInfoAccess Certificate Subject Information Access # PKIX Access Descriptor # https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-1.3.6.1.5.5.7.48 x509 OID_PKIX_ACCESS_DESCRIPTOR_OCSP 1.3.6.1.5.5.7.48.1 id-ad-ocsp PKIX Access Descriptor OCSP x509 OID_PKIX_ACCESS_DESCRIPTOR_CA_ISSUERS 1.3.6.1.5.5.7.48.2 id-ad-caIssuers PKIX Access Descriptor CA Issuers x509 OID_PKIX_ACCESS_DESCRIPTOR_TIMESTAMPING 1.3.6.1.5.5.7.48.3 id-ad-timestamping PKIX Access Descriptor Timestamping x509 OID_PKIX_ACCESS_DESCRIPTOR_DVCS 1.3.6.1.5.5.7.48.4 id-ad-dvcs PKIX Access Descriptor DVCS x509 OID_PKIX_ACCESS_DESCRIPTOR_CA_REPOSITORY 1.3.6.1.5.5.7.48.5 id-ad-caRepository PKIX Access Descriptor CA Repository x509 OID_PKIX_ACCESS_DESCRIPTOR_HTTP_CERTS 1.3.6.1.5.5.7.48.6 id-ad-http-certs PKIX Access Descriptor HTTP Certificates x509 OID_PKIX_ACCESS_DESCRIPTOR_HTTP_CRLS 1.3.6.1.5.5.7.48.7 id-ad-http-crls PKIX Access Descriptor HTTP Certificate Revocation Lists # x509 OID_PKIX_ACCESS_DESCRIPTOR_RPKI_MANIFEST 1.3.6.1.5.5.7.48.10 id-ad-rpki-manifest PKIX Access Descriptor RPKI Manifest x509 OID_PKIX_ACCESS_DESCRIPTOR_SIGNED_OBJECT 1.3.6.1.5.5.7.48.11 id-ad-signed-object PKIX Access Descriptor Signed Object x509 OID_PKIX_ACCESS_DESCRIPTOR_CMC 1.3.6.1.5.5.7.48.12 id-ad-cmc PKIX Access Descriptor CMC x509 OID_PKIX_ACCESS_DESCRIPTOR_RPKI_NOTIFY 1.3.6.1.5.5.7.48.13 id-ad-rpki-notify PKIX Access Descriptor RPKI Notify x509 OID_PKIX_ACCESS_DESCRIPTOR_STIRTNLIST 1.3.6.1.5.5.7.48.14 id-ad-stirTNList PKIX Access Descriptor STIRTNLIST nist-algs OID_MD5_WITH_RSA 1.3.14.3.2.25 md5WithRSASignature RSA algorithm coupled with the MD5 hashing algorithm (Oddball using ISO/IEC 9796-2 padding rules) nist-algs OID_HASH_SHA1 1.3.14.3.2.26 id-SHA1 SHA-1 hash algorithm nist-algs OID_SHA1_WITH_RSA 1.3.14.3.2.29 sha1WithRSAEncryption RSA algorithm that uses the Secure Hash Algorithm 1 (SHA1) (obsolete) x500 OID_X500 2.5 x500 X.500 x509 OID_X509 2.5.4 x509 X.509 x509 OID_X509_OBJECT_CLASS 2.5.4.0 objectClass Object classes x509 OID_X509_ALIASED_ENTRY_NAME 2.5.4.1 aliasedEntryName Aliased entry/object name x509 OID_X509_KNOWLEDGE_INFORMATION 2.5.4.2 knowledgeInformation 'knowledgeInformation' attribute type x509 OID_X509_COMMON_NAME 2.5.4.3 commonName Common Name x509 OID_X509_SURNAME 2.5.4.4 surname Surname x509 OID_X509_SERIALNUMBER 2.5.4.5 serialNumber Serial Number x509 OID_X509_COUNTRY_NAME 2.5.4.6 countryName Country Name x509 OID_X509_LOCALITY_NAME 2.5.4.7 localityName Locality Name x509 OID_X509_STATE_OR_PROVINCE_NAME 2.5.4.8 stateOrProvinceName State or Province name x509 OID_X509_STREET_ADDRESS 2.5.4.9 streetAddress Street Address x509 OID_X509_ORGANIZATION_NAME 2.5.4.10 organizationName Organization Name x509 OID_X509_ORGANIZATIONAL_UNIT 2.5.4.11 organizationalUnit Organizational Unit x509 OID_X509_TITLE 2.5.4.12 title Title x509 OID_X509_DESCRIPTION 2.5.4.13 description Description x509 OID_X509_SEARCH_GUIDE 2.5.4.14 searchGuide Search Guide x509 OID_X509_BUSINESS_CATEGORY 2.5.4.15 businessCategory Business Category x509 OID_X509_POSTAL_ADDRESS 2.5.4.16 postalAddress Postal Address x509 OID_X509_POSTAL_CODE 2.5.4.17 postalCode Postal Code # x509 OID_X509_NAME 2.5.4.41 name Name x509 OID_X509_GIVEN_NAME 2.5.4.42 givenName Given Name x509 OID_X509_INITIALS 2.5.4.43 initials Initials of an individual's name x509 OID_X509_GENERATION_QUALIFIER 2.5.4.44 generationQualifier Generation information to qualify an individual's name x509 OID_X509_UNIQUE_IDENTIFIER 2.5.4.45 uniqueIdentifier Unique Identifier x509 OID_X509_DN_QUALIFIER 2.5.4.46 dnQualifier DN Qualifier # # https://www.alvestrand.no/objectid/2.5.29.html x509 OID_X509_OBSOLETE_AUTHORITY_KEY_IDENTIFIER 2.5.29.1 oldAuthorityKeyIdentifier X509v3 Authority Key Identifier (obsolete) x509 OID_X509_OBSOLETE_KEY_ATTRIBUTES 2.5.29.2 oldKeyAttributes X509v3 Key Attributes (obsolete) x509 OID_X509_OBSOLETE_CERTIFICATE_POLICIES 2.5.29.3 oldCertificatePolicies X509v3 Certificate Policies (obsolete) x509 OID_X509_OBSOLETE_KEY_USAGE 2.5.29.4 oldKeyUsage X509v3 Key Usage Restriction (obsolete) x509 OID_X509_OBSOLETE_POLICY_MAPPING 2.5.29.5 oldPolicyMapping X509v3 Policy Mapping (obsolete) x509 OID_X509_OBSOLETE_SUBTREES_CONSTRAINT 2.5.29.6 oldSubtreesConstraint X509v3 Subtrees Constraint (obsolete) x509 OID_X509_OBSOLETE_SUBJECT_ALT_NAME 2.5.29.7 oldSubjectAltNAme X509v3 Subject Alternative Name (obsolete) x509 OID_X509_OBSOLETE_ISSUER_ALT_NAME 2.5.29.8 oldIssuerAltNAme X509v3 Issuer Alternative Name (obsolete) x509 OID_X509_EXT_SUBJECT_KEY_IDENTIFIER 2.5.29.14 subjectKeyIdentifier X509v3 Subject Key Identifier x509 OID_X509_EXT_KEY_USAGE 2.5.29.15 keyUsage X509v3 Key Usage x509 OID_X509_EXT_PRIVATE_KEY_USAGE_PERIOD 2.5.29.16 privateKeyUsagePeriod X509v3 Private Key Usage Period x509 OID_X509_EXT_SUBJECT_ALT_NAME 2.5.29.17 subjectAltName X509v3 Subject Alternative Name x509 OID_X509_EXT_ISSUER_ALT_NAME 2.5.29.18 issuerAltName X509v3 Issuer Alternative Name x509 OID_X509_EXT_BASIC_CONSTRAINTS 2.5.29.19 basicConstraints X509v3 Basic Constraints x509 OID_X509_EXT_CRL_NUMBER 2.5.29.20 crlNumber X509v3 CRL Number x509 OID_X509_EXT_REASON_CODE 2.5.29.21 reasonCode X509v3 Reason Code # no 2.5.29.22 x509 OID_X509_EXT_HOLD_INSTRUCTION_CODE 2.5.29.23 holdInstructionCode X509v3 Hold Instruction Code x509 OID_X509_EXT_INVALIDITY_DATE 2.5.29.24 invalidityDate X509v3 Invalidity Date # no 2.5.29.25 2.5.29.26 x509 OID_X509_EXT_DELTA_CRL_INDICATOR 2.5.29.27 deltaCRLIndicator X509v3 Delta CRL Indicator x509 OID_X509_EXT_ISSUER_DISTRIBUTION_POINT 2.5.29.28 issuerDistributionPoint X509v3 Issuer Distribution Point x509 OID_X509_EXT_ISSUER 2.5.29.29 issuer X509v3 Issuer x509 OID_X509_EXT_NAME_CONSTRAINTS 2.5.29.30 nameConstraints X509v3 Name Constraints x509 OID_X509_EXT_CRL_DISTRIBUTION_POINTS 2.5.29.31 crlDistributionPoints X509v3 CRL Distribution Points x509 OID_X509_EXT_CERTIFICATE_POLICIES 2.5.29.32 certificatePolicies X509v3 Certificate Policies x509 OID_X509_EXT_POLICY_MAPPINGS 2.5.29.33 policyMappings X509v3 Policy Mappings # no 2.5.29.34 x509 OID_X509_EXT_AUTHORITY_KEY_IDENTIFIER 2.5.29.35 authorityKeyIdentifier X509v3 Authority Key Identifier x509 OID_X509_EXT_POLICY_CONSTRAINTS 2.5.29.36 policyConstraints X509v3 Policy Constraints x509 OID_X509_EXT_EXTENDED_KEY_USAGE 2.5.29.37 extendedKeyUsage X509v3 Extended Key Usage # x509 OID_X509_EXT_FRESHEST_CRL 2.5.29.46 freshestCRL X509v3 Freshest CRL # x509 OID_X509_EXT_INHIBIT_ANY_POLICY 2.5.29.54 inhibitAnyPolicy X509v3 Inhibit Any-policy nist-algs OID_NIST_ENC_AES256_CBC 2.16.840.1.101.3.4.1.42 aes-256-cbc 256-bit Advanced Encryption Standard (AES) algorithm with Cipher-Block Chaining (CBC) mode of operation nist-algs OID_NIST_HASH_SHA256 2.16.840.1.101.3.4.2.1 sha256 Secure Hash Algorithm that uses a 256 bit key (SHA256) nist-algs OID_NIST_HASH_SHA384 2.16.840.1.101.3.4.2.2 sha384 Secure Hash Algorithm that uses a 384 bit key (SHA384) nist-algs OID_NIST_HASH_SHA512 2.16.840.1.101.3.4.2.3 sha512 Secure Hash Algorithm that uses a 512 bit key (SHA512) x509 OID_X509_EXT_CERT_TYPE 2.16.840.1.113730.1.1 nsCertType X.509 v3 Certificate Type x509 OID_X509_EXT_BASE_URL 2.16.840.1.113730.1.2 nsBaseURL Base URL x509 OID_X509_EXT_REVOCATION_URL 2.16.840.1.113730.1.3 nsRevocationURL Revocation URL x509 OID_X509_EXT_CA_REVOCATION_URL 2.16.840.1.113730.1.4 nsCARevocationURL CA Revocation URL x509 OID_X509_EXT_CA_CRL_URL 2.16.840.1.113730.1.5 nsCACRLURL CA CRL URL x509 OID_X509_EXT_CA_CERT_URL 2.16.840.1.113730.1.6 nsCACertURL CA Certificate URL x509 OID_X509_EXT_RENEWAL_URL 2.16.840.1.113730.1.7 nsRenewalURL Renewal URL x509 OID_X509_EXT_CA_POLICY_URL 2.16.840.1.113730.1.8 nsCAPolicyURL CA Policy URL x509 OID_X509_EXT_HOMEPAGE_URL 2.16.840.1.113730.1.9 nsHomepageURL Certificate Homepage URL x509 OID_X509_EXT_ENTITY_LOGO 2.16.840.1.113730.1.10 nsEntityLogo Certificate Entity Logo x509 OID_X509_EXT_USER_PICTURE 2.16.840.1.113730.1.11 nsUserPicture Certificate User Picture x509 OID_X509_EXT_SSL_SERVER_NAME 2.16.840.1.113730.1.12 nsSSLServerName SSL Server Name x509 OID_X509_EXT_CERT_COMMENT 2.16.840.1.113730.1.13 nsComment Certificate Comment rusticata-oid-registry-c3c015b/build.rs000066400000000000000000000005131475035405000202010ustar00rootroot00000000000000use std::env; include!("src/load.rs"); fn main() -> Result<()> { println!("cargo:rerun-if-changed=assets/oid_db.txt"); let out_dir = env::var_os("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("oid_db.rs"); let m = load_file("assets/oid_db.txt")?; generate_file(&m, dest_path)?; Ok(()) } rusticata-oid-registry-c3c015b/src/000077500000000000000000000000001475035405000173245ustar00rootroot00000000000000rusticata-oid-registry-c3c015b/src/deprecated.rs000066400000000000000000000003511475035405000217710ustar00rootroot00000000000000use asn1_rs::Oid; /// X509v3 Inhibit Any-policy #[deprecated(since = "0.8.1", note = "please use OID_X509_EXT_INHIBIT_ANY_POLICY instead")] pub const OID_X509_EXT_INHIBITANT_ANY_POLICY: Oid = crate::OID_X509_EXT_INHIBIT_ANY_POLICY; rusticata-oid-registry-c3c015b/src/lib.rs000066400000000000000000000225641475035405000204510ustar00rootroot00000000000000//! [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE-MIT) //! [![Apache License 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](./LICENSE-APACHE) //! [![docs.rs](https://docs.rs/oid-registry/badge.svg)](https://docs.rs/oid-registry) //! [![crates.io](https://img.shields.io/crates/v/oid-registry.svg)](https://crates.io/crates/oid-registry) //! [![Github CI](https://github.com/rusticata/oid-registry/workflows/Continuous%20integration/badge.svg)](https://github.com/rusticata/oid-registry/actions) //! [![Minimum rustc version](https://img.shields.io/badge/rustc-1.63.0+-lightgray.svg)](#rust-version-requirements) //! # 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. //! //! ```rust //! use oid_registry::OidRegistry; //! //! let mut registry = OidRegistry::default() //! # ; //! # #[cfg(feature = "crypto")] { //! # registry = registry //! .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: //! //! ```rust //! 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")); //! //! ``` //! //! ## Versions and compatibility with `asn1-rs` //! //! Versions of `oid-registry` must be chosen specifically, to depend on a precise version of `asn1-rs`. //! The following table summarizes the matching versions: //! //! - `oid-registry` 0.7.x depends on `asn1-rs` 0.6.0 //! - `oid-registry` 0.6.x depends on `asn1-rs` 0.5.0 //! - `oid-registry` 0.5.x depends on `asn1-rs` 0.4.0 //! //! ## 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. #![deny(missing_docs, unstable_features, unused_import_braces, unused_qualifications, unreachable_pub)] #![forbid(unsafe_code)] #![warn( /* missing_docs, rust_2018_idioms,*/ missing_debug_implementations, )] // pragmas for doc // #![deny(intra_doc_link_resolution_failure)] #![cfg_attr(docsrs, feature(doc_cfg))] pub use asn1_rs; pub use asn1_rs::Oid; use asn1_rs::oid; use std::borrow::Cow; use std::collections::HashMap; mod deprecated; mod load; pub use deprecated::*; pub use load::*; /// An entry stored in the OID registry #[derive(Debug)] pub struct OidEntry { // Short name sn: Cow<'static, str>, description: Cow<'static, str>, } impl OidEntry { /// Create a new entry pub fn new(sn: S, description: T) -> OidEntry where S: Into>, T: Into>, { let sn = sn.into(); let description = description.into(); OidEntry { sn, description } } /// Get the short name for this entry #[inline] pub fn sn(&self) -> &str { &self.sn } /// Get the description for this entry #[inline] pub fn description(&self) -> &str { &self.description } } impl From<(&'static str, &'static str)> for OidEntry { fn from(t: (&'static str, &'static str)) -> Self { Self::new(t.0, t.1) } } /// Registry of known OIDs /// /// Use `OidRegistry::default()` to create an empty registry. If the corresponding features have /// been selected, the `with_xxx()` methods can be used to add sets of known objets to the /// database. /// /// # Example /// /// ```rust /// use asn1_rs::{oid, Oid}; /// use oid_registry::{OidEntry, OidRegistry}; /// /// let mut registry = OidRegistry::default() /// # ; /// # #[cfg(feature = "crypto")] { /// # registry = registry /// .with_crypto() // only if the 'crypto' feature is enabled /// # } /// ; /// /// // 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")); /// /// // To query an entry, use the `get` method: /// const OID_1234: Oid<'static> = oid!(1.2.3.4); /// let e = registry.get(&OID_1234); /// assert!(e.is_some()); /// if let Some(e) = e { /// assert_eq!(e.sn(), "shortName"); /// } /// ``` #[derive(Debug, Default)] pub struct OidRegistry<'a> { map: HashMap, OidEntry>, } impl<'a> OidRegistry<'a> { /// Insert a new entry pub fn insert(&mut self, oid: Oid<'a>, entry: E) -> Option where E: Into, { self.map.insert(oid, entry.into()) } /// Returns a reference to the registry entry, if found for this OID. pub fn get(&self, oid: &Oid<'a>) -> Option<&OidEntry> { self.map.get(oid) } /// Return an Iterator over references to the OID numbers (registry keys) pub fn keys(&self) -> impl Iterator> { self.map.keys() } /// Return an Iterator over references to the `OidEntry` values pub fn values(&self) -> impl Iterator { self.map.values() } /// Return an Iterator over references to the `(Oid, OidEntry)` key/value pairs pub fn iter(&self) -> impl Iterator, &OidEntry)> { self.map.iter() } /// Return the `(Oid, OidEntry)` key/value pairs, matching a short name /// /// The registry should not contain entries with same short name to avoid ambiguity, but it is /// not mandatory. /// /// This function returns an iterator over the key/value pairs. In most cases, it will have 0 /// (not found) or 1 item, but can contain more if there are multiple definitions. /// /// ```rust /// # use oid_registry::OidRegistry; /// # /// # let registry = OidRegistry::default(); /// // iterate all entries matching "shortName" /// for (oid, entry) in registry.iter_by_sn("shortName") { /// // do something /// } /// /// // if you are *sure* that there is at most one entry: /// let opt_sn = registry.iter_by_sn("shortName").next(); /// if let Some((oid, entry)) = opt_sn { /// // do something /// } /// ``` pub fn iter_by_sn>(&self, sn: S) -> impl Iterator, &OidEntry)> { let s = sn.into(); self.map.iter().filter(move |(_, entry)| entry.sn == s) } /// Populate registry with common crypto OIDs (encryption, hash algorithms) #[cfg(feature = "crypto")] #[cfg_attr(docsrs, doc(cfg(feature = "crypto")))] pub fn with_crypto(self) -> Self { self.with_pkcs1().with_x962().with_kdf().with_nist_algs() } /// Populate registry with all known crypto OIDs (encryption, hash algorithms, PKCS constants, /// etc.) #[cfg(feature = "crypto")] #[cfg_attr(docsrs, doc(cfg(feature = "crypto")))] pub fn with_all_crypto(self) -> Self { self.with_crypto().with_pkcs7().with_pkcs9().with_pkcs12() } } /// Format a OID to a `String`, using the provided registry to get the short name if present. pub fn format_oid(oid: &Oid, registry: &OidRegistry) -> String { if let Some(entry) = registry.map.get(oid) { format!("{} ({})", entry.sn, oid) } else { format!("{}", oid) } } include!(concat!(env!("OUT_DIR"), "/oid_db.rs")); #[rustfmt::skip::macros(oid)] #[cfg(test)] mod tests { use super::*; // This test is mostly a compile test, to ensure the API has not changed #[test] fn test_lifetimes() { fn add_entry(input: &str, oid: Oid<'static>, registry: &mut OidRegistry) { // test insertion of owned string let s = String::from(input); let entry = OidEntry::new("test", s); registry.insert(oid, entry); } let mut registry = OidRegistry::default(); add_entry("a", oid!(1.2.3.4), &mut registry); add_entry("b", oid!(1.2.3.5), &mut registry); // test insertion of owned data let e = OidEntry::new("c", "test_c"); registry.insert(oid!(1.2.4.1), e); registry.insert(oid!(1.2.5.1), ("a", "b")); let iter = registry.iter_by_sn("test"); assert_eq!(iter.count(), 2); // dbg!(®istry); } } rusticata-oid-registry-c3c015b/src/load.rs000066400000000000000000000071551475035405000206210ustar00rootroot00000000000000use std::collections::BTreeMap; use std::fs::File; use std::io::{BufRead, BufReader, Result, Write}; use std::path::Path; /// Temporary structure, created when reading a file containing OID declarations #[derive(Debug)] pub struct LoadedEntry { /// Name of the global constant for this entry. /// /// If `name` is "", then no global constant is defined pub name: String, /// Textual representation of OID (ex: 2.5.4.3) pub oid: String, /// A short name to describe OID. Should be unique (no check is done) pub sn: String, /// A description for this entry pub description: String, } /// Temporary structure, created when reading a file containing OID declarations pub type LoadedMap = BTreeMap>; /// Load a file to an OID description map /// /// format of the file: tab-separated values ///
/// feature   name   oid   short_name   description (until end of line)
/// 
/// /// `name` is used to declare a global constant when creating output file (see `generate_file`). /// If `name` is "" then no constant will be written /// pub fn load_file>(path: P) -> Result { let mut map = BTreeMap::new(); let file = File::open(path)?; for line in BufReader::new(file).lines() { let line = line?; if line.is_empty() || line.starts_with('#') { continue; } // split by tabs let mut iter = line.splitn(5, '\t'); let feature = iter.next().expect("invalid oid_db format: missing feature").replace('-', "_"); let name = iter.next().expect("invalid oid_db format: missing name").to_string(); let oid = iter.next().expect("invalid oid_db format: missing OID").to_string(); let sn = iter.next().expect("invalid oid_db format: missing short name").to_string(); let description = iter.next().expect("invalid oid_db format: missing description").to_string(); let entry = LoadedEntry { name, oid, sn, description, }; let v = map.entry(feature.to_string()).or_insert_with(Vec::new); v.push(entry); } Ok(map) } /// Generate a file containing a `with_` method for OidRegistry pub fn generate_file>(map: &LoadedMap, dest_path: P) -> Result<()> { let mut out_file = File::create(&dest_path)?; for feat_entries in map.values() { for v in feat_entries { if v.name != "\"\"" { writeln!(out_file, "/// {}", v.oid)?; writeln!(out_file, "pub const {}: Oid<'static> = oid!({});", v.name, v.oid)?; } } } writeln!(out_file)?; writeln!(out_file, r#"#[cfg(feature = "registry")]"#)?; writeln!(out_file, r#"#[cfg_attr(docsrs, doc(cfg(feature = "registry")))]"#)?; writeln!(out_file, "impl OidRegistry<'_> {{")?; for (k, v) in map { writeln!(out_file, r#" #[cfg(feature = "{}")]"#, k)?; writeln!(out_file, r#" #[cfg_attr(docsrs, doc(cfg(feature = "{}")))]"#, k)?; writeln!( out_file, r#" #[doc = "Load all known OIDs for feature `{}` in the registry."]"#, k )?; writeln!(out_file, " pub fn with_{}(mut self) -> Self {{", k)?; for item in v { writeln!( out_file, r#" self.insert(oid!({}), OidEntry::new("{}", "{}"));"#, item.oid, item.sn, item.description )?; } writeln!(out_file, " self")?; writeln!(out_file, " }}")?; writeln!(out_file)?; } writeln!(out_file, "}}")?; Ok(()) }