diff --git a/rust/c509-certificate/.config/nextest.toml b/rust/c509-certificate/.config/nextest.toml index 726524896f..be3673830b 100644 --- a/rust/c509-certificate/.config/nextest.toml +++ b/rust/c509-certificate/.config/nextest.toml @@ -1,3 +1,4 @@ +# cspell: words scrollability testcase [store] # The directory under the workspace root at which nextest-related files are # written. Profile-specific storage is currently written to dir/. diff --git a/rust/c509-certificate/.idea/.gitignore b/rust/c509-certificate/.idea/.gitignore deleted file mode 100644 index b58b603fea..0000000000 --- a/rust/c509-certificate/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/rust/c509-certificate/.idea/c509-certificate.iml b/rust/c509-certificate/.idea/c509-certificate.iml deleted file mode 100644 index 7c12fe5a93..0000000000 --- a/rust/c509-certificate/.idea/c509-certificate.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/rust/c509-certificate/.idea/modules.xml b/rust/c509-certificate/.idea/modules.xml deleted file mode 100644 index 204ddafd82..0000000000 --- a/rust/c509-certificate/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/rust/c509-certificate/.idea/vcs.xml b/rust/c509-certificate/.idea/vcs.xml deleted file mode 100644 index b2bdec2d71..0000000000 --- a/rust/c509-certificate/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/rust/c509-certificate/deny.toml b/rust/c509-certificate/deny.toml index 8047bb3dc0..d290f243fd 100644 --- a/rust/c509-certificate/deny.toml +++ b/rust/c509-certificate/deny.toml @@ -1,4 +1,7 @@ +# cspell: words msvc, wasip, RUSTSEC, rustls, libssh, reqwest, tinyvec, Leay, webpki + [graph] +# cargo-deny is really only ever intended to run on the "normal" tier-1 targets targets = [ "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", @@ -22,11 +25,20 @@ ignore = [ multiple-versions = "warn" wildcards = 'deny' deny = [ + # { crate = "git2", use-instead = "gix" }, { crate = "openssl", use-instead = "rustls" }, { crate = "openssl-sys", use-instead = "rustls" }, "libssh2-sys", + # { crate = "cmake", use-instead = "cc" }, + # { crate = "windows", reason = "bloated and unnecessary", use-instead = "ideally inline bindings, practically, windows-sys" }, +] +skip = [ + # { crate = "bitflags@1.3.2", reason = "https://github.com/seanmonstar/reqwest/pull/2130 should be in the next version" }, + # { crate = "winnow@0.5.40", reason = "gix 0.59 was yanked, see https://github.com/Byron/gitoxide/issues/1309" }, + # { crate = "heck@0.4.1", reason = "strum_macros uses this old version" }, + # { crate = "base64@0.21.7", reason = "gix-transport pulls in this old version, as well as a newer version via reqwest" }, + # { crate = "byte-array-literalsase64@0.21.7", reason = "gix-transport pulls in this old version, as well as a newer version via reqwest" }, ] -skip = [] skip-tree = [ { crate = "windows-sys@0.48.0", reason = "a foundational crate for many that bumps far too frequently to ever have a shared version" }, ] @@ -45,7 +57,9 @@ allow-git = [ [licenses] version = 2 -unused-allowed-license = "allow" +# Don't warn if a listed license isn't found +unused-allowed-license="allow" +# We want really high confidence when inferring licenses from text confidence-threshold = 0.93 allow = [ "MIT", @@ -60,7 +74,11 @@ allow = [ "Unicode-3.0", "MPL-2.0", ] -exceptions = [] +exceptions = [ + #{ allow = ["Zlib"], crate = "tinyvec" }, + #{ allow = ["Unicode-DFS-2016"], crate = "unicode-ident" }, + #{ allow = ["OpenSSL"], crate = "ring" }, +] [[licenses.clarify]] crate = "byte-array-literals" @@ -76,3 +94,24 @@ license-files = [{ path = "../LICENSE-MIT", hash = 0x001c7e6c }] crate = "ring" expression = "MIT" license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] + +# SPDX considers OpenSSL to encompass both the OpenSSL and SSLeay licenses +# https://spdx.org/licenses/OpenSSL.html +# ISC - Both BoringSSL and ring use this for their new files +# MIT - "Files in third_party/ have their own licenses, as described therein. The MIT +# license, for third_party/fiat, which, unlike other third_party directories, is +# compiled into non-test libraries, is included below." +# OpenSSL - Obviously +#expression = "ISC AND MIT AND OpenSSL" +#license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] + +#[[licenses.clarify]] +#crate = "webpki" +#expression = "ISC" +#license-files = [{ path = "LICENSE", hash = 0x001c7e6c }] + +# Actually "ISC-style" +#[[licenses.clarify]] +#crate = "rustls-webpki" +#expression = "ISC" +#license-files = [{ path = "LICENSE", hash = 0x001c7e6c }] \ No newline at end of file diff --git a/rust/c509-certificate/examples/cli/main.rs b/rust/c509-certificate/examples/cli/main.rs index f344200f00..816446f487 100644 --- a/rust/c509-certificate/examples/cli/main.rs +++ b/rust/c509-certificate/examples/cli/main.rs @@ -8,14 +8,14 @@ use std::{ use asn1_rs::{oid, Oid}; use c509_certificate::{ - c509_big_uint::UnwrappedBigUint, - c509_extensions::Extensions, - c509_issuer_sig_algo::IssuerSignatureAlgorithm, - c509_name::{rdn::RelativeDistinguishedName, Name, NameValue}, - c509_subject_pub_key_algo::SubjectPubKeyAlgorithm, - c509_time::Time, + big_uint::UnwrappedBigUint, + extensions::Extensions, + issuer_sig_algo::IssuerSignatureAlgorithm, + name::{rdn::RelativeDistinguishedName, Name, NameValue}, signing::{PrivateKey, PublicKey}, + subject_pub_key_algo::SubjectPubKeyAlgorithm, tbs_cert::TbsCert, + time::Time, }; use chrono::{DateTime, Utc}; use clap::Parser; diff --git a/rust/c509-certificate/src/c509_algo_identifier.rs b/rust/c509-certificate/src/algorithm_identifier.rs similarity index 98% rename from rust/c509-certificate/src/c509_algo_identifier.rs rename to rust/c509-certificate/src/algorithm_identifier.rs index b11153c8a9..89bca4b118 100644 --- a/rust/c509-certificate/src/c509_algo_identifier.rs +++ b/rust/c509-certificate/src/algorithm_identifier.rs @@ -17,7 +17,7 @@ use asn1_rs::Oid; use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Serialize}; -use crate::c509_oid::C509oid; +use crate::oid::C509oid; /// A struct represents the `AlgorithmIdentifier` type. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] diff --git a/rust/c509-certificate/src/c509_attributes/attribute.rs b/rust/c509-certificate/src/attributes/attribute.rs similarity index 99% rename from rust/c509-certificate/src/c509_attributes/attribute.rs rename to rust/c509-certificate/src/attributes/attribute.rs index 507a5decb0..1aa99740a9 100644 --- a/rust/c509-certificate/src/c509_attributes/attribute.rs +++ b/rust/c509-certificate/src/attributes/attribute.rs @@ -16,7 +16,7 @@ use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Deserializer, Serialize}; use super::data::{get_oid_from_int, ATTRIBUTES_LOOKUP}; -use crate::c509_oid::{C509oid, C509oidRegistered}; +use crate::oid::{C509oid, C509oidRegistered}; /// A struct of C509 `Attribute` #[derive(Debug, Clone, PartialEq)] diff --git a/rust/c509-certificate/src/c509_attributes/data.rs b/rust/c509-certificate/src/attributes/data.rs similarity index 100% rename from rust/c509-certificate/src/c509_attributes/data.rs rename to rust/c509-certificate/src/attributes/data.rs diff --git a/rust/c509-certificate/src/c509_attributes/mod.rs b/rust/c509-certificate/src/attributes/mod.rs similarity index 98% rename from rust/c509-certificate/src/c509_attributes/mod.rs rename to rust/c509-certificate/src/attributes/mod.rs index b188558e18..30fa1684ae 100644 --- a/rust/c509-certificate/src/c509_attributes/mod.rs +++ b/rust/c509-certificate/src/attributes/mod.rs @@ -10,7 +10,7 @@ //! SubjectDirectoryAttributes = [+Attributes] //! ``` //! -//! For more information about `Attributes`, +//! For more information about `Atributes`, //! visit [C509 Certificate](https://datatracker.ietf.org/doc/draft-ietf-cose-cbor-encoded-cert/09/) use attribute::Attribute; diff --git a/rust/c509-certificate/src/c509_big_uint.rs b/rust/c509-certificate/src/big_uint.rs similarity index 98% rename from rust/c509-certificate/src/c509_big_uint.rs rename to rust/c509-certificate/src/big_uint.rs index 8d844e2e8a..a28e93305d 100644 --- a/rust/c509-certificate/src/c509_big_uint.rs +++ b/rust/c509-certificate/src/big_uint.rs @@ -9,6 +9,7 @@ use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Serialize}; /// A struct representing an unwrapped CBOR unsigned bignum. +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct UnwrappedBigUint(u64); diff --git a/rust/c509-certificate/src/c509.rs b/rust/c509-certificate/src/c509.rs index cde35592bf..75cc23bfa9 100644 --- a/rust/c509-certificate/src/c509.rs +++ b/rust/c509-certificate/src/c509.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use crate::tbs_cert::TbsCert; -#[derive(Deserialize, Serialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] /// A struct represents the `C509` Certificate. pub struct C509 { /// A TBS Certificate. diff --git a/rust/c509-certificate/src/c509_extensions/alt_name.rs b/rust/c509-certificate/src/extensions/alt_name.rs similarity index 94% rename from rust/c509-certificate/src/c509_extensions/alt_name.rs rename to rust/c509-certificate/src/extensions/alt_name.rs index 7ab83513bc..f5448ff032 100644 --- a/rust/c509-certificate/src/c509_extensions/alt_name.rs +++ b/rust/c509-certificate/src/extensions/alt_name.rs @@ -4,7 +4,7 @@ use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Serialize}; -use crate::c509_general_names::{ +use crate::general_names::{ general_name::{GeneralName, GeneralNameTypeRegistry, GeneralNameValue}, GeneralNames, }; @@ -20,6 +20,12 @@ impl AlternativeName { pub fn new(value: GeneralNamesOrText) -> Self { Self(value) } + + /// Get the inner of Alternative Name. + #[must_use] + pub fn get_inner(&self) -> &GeneralNamesOrText { + &self.0 + } } impl Encode<()> for AlternativeName { @@ -55,11 +61,11 @@ impl Encode<()> for GeneralNamesOrText { match self { GeneralNamesOrText::GeneralNames(gns) => { let gn = gns - .get_gns() + .get_inner() .first() .ok_or(minicbor::encode::Error::message("GeneralNames is empty"))?; // Check whether there is only 1 item in the array which is a DNSName - if gns.get_gns().len() == 1 && gn.get_gn_type().is_dns_name() { + if gns.get_inner().len() == 1 && gn.get_gn_type().is_dns_name() { gn.get_gn_value().encode(e, ctx)?; } else { gns.encode(e, ctx)?; @@ -105,7 +111,7 @@ impl Decode<'_, ()> for GeneralNamesOrText { #[cfg(test)] mod test_alt_name { use super::*; - use crate::c509_general_names::general_name::{ + use crate::general_names::general_name::{ GeneralName, GeneralNameTypeRegistry, GeneralNameValue, }; diff --git a/rust/c509-certificate/src/c509_extensions/extension/data.rs b/rust/c509-certificate/src/extensions/extension/data.rs similarity index 100% rename from rust/c509-certificate/src/c509_extensions/extension/data.rs rename to rust/c509-certificate/src/extensions/extension/data.rs diff --git a/rust/c509-certificate/src/c509_extensions/extension/mod.rs b/rust/c509-certificate/src/extensions/extension/mod.rs similarity index 99% rename from rust/c509-certificate/src/c509_extensions/extension/mod.rs rename to rust/c509-certificate/src/extensions/extension/mod.rs index 264b98d1a7..b2b82e5492 100644 --- a/rust/c509-certificate/src/c509_extensions/extension/mod.rs +++ b/rust/c509-certificate/src/extensions/extension/mod.rs @@ -10,7 +10,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use strum_macros::EnumDiscriminants; use super::alt_name::AlternativeName; -use crate::c509_oid::{C509oid, C509oidRegistered}; +use crate::oid::{C509oid, C509oidRegistered}; /// A struct of C509 `Extension` #[derive(Debug, Clone, PartialEq)] diff --git a/rust/c509-certificate/src/c509_extensions/mod.rs b/rust/c509-certificate/src/extensions/mod.rs similarity index 98% rename from rust/c509-certificate/src/c509_extensions/mod.rs rename to rust/c509-certificate/src/extensions/mod.rs index 71d71d422e..1288f9e642 100644 --- a/rust/c509-certificate/src/c509_extensions/mod.rs +++ b/rust/c509-certificate/src/extensions/mod.rs @@ -51,6 +51,12 @@ impl Extensions { pub fn add_ext(&mut self, extension: Extension) { self.0.push(extension); } + + /// Get the inner vector of `Extensions`. + #[must_use] + pub fn get_inner(&self) -> &Vec { + &self.0 + } } impl Encode<()> for Extensions { diff --git a/rust/c509-certificate/src/c509_general_names/data.rs b/rust/c509-certificate/src/general_names/data.rs similarity index 100% rename from rust/c509-certificate/src/c509_general_names/data.rs rename to rust/c509-certificate/src/general_names/data.rs diff --git a/rust/c509-certificate/src/c509_general_names/general_name.rs b/rust/c509-certificate/src/general_names/general_name.rs similarity index 96% rename from rust/c509-certificate/src/c509_general_names/general_name.rs rename to rust/c509-certificate/src/general_names/general_name.rs index 9d7b06ecb2..42d0526c75 100644 --- a/rust/c509-certificate/src/c509_general_names/general_name.rs +++ b/rust/c509-certificate/src/general_names/general_name.rs @@ -13,7 +13,7 @@ use super::{ data::{get_gn_from_int, get_gn_value_type_from_int, get_int_from_gn}, other_name_hw_module::OtherNameHardwareModuleName, }; -use crate::{c509_name::Name, c509_oid::C509oid}; +use crate::{name::Name, oid::C509oid}; /// A struct represents a `GeneralName`. /// ```cddl @@ -173,7 +173,8 @@ impl Encode<()> for GeneralNameValue { } } impl Decode<'_, C> for GeneralNameValue -where C: GeneralNameValueTrait + Debug +where + C: GeneralNameValueTrait + Debug, { fn decode(d: &mut Decoder<'_>, ctx: &mut C) -> Result { match ctx.get_type() { @@ -197,11 +198,9 @@ where C: GeneralNameValueTrait + Debug let value = Name::decode(d, &mut ())?; Ok(GeneralNameValue::Name(value)) }, - GeneralNameValueType::Unsupported => { - Err(minicbor::decode::Error::message( - "Cannot decode Unsupported GeneralName value", - )) - }, + GeneralNameValueType::Unsupported => Err(minicbor::decode::Error::message( + "Cannot decode Unsupported GeneralName value", + )), } } } @@ -242,9 +241,10 @@ mod test_general_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let hw = OtherNameHardwareModuleName::new(oid!(2.16.840 .1 .101 .3 .4 .2 .1), vec![ - 0x01, 0x02, 0x03, 0x04, - ]); + let hw = OtherNameHardwareModuleName::new( + oid!(2.16.840 .1 .101 .3 .4 .2 .1), + vec![0x01, 0x02, 0x03, 0x04], + ); let gn = GeneralName::new( GeneralNameTypeRegistry::OtherNameHardwareModuleName, GeneralNameValue::OtherNameHWModuleName(hw), diff --git a/rust/c509-certificate/src/c509_general_names/mod.rs b/rust/c509-certificate/src/general_names/mod.rs similarity index 97% rename from rust/c509-certificate/src/c509_general_names/mod.rs rename to rust/c509-certificate/src/general_names/mod.rs index f5778fb014..1998733be3 100644 --- a/rust/c509-certificate/src/c509_general_names/mod.rs +++ b/rust/c509-certificate/src/general_names/mod.rs @@ -36,8 +36,9 @@ impl GeneralNames { self.0.push(gn); } - /// Get the a vector of `GeneralName`. - pub(crate) fn get_gns(&self) -> &Vec { + /// Get the inner of `GeneralName`. + #[must_use] + pub fn get_inner(&self) -> &Vec { &self.0 } } @@ -85,7 +86,7 @@ mod test_general_names { use other_name_hw_module::OtherNameHardwareModuleName; use super::*; - use crate::c509_oid::C509oid; + use crate::oid::C509oid; #[test] fn encode_decode_gns() { diff --git a/rust/c509-certificate/src/c509_general_names/other_name_hw_module.rs b/rust/c509-certificate/src/general_names/other_name_hw_module.rs similarity index 98% rename from rust/c509-certificate/src/c509_general_names/other_name_hw_module.rs rename to rust/c509-certificate/src/general_names/other_name_hw_module.rs index 745b3cca0d..b57697ce79 100644 --- a/rust/c509-certificate/src/c509_general_names/other_name_hw_module.rs +++ b/rust/c509-certificate/src/general_names/other_name_hw_module.rs @@ -7,7 +7,7 @@ use asn1_rs::Oid; use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Serialize}; -use crate::c509_oid::C509oid; +use crate::oid::C509oid; /// A struct represents the hardwareModuleName type of otherName. /// Containing a pair of ( hwType, hwSerialNum ) as mentioned in diff --git a/rust/c509-certificate/src/c509_issuer_sig_algo/data.rs b/rust/c509-certificate/src/issuer_sig_algo/data.rs similarity index 100% rename from rust/c509-certificate/src/c509_issuer_sig_algo/data.rs rename to rust/c509-certificate/src/issuer_sig_algo/data.rs diff --git a/rust/c509-certificate/src/c509_issuer_sig_algo/mod.rs b/rust/c509-certificate/src/issuer_sig_algo/mod.rs similarity index 98% rename from rust/c509-certificate/src/c509_issuer_sig_algo/mod.rs rename to rust/c509-certificate/src/issuer_sig_algo/mod.rs index 33e67941c4..ff63acae59 100644 --- a/rust/c509-certificate/src/c509_issuer_sig_algo/mod.rs +++ b/rust/c509-certificate/src/issuer_sig_algo/mod.rs @@ -14,7 +14,7 @@ use data::{get_oid_from_int, ISSUER_SIG_ALGO_LOOKUP}; use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Deserializer, Serialize}; -use crate::{c509_algo_identifier::AlgorithmIdentifier, c509_oid::C509oidRegistered}; +use crate::{algorithm_identifier::AlgorithmIdentifier, oid::C509oidRegistered}; /// A struct represents the `IssuerSignatureAlgorithm` #[derive(Debug, Clone, PartialEq)] diff --git a/rust/c509-certificate/src/lib.rs b/rust/c509-certificate/src/lib.rs index 56fea7c16a..ae223655b9 100644 --- a/rust/c509-certificate/src/lib.rs +++ b/rust/c509-certificate/src/lib.rs @@ -40,20 +40,20 @@ use c509::C509; use minicbor::{Decode, Encode}; use signing::{PrivateKey, PublicKey}; use tbs_cert::TbsCert; +pub mod algorithm_identifier; +pub mod attributes; +pub mod big_uint; pub mod c509; -pub mod c509_algo_identifier; -pub mod c509_attributes; -pub mod c509_big_uint; -pub mod c509_extensions; -pub mod c509_general_names; -pub mod c509_issuer_sig_algo; -pub mod c509_name; -pub mod c509_oid; -pub mod c509_subject_pub_key_algo; -pub mod c509_time; +pub mod extensions; +pub mod general_names; +pub mod issuer_sig_algo; +pub mod name; +pub mod oid; pub mod signing; +pub mod subject_pub_key_algo; mod tables; pub mod tbs_cert; +pub mod time; pub mod wasm_binding; /// Generate a signed or unsigned C509 certificate. diff --git a/rust/c509-certificate/src/c509_name/mod.rs b/rust/c509-certificate/src/name/mod.rs similarity index 99% rename from rust/c509-certificate/src/c509_name/mod.rs rename to rust/c509-certificate/src/name/mod.rs index 5e0028dfdf..c414439077 100644 --- a/rust/c509-certificate/src/c509_name/mod.rs +++ b/rust/c509-certificate/src/name/mod.rs @@ -23,7 +23,7 @@ use rdn::RelativeDistinguishedName; use regex::Regex; use serde::{Deserialize, Serialize}; -use crate::c509_attributes::attribute::{Attribute, AttributeValue}; +use crate::attributes::attribute::{Attribute, AttributeValue}; /// OID of `CommonName` attribute. const COMMON_NAME_OID: Oid<'static> = oid!(2.5.4 .3); @@ -73,6 +73,7 @@ impl Decode<'_, ()> for Name { // ------------------NameValue---------------------- /// An enum of possible value types for `Name`. +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] pub enum NameValue { @@ -283,7 +284,7 @@ fn create_rdn_with_cn_attr(text: String) -> NameValue { #[cfg(test)] pub(crate) mod test_name { use super::*; - use crate::c509_attributes::attribute::Attribute; + use crate::attributes::attribute::Attribute; // Test data from https://datatracker.ietf.org/doc/draft-ietf-cose-cbor-encoded-cert/09/ // A.1.1. Example C509 Certificate Encoding diff --git a/rust/c509-certificate/src/c509_name/rdn.rs b/rust/c509-certificate/src/name/rdn.rs similarity index 98% rename from rust/c509-certificate/src/c509_name/rdn.rs rename to rust/c509-certificate/src/name/rdn.rs index ef71481fa2..13f5eb12f0 100644 --- a/rust/c509-certificate/src/c509_name/rdn.rs +++ b/rust/c509-certificate/src/name/rdn.rs @@ -8,7 +8,7 @@ use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Serialize}; -use crate::c509_attributes::attribute::Attribute; +use crate::attributes::attribute::Attribute; /// A struct represents a Relative Distinguished Name containing vector of `Attribute`. /// @@ -104,7 +104,7 @@ mod test_relative_distinguished_name { use asn1_rs::oid; use super::*; - use crate::c509_attributes::attribute::AttributeValue; + use crate::attributes::attribute::AttributeValue; #[test] fn encode_decode_rdn() { diff --git a/rust/c509-certificate/src/c509_oid.rs b/rust/c509-certificate/src/oid.rs similarity index 98% rename from rust/c509-certificate/src/c509_oid.rs rename to rust/c509-certificate/src/oid.rs index 646263a14a..46f2e2d864 100644 --- a/rust/c509-certificate/src/c509_oid.rs +++ b/rust/c509-certificate/src/oid.rs @@ -46,7 +46,8 @@ impl C509oidRegistered { } /// Get the `C509oid`. - pub(crate) fn get_c509_oid(&self) -> C509oid { + #[must_use] + pub fn get_c509_oid(&self) -> C509oid { self.oid.clone() } @@ -76,7 +77,9 @@ struct Helper { impl<'de> Deserialize<'de> for C509oid { fn deserialize(deserializer: D) -> Result - where D: Deserializer<'de> { + where + D: Deserializer<'de>, + { let helper = Helper::deserialize(deserializer)?; let oid = Oid::from_str(&helper.oid).map_err(|e| serde::de::Error::custom(format!("{e:?}")))?; @@ -86,7 +89,9 @@ impl<'de> Deserialize<'de> for C509oid { impl Serialize for C509oid { fn serialize(&self, serializer: S) -> Result - where S: serde::Serializer { + where + S: serde::Serializer, + { let helper = Helper { oid: self.oid.to_string(), }; diff --git a/rust/c509-certificate/src/c509_subject_pub_key_algo/data.rs b/rust/c509-certificate/src/subject_pub_key_algo/data.rs similarity index 100% rename from rust/c509-certificate/src/c509_subject_pub_key_algo/data.rs rename to rust/c509-certificate/src/subject_pub_key_algo/data.rs diff --git a/rust/c509-certificate/src/c509_subject_pub_key_algo/mod.rs b/rust/c509-certificate/src/subject_pub_key_algo/mod.rs similarity index 98% rename from rust/c509-certificate/src/c509_subject_pub_key_algo/mod.rs rename to rust/c509-certificate/src/subject_pub_key_algo/mod.rs index 3c56175fbd..014ad6e6cc 100644 --- a/rust/c509-certificate/src/c509_subject_pub_key_algo/mod.rs +++ b/rust/c509-certificate/src/subject_pub_key_algo/mod.rs @@ -16,7 +16,7 @@ use data::{get_oid_from_int, SUBJECT_PUB_KEY_ALGO_LOOKUP}; use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Deserializer, Serialize}; -use crate::{c509_algo_identifier::AlgorithmIdentifier, c509_oid::C509oidRegistered}; +use crate::{algorithm_identifier::AlgorithmIdentifier, oid::C509oidRegistered}; /// A struct represents the `SubjectPubKeyAlgorithm` #[derive(Debug, Clone, PartialEq)] diff --git a/rust/c509-certificate/src/tbs_cert.rs b/rust/c509-certificate/src/tbs_cert.rs index 0154a5d40e..c9f4b55585 100644 --- a/rust/c509-certificate/src/tbs_cert.rs +++ b/rust/c509-certificate/src/tbs_cert.rs @@ -4,9 +4,8 @@ use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; use serde::{Deserialize, Serialize}; use crate::{ - c509_big_uint::UnwrappedBigUint, c509_extensions::Extensions, - c509_issuer_sig_algo::IssuerSignatureAlgorithm, c509_name::Name, - c509_subject_pub_key_algo::SubjectPubKeyAlgorithm, c509_time::Time, + big_uint::UnwrappedBigUint, extensions::Extensions, issuer_sig_algo::IssuerSignatureAlgorithm, + name::Name, subject_pub_key_algo::SubjectPubKeyAlgorithm, time::Time, }; /// A struct represents a To Be Signed Certificate (TBS Certificate). @@ -182,17 +181,17 @@ pub(crate) mod test_tbs_cert { use super::*; use crate::{ - c509_attributes::attribute::{Attribute, AttributeValue}, - c509_extensions::{ + attributes::attribute::{Attribute, AttributeValue}, + extensions::{ alt_name::{AlternativeName, GeneralNamesOrText}, extension::{Extension, ExtensionValue}, }, - c509_general_names::{ + general_names::{ general_name::{GeneralName, GeneralNameTypeRegistry, GeneralNameValue}, other_name_hw_module::OtherNameHardwareModuleName, GeneralNames, }, - c509_name::{ + name::{ rdn::RelativeDistinguishedName, test_name::{name_cn_eui_mac, name_cn_text, names}, NameValue, diff --git a/rust/c509-certificate/src/c509_time.rs b/rust/c509-certificate/src/time.rs similarity index 100% rename from rust/c509-certificate/src/c509_time.rs rename to rust/c509-certificate/src/time.rs