Skip to content

Commit

Permalink
fix: data tables
Browse files Browse the repository at this point in the history
  • Loading branch information
bkioshn committed Jul 9, 2024
1 parent bae088a commit db23d96
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,153 +14,38 @@ use crate::tables::IntegerToOidTable;
/// Int | OID | Type | Name
type ExtensionDataTuple = (i16, Oid<'static>, ExtensionValueType, &'static str);

/// Create a type alias for `ExtensionValueType`
type Evt = ExtensionValueType;

/// `Extension` data table
#[rustfmt::skip]
const EXTENSION_DATA: [ExtensionDataTuple; 25] = [
(
1,
oid!(2.5.29 .14),
ExtensionValueType::Bytes,
"Subject Key Identifier",
),
(2, oid!(2.5.29 .15), ExtensionValueType::Int, "Key Usage"),
(
3,
oid!(2.5.29 .17),
ExtensionValueType::AlternativeName,
"Subject Alternative Name",
),
(
4,
oid!(2.5.29 .19),
ExtensionValueType::Int,
"Basic Constraints",
),
(
5,
oid!(2.5.29 .31),
ExtensionValueType::Unsupported,
"CRL Distribution Points",
),
(
6,
oid!(2.5.29 .32),
ExtensionValueType::Unsupported,
"Certificate Policies",
),
(
7,
oid!(2.5.29 .35),
ExtensionValueType::Unsupported,
"Authority Key Identifier",
),
(
8,
oid!(2.5.29 .37),
ExtensionValueType::Unsupported,
"Extended Key Usage",
),
(
9,
oid!(1.3.6 .1 .5 .5 .7 .1 .1),
ExtensionValueType::Unsupported,
"Authority Information Access",
),
(
10,
oid!(1.3.6 .1 .4 .1 .11129 .2 .4 .2),
ExtensionValueType::Unsupported,
"Signed Certificate Timestamp List",
),
(
24,
oid!(2.5.29 .9),
ExtensionValueType::Unsupported,
"Subject Directory Attributes",
),
(
25,
oid!(2.5.29 .18),
ExtensionValueType::AlternativeName,
"Issuer Alternative Name",
),
(
26,
oid!(2.5.29 .30),
ExtensionValueType::Unsupported,
"Name Constraints",
),
(
27,
oid!(2.5.29 .33),
ExtensionValueType::Unsupported,
"Policy Mappings",
),
(
28,
oid!(2.5.29 .36),
ExtensionValueType::Unsupported,
"Policy Constraints",
),
(
29,
oid!(2.5.29 .46),
ExtensionValueType::Unsupported,
"Freshest CRL",
),
(
30,
oid!(2.5.29 .54),
ExtensionValueType::Int,
"Inhibit anyPolicy",
),
(
31,
oid!(1.3.6 .1 .5 .5 .7 .1 .11),
ExtensionValueType::Unsupported,
"Subject Information Access",
),
(
32,
oid!(1.3.6 .1 .5 .5 .7 .1 .7),
ExtensionValueType::Unsupported,
"IP Resources",
),
(
33,
oid!(1.3.6 .1 .5 .5 .7 .1 .7),
ExtensionValueType::Unsupported,
"AS Resource",
),
(
34,
oid!(1.3.6 .1 .5 .5 .7 .1 .28),
ExtensionValueType::Unsupported,
"IP Resources v2",
),
(
35,
oid!(1.3.6 .1 .5 .5 .7 .1 .29),
ExtensionValueType::Unsupported,
"AS Resources v2",
),
(
36,
oid!(1.3.6 .1 .5 .5 .7 .1 .2),
ExtensionValueType::Unsupported,
"Biometric Information",
),
(
37,
oid!(1.3.6 .1 .4 .1 .11129 .2 .4 .4),
ExtensionValueType::Unsupported,
"Precertificate Signing Certificate",
),
(
38,
oid!(1.3.6 .1 .5 .5 .7 .48 .1 .5),
ExtensionValueType::Unsupported,
"OCSP No Check",
),
// Int | OID | Type | Name
( 1, oid!(2.5.29 .14), Evt::Bytes, "Subject Key Identifier"),
( 2, oid!(2.5.29 .15), Evt::Int, "Key Usage"),
( 3, oid!(2.5.29 .17), Evt::AlternativeName, "Subject Alternative Name"),
( 4, oid!(2.5.29 .19), Evt::Int, "Basic Constraints"),
( 5, oid!(2.5.29 .31), Evt::Unsupported, "CRL Distribution Points"),
( 6, oid!(2.5.29 .32), Evt::Unsupported, "Certificate Policies"),
( 7, oid!(2.5.29 .35), Evt::Unsupported, "Authority Key Identifier"),
( 8, oid!(2.5.29 .37), Evt::Unsupported, "Extended Key Usage"),
( 9, oid!(1.3.6 .1 .5 .5 .7 .1 .1), Evt::Unsupported, "Authority Information Access"),
(10, oid!(1.3.6 .1 .4 .1 .11129 .2 .4 .2), Evt::Unsupported, "Signed Certificate Timestamp List"),
(24, oid!(2.5.29 .9), Evt::Unsupported, "Subject Directory Attributes"),
(25, oid!(2.5.29 .18), Evt::AlternativeName, "Issuer Alternative Name"),
(26, oid!(2.5.29 .30), Evt::Unsupported, "Name Constraints"),
(27, oid!(2.5.29 .33), Evt::Unsupported, "Policy Mappings"),
(28, oid!(2.5.29 .36), Evt::Unsupported, "Policy Constraints"),
(29, oid!(2.5.29 .46), Evt::Unsupported, "Freshest CRL"),
(30, oid!(2.5.29 .54), Evt::Int, "Inhibit anyPolicy"),
(31, oid!(1.3.6 .1 .5 .5 .7 .1 .11), Evt::Unsupported, "Subject Information Access"),
(32, oid!(1.3.6 .1 .5 .5 .7 .1 .7), Evt::Unsupported, "IP Resources"),
(33, oid!(1.3.6 .1 .5 .5 .7 .1 .7), Evt::Unsupported, "AS Resource"),
(34, oid!(1.3.6 .1 .5 .5 .7 .1 .28), Evt::Unsupported, "IP Resources v2"),
(35, oid!(1.3.6 .1 .5 .5 .7 .1 .29), Evt::Unsupported, "AS Resources v2"),
(36, oid!(1.3.6 .1 .5 .5 .7 .1 .2), Evt::Unsupported, "Biometric Information"),
(37, oid!(1.3.6 .1 .4 .1 .11129 .2 .4 .4), Evt::Unsupported, "Precertificate Signing Certificate"),
(38, oid!(1.3.6 .1 .5 .5 .7 .48 .1 .5), Evt::Unsupported, "OCSP No Check"),
];

/// A struct of data that contains lookup tables for `Extension`.
Expand All @@ -185,7 +70,7 @@ impl ExtensionData {
}

/// Define static lookup for extensions table
pub(crate) static EXTENSIONS_TABLES: Lazy<ExtensionData> = Lazy::new(|| {
pub(super) static EXTENSIONS_TABLES: Lazy<ExtensionData> = Lazy::new(|| {
let mut int_to_oid_table = IntegerToOidTable::new();
let mut int_to_type_table = HashMap::<i16, ExtensionValueType>::new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,25 @@ use crate::tables::{IntTable, TableTrait};
/// Int | Name | Type
type GeneralNameDataTuple = (i16, GeneralNameTypeRegistry, GeneralNameValueType);

/// Create a type alias for `GeneralNameTypeRegistry`
type Gntr = GeneralNameTypeRegistry;
/// Create a type alias for `GeneralNameValueType`
type Gnvt = GeneralNameValueType;

/// `GeneralName` data table.
#[rustfmt::skip]
const GENERAL_NAME_DATA: [GeneralNameDataTuple; 10] = [
(
-3,
GeneralNameTypeRegistry::OtherNameBundleEID,
GeneralNameValueType::Unsupported,
),
(
-2,
GeneralNameTypeRegistry::OtherNameSmtpUTF8Mailbox,
GeneralNameValueType::Text,
),
(
-1,
GeneralNameTypeRegistry::OtherNameHardwareModuleName,
GeneralNameValueType::OtherNameHWModuleName,
),
(
0,
GeneralNameTypeRegistry::OtherName,
GeneralNameValueType::OtherNameHWModuleName,
),
(
1,
GeneralNameTypeRegistry::Rfc822Name,
GeneralNameValueType::Text,
),
(
2,
GeneralNameTypeRegistry::DNSName,
GeneralNameValueType::Text,
),
(
4,
GeneralNameTypeRegistry::DirectoryName,
GeneralNameValueType::Unsupported,
),
(
6,
GeneralNameTypeRegistry::UniformResourceIdentifier,
GeneralNameValueType::Text,
),
(
7,
GeneralNameTypeRegistry::IPAddress,
GeneralNameValueType::Bytes,
),
(
8,
GeneralNameTypeRegistry::RegisteredID,
GeneralNameValueType::Oid,
),
// Int | Name | Type
(-3, Gntr::OtherNameBundleEID, Gnvt::Unsupported),
(-2, Gntr::OtherNameSmtpUTF8Mailbox, Gnvt::Text),
(-1, Gntr::OtherNameHardwareModuleName, Gnvt::OtherNameHWModuleName),
(0, Gntr::OtherName, Gnvt::OtherNameHWModuleName),
(1, Gntr::Rfc822Name, Gnvt::Text),
(2, Gntr::DNSName, Gnvt::Text),
(4, Gntr::DirectoryName, Gnvt::Unsupported),
(6, Gntr::UniformResourceIdentifier, Gnvt::Text),
(7, Gntr::IPAddress, Gnvt::Bytes),
(8, Gntr::RegisteredID, Gnvt::Oid),
];

/// A struct of data that contains lookup table for `GeneralName`.
Expand Down Expand Up @@ -111,7 +78,7 @@ impl IntegerToGNTable {
}

/// Define static lookup for general names table
pub(crate) static GENERAL_NAME_TABLES: Lazy<GeneralNameData> = Lazy::new(|| {
pub(super) static GENERAL_NAME_TABLES: Lazy<GeneralNameData> = Lazy::new(|| {
let mut int_to_name_table = IntegerToGNTable::new();
let mut int_to_type_table = HashMap::new();

Expand Down

0 comments on commit db23d96

Please sign in to comment.