From f39f005d6f12050c801b8d837514070b7329a7b3 Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Tue, 26 Nov 2024 17:19:39 +0700 Subject: [PATCH 1/5] Use OpenSSL for ed25519 keys --- components/brave_wallet/browser/BUILD.gn | 2 - .../brave_wallet/browser/internal/BUILD.gn | 3 +- .../brave_wallet/browser/internal/hd_key.cc | 68 +----- .../browser/internal/hd_key_ed25519.cc | 165 +++++++------- .../browser/internal/hd_key_ed25519.h | 46 ++-- .../internal/hd_key_ed25519_unittest.cc | 203 ++++++++---------- .../browser/internal/hd_key_utils.cc | 50 +++++ .../browser/internal/hd_key_utils.h | 25 +++ .../browser/internal/hd_key_utils_unittest.cc | 50 +++++ .../brave_wallet/browser/solana_keyring.cc | 26 ++- .../brave_wallet/browser/solana_keyring.h | 2 +- .../browser/solana_keyring_unittest.cc | 3 +- components/brave_wallet/browser/test/BUILD.gn | 1 + components/brave_wallet/common/BUILD.gn | 1 - components/brave_wallet/common/hash_utils.cc | 11 + components/brave_wallet/common/hash_utils.h | 5 + .../common/hash_utils_unittest.cc | 26 +++ 17 files changed, 395 insertions(+), 292 deletions(-) create mode 100644 components/brave_wallet/browser/internal/hd_key_utils.cc create mode 100644 components/brave_wallet/browser/internal/hd_key_utils.h create mode 100644 components/brave_wallet/browser/internal/hd_key_utils_unittest.cc diff --git a/components/brave_wallet/browser/BUILD.gn b/components/brave_wallet/browser/BUILD.gn index c322e93d8661..d35b9f5379dd 100644 --- a/components/brave_wallet/browser/BUILD.gn +++ b/components/brave_wallet/browser/BUILD.gn @@ -435,8 +435,6 @@ source_set("hd_keyring") { "//brave/components/filecoin/rs:rust_lib", "//crypto", ] - - public_deps = [ "//brave/components/brave_wallet/rust:rust_lib" ] } source_set("transaction") { diff --git a/components/brave_wallet/browser/internal/BUILD.gn b/components/brave_wallet/browser/internal/BUILD.gn index c957e9fbd3b8..f242783cad6a 100644 --- a/components/brave_wallet/browser/internal/BUILD.gn +++ b/components/brave_wallet/browser/internal/BUILD.gn @@ -11,6 +11,8 @@ source_set("hd_key") { "hd_key.h", "hd_key_ed25519.cc", "hd_key_ed25519.h", + "hd_key_utils.cc", + "hd_key_utils.h", ] visibility = [ @@ -28,7 +30,6 @@ source_set("hd_key") { "//third_party/boringssl", ] - public_deps = [ "//brave/components/brave_wallet/rust:rust_lib" ] if (enable_orchard) { sources += [ "hd_key_zip32.cc", diff --git a/components/brave_wallet/browser/internal/hd_key.cc b/components/brave_wallet/browser/internal/hd_key.cc index 9ff922674ba4..aea339ad3142 100644 --- a/components/brave_wallet/browser/internal/hd_key.cc +++ b/components/brave_wallet/browser/internal/hd_key.cc @@ -24,6 +24,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" +#include "brave/components/brave_wallet/browser/internal/hd_key_utils.h" #include "brave/components/brave_wallet/common/bitcoin_utils.h" #include "brave/components/brave_wallet/common/hash_utils.h" #include "brave/components/brave_wallet/common/hex_utils.h" @@ -35,7 +36,6 @@ #include "crypto/process_bound_string.h" #include "crypto/random.h" #include "crypto/symmetric_key.h" -#include "third_party/boringssl/src/include/openssl/hmac.h" #define SECP256K1_BUILD // This effectively turns off export attributes. #include "brave/third_party/bitcoin-core/src/src/secp256k1/include/secp256k1.h" @@ -47,10 +47,7 @@ using crypto::SymmetricKey; namespace brave_wallet { namespace { -constexpr char kMasterNode[] = "m"; constexpr char kMasterSecret[] = "Bitcoin seed"; -constexpr size_t kSHA512Length = 64; -constexpr uint32_t kHardenedOffset = 0x80000000; constexpr size_t kSerializationLength = 78; constexpr size_t kMaxDerSignatureSize = 72; constexpr size_t kContextRandomizeSize = 32; @@ -136,19 +133,10 @@ std::unique_ptr HDKey::GenerateFromSeed(base::span seed) { return nullptr; } - SecureVector hmac(kSHA512Length); - unsigned int out_len; - if (!HMAC(EVP_sha512(), kMasterSecret, sizeof(kMasterSecret), seed.data(), - seed.size(), hmac.data(), &out_len)) { - LOG(ERROR) << __func__ << ": HMAC_SHA512 failed"; - return nullptr; - } - DCHECK(out_len == kSHA512Length); + auto hmac = HmacSha512(base::byte_span_from_cstring(kMasterSecret), seed); + auto [IL, IR] = base::span(hmac).split_at(kSHA512HashLength / 2); std::unique_ptr hdkey = std::make_unique(); - auto hmac_span = base::make_span(hmac); - auto IL = hmac_span.first(kSHA512Length / 2); - auto IR = hmac_span.last(kSHA512Length / 2); hdkey->SetPrivateKey(IL); hdkey->SetChainCode(IR); hdkey->path_ = kMasterNode; @@ -549,18 +537,8 @@ std::unique_ptr HDKey::DeriveChild(uint32_t index) { data.push_back((index >> 8) & 0xFF); data.push_back(index & 0xFF); - SecureVector hmac(kSHA512Length); - unsigned int out_len; - if (!HMAC(EVP_sha512(), chain_code_.data(), chain_code_.size(), data.data(), - data.size(), hmac.data(), &out_len)) { - LOG(ERROR) << __func__ << ": HMAC_SHA512 failed"; - return nullptr; - } - DCHECK(out_len == kSHA512Length); - - auto hmac_span = base::make_span(hmac); - auto IL = hmac_span.first(kSHA512Length / 2); - auto IR = hmac_span.last(kSHA512Length / 2); + auto hmac = HmacSha512(chain_code_, data); + auto [IL, IR] = base::span(hmac).split_at(kSHA512HashLength / 2); std::unique_ptr hdkey = std::make_unique(); hdkey->SetChainCode(IR); @@ -625,44 +603,18 @@ std::unique_ptr HDKey::DeriveChildFromPath(const std::string& path) { return nullptr; } - std::unique_ptr hd_key = std::make_unique(); - std::vector entries = - base::SplitString(path, "/", base::WhitespaceHandling::TRIM_WHITESPACE, - base::SplitResult::SPLIT_WANT_NONEMPTY); - if (entries.empty()) { + const auto hd_path = ParseFullHDPath(path); + if (!hd_path) { return nullptr; } - // Starting with 'm' node and effectively copying `*this` into `hd_key`. - if (entries[0] != kMasterNode) { - LOG(ERROR) << __func__ << ": path must start with \"m\""; - return nullptr; - } + std::unique_ptr hd_key = std::make_unique(); hd_key->SetPrivateKey(private_key_); hd_key->SetChainCode(chain_code_); hd_key->path_ = path_; - for (size_t i = 1; i < entries.size(); ++i) { - std::string entry = entries[i]; - - bool is_hardened = entry.length() > 1 && entry.back() == '\''; - if (is_hardened) { - entry.pop_back(); - } - unsigned child_index = 0; - if (!base::StringToUint(entry, &child_index)) { - LOG(ERROR) << __func__ << ": path must contain number or number'"; - return nullptr; - } - if (child_index >= kHardenedOffset) { - LOG(ERROR) << __func__ << ": index must be less than " << kHardenedOffset; - return nullptr; - } - if (is_hardened) { - child_index += kHardenedOffset; - } - - hd_key = hd_key->DeriveChild(child_index); + for (auto node : *hd_path) { + hd_key = hd_key->DeriveChild(node); if (!hd_key) { return nullptr; } diff --git a/components/brave_wallet/browser/internal/hd_key_ed25519.cc b/components/brave_wallet/browser/internal/hd_key_ed25519.cc index a10752f68f9f..475e161801c6 100644 --- a/components/brave_wallet/browser/internal/hd_key_ed25519.cc +++ b/components/brave_wallet/browser/internal/hd_key_ed25519.cc @@ -8,52 +8,63 @@ #include #include "base/check.h" -#include "base/logging.h" -#include "base/notreached.h" -#include "base/strings/strcat.h" +#include "base/containers/span.h" +#include "base/containers/span_writer.h" +#include "base/memory/ptr_util.h" +#include "base/numerics/byte_conversions.h" #include "base/strings/string_number_conversions.h" +#include "brave/components/brave_wallet/browser/internal/hd_key_utils.h" +#include "brave/components/brave_wallet/common/hash_utils.h" #include "brave/third_party/bitcoin-core/src/src/base58.h" +#include "third_party/boringssl/src/include/openssl/curve25519.h" namespace brave_wallet { namespace { -constexpr char kMasterNode[] = "m"; -} -HDKeyEd25519::HDKeyEd25519( - std::string path, - rust::Box private_key) - : path_(std::move(path)), private_key_(std::move(private_key)) { - CHECK(private_key_->is_ok()); +constexpr char kMasterSecret[] = "ed25519 seed"; + +// Validate keypair by signing and verifying signature to ensure included +// private key matches public key. +bool ValidateKeypair(base::span key_pair) { + std::array signature = {}; + auto msg = base::byte_span_from_cstring("brave"); + + CHECK( + ED25519_sign(signature.data(), msg.data(), msg.size(), key_pair.data())); + + return !!ED25519_verify(msg.data(), msg.size(), signature.data(), + key_pair.last().data()); } + +} // namespace + +HDKeyEd25519::HDKeyEd25519() = default; HDKeyEd25519::~HDKeyEd25519() = default; -// static -std::unique_ptr HDKeyEd25519::GenerateFromSeed( - base::span seed) { - auto master_private_key = generate_ed25519_extended_secret_key_from_seed( - rust::Slice{seed.data(), seed.size()}); - if (!master_private_key->is_ok()) { - VLOG(0) << std::string(master_private_key->error_message()); - return nullptr; - } - return std::make_unique(kMasterNode, - std::move(master_private_key)); +// Child key derivation constructor. +// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#private-parent-key--private-child-key +HDKeyEd25519::HDKeyEd25519(base::span key, + base::span data) { + auto hmac = HmacSha512(key, data); + auto [il, ir] = base::span(hmac).split_at<32>(); + + // `public_key` is not used, we use key pair instead. + std::array public_key; + ED25519_keypair_from_seed(public_key.data(), key_pair_.data(), il.data()); + + base::span(chain_code_).copy_from(ir); } // static -std::unique_ptr HDKeyEd25519::GenerateFromPrivateKey( - base::span private_key) { - auto master_private_key = generate_ed25519_extended_secret_key_from_bytes( - rust::Slice{private_key.data(), private_key.size()}); - if (!master_private_key->is_ok()) { - VLOG(0) << std::string(master_private_key->error_message()); +std::unique_ptr HDKeyEd25519::GenerateFromKeyPair( + base::span key_pair) { + if (!ValidateKeypair(key_pair)) { return nullptr; } - return std::make_unique("", std::move(master_private_key)); -} -std::string HDKeyEd25519::GetPath() const { - return path_; + auto result = std::make_unique(); + base::span(result->key_pair_).copy_from(key_pair); + return result; } // index should be 0 to 2^31-1 @@ -62,74 +73,74 @@ std::string HDKeyEd25519::GetPath() const { // https://github.com/satoshilabs/slips/blob/master/slip-0010.md#private-parent-key--private-child-key std::unique_ptr HDKeyEd25519::DeriveHardenedChild( uint32_t index) { - auto child_private_key = private_key_->unwrap().derive_hardened_child(index); - if (!child_private_key->is_ok()) { - VLOG(0) << std::string(child_private_key->error_message()); + if (index >= kHardenedOffset) { return nullptr; } - auto child_path = - base::StrCat({path_, "/", base::NumberToString(index), "'"}); - return std::make_unique(std::move(child_path), - std::move(child_private_key)); + return DeriveChild(kHardenedOffset + index); +} + +std::unique_ptr HDKeyEd25519::DeriveChild(uint32_t index) { + std::vector hmac_payload(37); + + auto span_writer = base::SpanWriter(base::span(hmac_payload)); + // https://github.com/satoshilabs/slips/blob/master/slip-0010.md#private-parent-key--private-child-key + span_writer.Write(base::U8ToBigEndian(0)); + span_writer.Write(GetPrivateKeyAsSpan()); + span_writer.Write(base::U32ToBigEndian(index)); + + return base::WrapUnique(new HDKeyEd25519(chain_code_, hmac_payload)); } -std::unique_ptr HDKeyEd25519::DeriveChildFromPath( - const std::string& path) { - if (path_ != kMasterNode) { - VLOG(0) << "must derive only from master key"; +// static +std::unique_ptr HDKeyEd25519::GenerateFromSeedAndPath( + base::span seed, + std::string_view hd_path) { + auto hd_key = base::WrapUnique( + new HDKeyEd25519(base::byte_span_from_cstring(kMasterSecret), seed)); + + auto nodes = ParseFullHDPath(hd_path); + if (!nodes) { return nullptr; } - auto child_private_key = private_key_->unwrap().derive(path); - if (!child_private_key->is_ok()) { - VLOG(0) << std::string(child_private_key->error_message()); - return nullptr; + for (auto index : *nodes) { + if (index < kHardenedOffset) { + return nullptr; + } + hd_key = hd_key->DeriveChild(index); + if (!hd_key) { + return nullptr; + } } - return std::make_unique(path, std::move(child_private_key)); + return hd_key; } -std::vector HDKeyEd25519::Sign(base::span msg) { - auto signature_result = private_key_->unwrap().sign( - rust::Slice{msg.data(), msg.size()}); - if (!signature_result->is_ok()) { - VLOG(0) << std::string(signature_result->error_message()); - return std::vector(); - } - auto signature_bytes = signature_result->unwrap().to_bytes(); - return std::vector(signature_bytes.begin(), signature_bytes.end()); -} +std::array HDKeyEd25519::Sign( + base::span msg) { + std::array signature = {}; -bool HDKeyEd25519::VerifyForTesting(base::span msg, - base::span sig) { - auto verification_result = private_key_->unwrap().verify( - rust::Slice{msg.data(), msg.size()}, - rust::Slice{sig.data(), sig.size()}); - if (!verification_result->is_ok()) { - VLOG(0) << std::string(verification_result->error_message()); - return false; - } - return true; + CHECK( + ED25519_sign(signature.data(), msg.data(), msg.size(), key_pair_.data())); + return signature; } -std::vector HDKeyEd25519::GetPrivateKeyBytes() const { - auto secret_key = private_key_->unwrap().secret_key_raw(); - return {secret_key.begin(), secret_key.end()}; +base::span +HDKeyEd25519::GetPrivateKeyAsSpan() const { + return base::span(key_pair_).first(); } -std::vector HDKeyEd25519::GetPublicKeyBytes() const { - auto public_key = private_key_->unwrap().public_key_raw(); - return {public_key.begin(), public_key.end()}; +base::span +HDKeyEd25519::GetPublicKeyAsSpan() const { + return base::span(key_pair_).last(); } std::string HDKeyEd25519::GetBase58EncodedPublicKey() const { - auto public_key = private_key_->unwrap().public_key_raw(); - return EncodeBase58(public_key); + return EncodeBase58(GetPublicKeyAsSpan()); } std::string HDKeyEd25519::GetBase58EncodedKeypair() const { - auto keypair = private_key_->unwrap().keypair_raw(); - return EncodeBase58(keypair); + return EncodeBase58(key_pair_); } } // namespace brave_wallet diff --git a/components/brave_wallet/browser/internal/hd_key_ed25519.h b/components/brave_wallet/browser/internal/hd_key_ed25519.h index 9a02be8a0b49..c7f48dbed4c0 100644 --- a/components/brave_wallet/browser/internal/hd_key_ed25519.h +++ b/components/brave_wallet/browser/internal/hd_key_ed25519.h @@ -8,47 +8,55 @@ #include #include -#include #include "base/containers/span.h" -#include "brave/components/brave_wallet/rust/lib.rs.h" namespace brave_wallet { -// This class implement basic EdDSA over ed25519 functionality of bip32-ed25519 +constexpr size_t kEd25519SecretKeySize = 32; +constexpr size_t kEd25519PublicKeySize = 32; +constexpr size_t kEd25519KeypairSize = + kEd25519SecretKeySize + kEd25519PublicKeySize; +constexpr size_t kEd25519ChainCodeSize = 32; +constexpr size_t kEd25519SignatureSize = 64; + +// This class implements basic EdDSA over ed25519 functionality of SLIP-0010 // spec with 32 bytes private key and only allows private key derivation with // hardened index. +// https://github.com/satoshilabs/slips/blob/master/slip-0010.md class HDKeyEd25519 { public: - HDKeyEd25519(std::string path, - rust::Box); + HDKeyEd25519(); ~HDKeyEd25519(); HDKeyEd25519(const HDKeyEd25519&) = delete; HDKeyEd25519& operator=(const HDKeyEd25519&) = delete; - static std::unique_ptr GenerateFromSeed( - base::span seed); - static std::unique_ptr GenerateFromPrivateKey( - base::span private_key); + static std::unique_ptr GenerateFromSeedAndPath( + base::span seed, + std::string_view hd_path); + static std::unique_ptr GenerateFromKeyPair( + base::span key_pair); - std::string GetPath() const; std::unique_ptr DeriveHardenedChild(uint32_t index); - // If path contains normal index, nullptr will be returned - std::unique_ptr DeriveChildFromPath(const std::string& path); - std::vector Sign(base::span msg); - bool VerifyForTesting(base::span msg, - base::span sig); + std::array Sign( + base::span msg); - std::vector GetPrivateKeyBytes() const; - std::vector GetPublicKeyBytes() const; + base::span GetPrivateKeyAsSpan() const + LIFETIME_BOUND; + base::span GetPublicKeyAsSpan() const + LIFETIME_BOUND; std::string GetBase58EncodedPublicKey() const; std::string GetBase58EncodedKeypair() const; private: - std::string path_; - rust::Box private_key_; + HDKeyEd25519(base::span key, base::span data); + + std::unique_ptr DeriveChild(uint32_t index); + + std::array key_pair_ = {}; + std::array chain_code_ = {}; }; } // namespace brave_wallet diff --git a/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc b/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc index da32fc5a53af..ff2035200887 100644 --- a/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc +++ b/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc @@ -4,12 +4,26 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ #include "brave/components/brave_wallet/browser/internal/hd_key_ed25519.h" + #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" +#include "brave/components/brave_wallet/common/hex_utils.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/boringssl/src/include/openssl/curve25519.h" namespace brave_wallet { +namespace { + +bool VerifySignature(const HDKeyEd25519& key, + base::span msg, + base::span sig) { + return !!ED25519_verify(msg.data(), msg.size(), sig.data(), + key.GetPublicKeyAsSpan().data()); +} + +} // namespace + // https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-1-for-ed25519 TEST(HDKeyEd25519UnitTest, TestVector1) { std::vector bytes; @@ -17,15 +31,11 @@ TEST(HDKeyEd25519UnitTest, TestVector1) { base::HexStringToBytes("000102030405060708090a0b0c0d0e0f", &bytes)); // m - auto master_key_base = HDKeyEd25519::GenerateFromSeed(bytes); - EXPECT_EQ(master_key_base->GetPath(), "m"); - HDKeyEd25519* master_key = static_cast(master_key_base.get()); - EXPECT_EQ( - base::ToLowerASCII(base::HexEncode(master_key->GetPrivateKeyBytes())), - "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7"); - EXPECT_EQ( - base::ToLowerASCII(base::HexEncode(master_key->GetPublicKeyBytes())), - "a4b2856bfec510abab89753fac1ac0e1112364e7d250545963f135f2a33188ed"); + auto master_key = HDKeyEd25519::GenerateFromSeedAndPath(bytes, "m"); + EXPECT_EQ(HexEncodeLower(master_key->GetPrivateKeyAsSpan()), + "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7"); + EXPECT_EQ(HexEncodeLower(master_key->GetPublicKeyAsSpan()), + "a4b2856bfec510abab89753fac1ac0e1112364e7d250545963f135f2a33188ed"); EXPECT_EQ(master_key->GetBase58EncodedPublicKey(), "C5ukMV73nk32h52MjxtnZXTrrr7rupD9CTDDRnYYDRYQ"); EXPECT_EQ(master_key->GetBase58EncodedKeypair(), @@ -33,13 +43,11 @@ TEST(HDKeyEd25519UnitTest, TestVector1) { "YbQtaJQKLXET9jVjepWXe"); // m/0'/1'/2'/2'/1000000000' - auto child_base = - master_key->DeriveChildFromPath("m/0'/1'/2'/2'/1000000000'"); - EXPECT_EQ(child_base->GetPath(), "m/0'/1'/2'/2'/1000000000'"); - HDKeyEd25519* child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + auto child = + HDKeyEd25519::GenerateFromSeedAndPath(bytes, "m/0'/1'/2'/2'/1000000000'"); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "8f94d394a8e8fd6b1bc2f3f49f5c47e385281d5c17e65324b0f62483e37e8793"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "3c24da049451555d51a7014a37337aa4e12d41e485abccfa46b47dfb2af54b7a"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "53n47S4RT9ozx5KrpH6uYfdnAjrTBJri8qZJBvRfw1Bf"); @@ -47,12 +55,10 @@ TEST(HDKeyEd25519UnitTest, TestVector1) { "3sVsV9myuRDg4rio4n3ftoP3NsUDzjVk6i8WiTg9veDsiALQjt9QEfUckJkutYUgzm" "wwz55D49JUDFic5Fu2gDjX"); // m/0' - child_base = master_key->DeriveHardenedChild(0); - EXPECT_EQ(child_base->GetPath(), "m/0'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = master_key->DeriveHardenedChild(0); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "68e0fe46dfb67e368c75379acec591dad19df3cde26e63b93a8e704f1dade7a3"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "8c8a13df77a28f3445213a0f432fde644acaa215fc72dcdf300d5efaa85d350c"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "ATcCGRoY87cSJESCXbHXEX6CDWQxepAViUvVnNsELhRu"); @@ -60,12 +66,10 @@ TEST(HDKeyEd25519UnitTest, TestVector1) { "36crUN2YvuPXEpRXNmdtv5W1veeXHZvMqSe4Egqu4Ski9FHtbdizagf9Kfj8e7sD4S" "e5YCqQQ2vpUuKGycM8WhF9"); // m/0'/1' - child_base = child->DeriveHardenedChild(1); - EXPECT_EQ(child_base->GetPath(), "m/0'/1'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = child->DeriveHardenedChild(1); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "b1d0bad404bf35da785a64ca1ac54b2617211d2777696fbffaf208f746ae84f2"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "1932a5270f335bed617d5b935c80aedb1a35bd9fc1e31acafd5372c30f5c1187"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "2hMz2f8WbLw5m2icKR2WVrcizvnguw8xaAnXjaeohuHQ"); @@ -73,12 +77,10 @@ TEST(HDKeyEd25519UnitTest, TestVector1) { "4ZCMMnibQjY732c95g1bK5aWzZpR3H1HAqGMeh1B4xpcUWkpxJyUVfwqVBjft1bpRA" "WjiJTaUUPWFJEqKWn6cVZp"); // m/0'/1'/2' - child_base = child->DeriveHardenedChild(2); - EXPECT_EQ(child_base->GetPath(), "m/0'/1'/2'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = child->DeriveHardenedChild(2); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "92a5b23c0b8a99e37d07df3fb9966917f5d06e02ddbd909c7e184371463e9fc9"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "ae98736566d30ed0e9d2f4486a64bc95740d89c7db33f52121f8ea8f76ff0fc1"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "CkYmXLvWehLXBzUAJ3g3wsfc5QjoCtWtSydquF7HDxXS"); @@ -86,12 +88,10 @@ TEST(HDKeyEd25519UnitTest, TestVector1) { "3w45HeUP7x8DhVFxmUwsww19XUdxNZeTuMQQBFJCXAaGtYLvjUVvWovNX7aKpjp5pa" "YERPr1jgWEvGeemRm2bCBJ"); // m/0'/1'/2'/2' - child_base = child->DeriveHardenedChild(2); - EXPECT_EQ(child_base->GetPath(), "m/0'/1'/2'/2'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = child->DeriveHardenedChild(2); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "30d1dc7e5fc04c31219ab25a27ae00b50f6fd66622f6e9c913253d6511d1e662"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "8abae2d66361c879b900d204ad2cc4984fa2aa344dd7ddc46007329ac76c429c"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "ALYYdMp2jVV4HGsZZPfLy1BQLMHL2CQG5XHpzr2XiHCw"); @@ -99,12 +99,10 @@ TEST(HDKeyEd25519UnitTest, TestVector1) { "ycUieXQauHN9msp7beGkDcUPwF4g3YhzqUXwVihv8PJbF96Eyeh1PFTxhzP4AaXt5U" "QCR3mVsrs8AiPCKMCLs2s"); // m/0'/1'/2'/2'/1000000000' - child_base = child->DeriveHardenedChild(1000000000); - EXPECT_EQ(child_base->GetPath(), "m/0'/1'/2'/2'/1000000000'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = child->DeriveHardenedChild(1000000000); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "8f94d394a8e8fd6b1bc2f3f49f5c47e385281d5c17e65324b0f62483e37e8793"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "3c24da049451555d51a7014a37337aa4e12d41e485abccfa46b47dfb2af54b7a"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "53n47S4RT9ozx5KrpH6uYfdnAjrTBJri8qZJBvRfw1Bf"); @@ -122,28 +120,23 @@ TEST(HDKeyEd25519UnitTest, TestVector2) { &bytes)); // m - auto master_key_base = HDKeyEd25519::GenerateFromSeed(bytes); - EXPECT_EQ(master_key_base->GetPath(), "m"); + auto master_key_base = HDKeyEd25519::GenerateFromSeedAndPath(bytes, "m"); HDKeyEd25519* master_key = static_cast(master_key_base.get()); - EXPECT_EQ( - base::ToLowerASCII(base::HexEncode(master_key->GetPrivateKeyBytes())), - "171cb88b1b3c1db25add599712e36245d75bc65a1a5c9e18d76f9f2b1eab4012"); - EXPECT_EQ( - base::ToLowerASCII(base::HexEncode(master_key->GetPublicKeyBytes())), - "8fe9693f8fa62a4305a140b9764c5ee01e455963744fe18204b4fb948249308a"); + EXPECT_EQ(HexEncodeLower(master_key->GetPrivateKeyAsSpan()), + "171cb88b1b3c1db25add599712e36245d75bc65a1a5c9e18d76f9f2b1eab4012"); + EXPECT_EQ(HexEncodeLower(master_key->GetPublicKeyAsSpan()), + "8fe9693f8fa62a4305a140b9764c5ee01e455963744fe18204b4fb948249308a"); EXPECT_EQ(master_key->GetBase58EncodedPublicKey(), "AgmjPHe5Qs4VakvXHGnd6NsYjaxt4suMUtf39TayrSfb"); EXPECT_EQ(master_key->GetBase58EncodedKeypair(), "ToTfZTGTYncQcR7P7PduNLKDd8sNHMKsB7td24qCZzwzzZ65fA8y7Ht3o7nwojMzoV" "rD9M6Y7vPKznLJPjpwgLZ"); // m/0'/2147483647'/1'/2147483646'/2' - auto child_base = - master_key->DeriveChildFromPath("m/0'/2147483647'/1'/2147483646'/2'"); - EXPECT_EQ(child_base->GetPath(), "m/0'/2147483647'/1'/2147483646'/2'"); - HDKeyEd25519* child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + auto child = master_key->GenerateFromSeedAndPath( + bytes, "m/0'/2147483647'/1'/2147483646'/2'"); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "551d333177df541ad876a60ea71f00447931c0a9da16f227c11ea080d7391b8d"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "47150c75db263559a70d5778bf36abbab30fb061ad69f69ece61a72b0cfa4fc0"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "5nUZbtNefYa7tWHdpQApxsjPLtTZpKuZYnKDsd2dXADu"); @@ -151,12 +144,10 @@ TEST(HDKeyEd25519UnitTest, TestVector2) { "2hhXd52y2dVVJGUkr6kikm3LcMQcPSwhWaB1GDU7nAMRWXbjAuG1G9mjdSETpAEAJ1" "vV9nQrvhARxQDc6iEEbpU7"); // m/0' - child_base = master_key->DeriveHardenedChild(0); - EXPECT_EQ(child_base->GetPath(), "m/0'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = master_key->DeriveHardenedChild(0); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "1559eb2bbec5790b0c65d8693e4d0875b1747f4970ae8b650486ed7470845635"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "86fab68dcb57aa196c77c5f264f215a112c22a912c10d123b0d03c3c28ef1037"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "A5uN5c31sqKK4x82gXeHzsBFpBTTusPDHBZT111V3u4i"); @@ -164,12 +155,10 @@ TEST(HDKeyEd25519UnitTest, TestVector2) { "Rm2NBwPiLaJoWaetGVz9Jy1T477CS2FfM4Q5JmWgCLRhX54T8zHX57RH6LgR2kRXTc" "DwPVMAQi4nxFVH2DJiXkA"); // m/0'/2147483647' - child_base = child->DeriveHardenedChild(2147483647); - EXPECT_EQ(child_base->GetPath(), "m/0'/2147483647'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = child->DeriveHardenedChild(2147483647); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "ea4f5bfe8694d8bb74b7b59404632fd5968b774ed545e810de9c32a4fb4192f4"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "5ba3b9ac6e90e83effcd25ac4e58a1365a9e35a3d3ae5eb07b9e4d90bcf7506d"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "7AiuCW2Mg2vRAHsrVmsM3uFky4XRaXHqqcemSp6Bract"); @@ -177,12 +166,10 @@ TEST(HDKeyEd25519UnitTest, TestVector2) { "5gi27AKyRrB5rvX9yPT39WpRak9B5QAXSZLvFDoqb7nQGhKLTqhTLeUgax4FVGGurZ" "PQNjRX6N9sn4o7f5rSAeWG"); // m/0'/2147483647'/1' - child_base = child->DeriveHardenedChild(1); - EXPECT_EQ(child_base->GetPath(), "m/0'/2147483647'/1'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = child->DeriveHardenedChild(1); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "3757c7577170179c7868353ada796c839135b3d30554bbb74a4b1e4a5a58505c"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "2e66aa57069c86cc18249aecf5cb5a9cebbfd6fadeab056254763874a9352b45"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "488Z1Z7moahUL7Np2JMrApWbWwdUEBzSfEioz9vj7vCc"); @@ -190,12 +177,10 @@ TEST(HDKeyEd25519UnitTest, TestVector2) { "27BCpwH2qcy7ANSVAisHjBN3CQyfzKyV4qcSet2YP1X5aCsoKS9kwcxqvJdVNcBWN3" "xuKFviozGBrUsbhXumYa9z"); // m/0'/2147483647'/1'/2147483646' - child_base = child->DeriveHardenedChild(2147483646); - EXPECT_EQ(child_base->GetPath(), "m/0'/2147483647'/1'/2147483646'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = child->DeriveHardenedChild(2147483646); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "5837736c89570de861ebc173b1086da4f505d4adb387c6a1b1342d5e4ac9ec72"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "e33c0f7d81d843c572275f287498e8d408654fdf0d1e065b84e2e6f157aab09b"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "GJ2famWaTaWgT5oYvi1dqA7cvtoKMzyje1Pcx1bL9Nsc"); @@ -203,12 +188,10 @@ TEST(HDKeyEd25519UnitTest, TestVector2) { "2mJCNeA9JefF3B2gikqrR22BWa2ETCZNwijZvDn7XktHRVYj7sXhTt93sr7SqkBUp8" "h2pLb6V3nzpYN4mB9paeDQ"); // m/0'/2147483647'/1'/2147483646'/2' - child_base = child->DeriveHardenedChild(2); - EXPECT_EQ(child_base->GetPath(), "m/0'/2147483647'/1'/2147483646'/2'"); - child = static_cast(child_base.get()); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPrivateKeyBytes())), + child = child->DeriveHardenedChild(2); + EXPECT_EQ(HexEncodeLower(child->GetPrivateKeyAsSpan()), "551d333177df541ad876a60ea71f00447931c0a9da16f227c11ea080d7391b8d"); - EXPECT_EQ(base::ToLowerASCII(base::HexEncode(child->GetPublicKeyBytes())), + EXPECT_EQ(HexEncodeLower(child->GetPublicKeyAsSpan()), "47150c75db263559a70d5778bf36abbab30fb061ad69f69ece61a72b0cfa4fc0"); EXPECT_EQ(child->GetBase58EncodedPublicKey(), "5nUZbtNefYa7tWHdpQApxsjPLtTZpKuZYnKDsd2dXADu"); @@ -221,14 +204,14 @@ TEST(HDKeyEd25519UnitTest, Errors) { std::vector bytes; EXPECT_TRUE( base::HexStringToBytes("000102030405060708090a0b0c0d0e0f", &bytes)); - auto master_key = HDKeyEd25519::GenerateFromSeed(bytes); + auto master_key = HDKeyEd25519::GenerateFromSeedAndPath(bytes, "m"); // path contains normal index - auto child1 = master_key->DeriveChildFromPath("m/0'/1'/2'/3'/4"); + auto child1 = HDKeyEd25519::GenerateFromSeedAndPath(bytes, "m/0'/1'/2'/3'/4"); EXPECT_FALSE(child1); // invalid path - auto child2 = master_key->DeriveChildFromPath("BRAVE0'1'2'3'4'"); + auto child2 = HDKeyEd25519::GenerateFromSeedAndPath(bytes, "BRAVE0'1'2'3'4'"); EXPECT_FALSE(child2); // index is too big for hardened index @@ -240,7 +223,7 @@ TEST(HDKeyEd25519UnitTest, EncodePrivateKeyForExport) { std::vector bytes; EXPECT_TRUE( base::HexStringToBytes("000102030405060708090a0b0c0d0e0f", &bytes)); - auto master_key = HDKeyEd25519::GenerateFromSeed(bytes); + auto master_key = HDKeyEd25519::GenerateFromSeedAndPath(bytes, "m"); EXPECT_EQ(master_key->GetBase58EncodedKeypair(), "sCzwsBKmKtk5Hgb4YUJAduQ5nmJq4GTyzCXhrKonAGaexa83MgSZuTSMS6TSZTndnC" "YbQtaJQKLXET9jVjepWXe"); @@ -250,56 +233,40 @@ TEST(HDKeyEd25519UnitTest, SignAndVerify) { std::vector bytes; EXPECT_TRUE( base::HexStringToBytes("000102030405060708090a0b0c0d0e0f", &bytes)); - auto key = HDKeyEd25519::GenerateFromSeed(bytes); + auto key = HDKeyEd25519::GenerateFromSeedAndPath(bytes, "m"); const std::vector msg_a(32, 0x00); const std::vector msg_b(32, 0x08); - const std::vector sig_a = key->Sign(msg_a); - const std::vector sig_b = key->Sign(msg_b); + const auto sig_a = key->Sign(msg_a); + const auto sig_b = key->Sign(msg_b); - EXPECT_TRUE(key->VerifyForTesting(msg_a, sig_a)); - EXPECT_TRUE(key->VerifyForTesting(msg_b, sig_b)); + EXPECT_TRUE(VerifySignature(*key, msg_a, sig_a)); + EXPECT_TRUE(VerifySignature(*key, msg_b, sig_b)); // wrong signature - EXPECT_FALSE(key->VerifyForTesting(msg_a, sig_b)); - EXPECT_FALSE(key->VerifyForTesting(msg_b, sig_a)); - - // signature size != 64 - EXPECT_FALSE(key->VerifyForTesting(msg_a, std::vector(128, 0xff))); - EXPECT_FALSE(key->VerifyForTesting(msg_a, std::vector(32, 0xff))); - EXPECT_FALSE(key->VerifyForTesting(msg_b, std::vector(128, 0xff))); - EXPECT_FALSE(key->VerifyForTesting(msg_b, std::vector(32, 0xff))); + EXPECT_FALSE(VerifySignature(*key, msg_a, sig_b)); + EXPECT_FALSE(VerifySignature(*key, msg_b, sig_a)); } TEST(HDKeyEd25519UnitTest, GenerateFromPrivateKey) { - std::vector private_key; - ASSERT_TRUE(base::HexStringToBytes( - "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7", - &private_key)); - auto master_key = HDKeyEd25519::GenerateFromPrivateKey(private_key); + std::array key_pair; + ASSERT_TRUE(base::HexStringToSpan( + "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7" + "a4b2856bfec510abab89753fac1ac0e1112364e7d250545963f135f2a33188ed", + base::span(key_pair))); + auto master_key = HDKeyEd25519::GenerateFromKeyPair(key_pair); EXPECT_EQ(master_key->GetBase58EncodedKeypair(), "sCzwsBKmKtk5Hgb4YUJAduQ5nmJq4GTyzCXhrKonAGaexa83MgSZuTSMS6TSZTndnC" "YbQtaJQKLXET9jVjepWXe"); EXPECT_EQ(master_key->GetBase58EncodedPublicKey(), "C5ukMV73nk32h52MjxtnZXTrrr7rupD9CTDDRnYYDRYQ"); - EXPECT_EQ(master_key->GetPath(), ""); - - // 31 bytes - private_key.clear(); - ASSERT_TRUE(base::HexStringToBytes( - "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19", - &private_key)); - EXPECT_FALSE(HDKeyEd25519::GenerateFromPrivateKey(private_key)); - // 33 bytes - private_key.clear(); - ASSERT_TRUE(base::HexStringToBytes( - "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7ff", - &private_key)); - EXPECT_FALSE(HDKeyEd25519::GenerateFromPrivateKey(private_key)); + EXPECT_EQ( + "6260C446B2BA429541722F6BAABBEEAF3D1B5981DA326A2DB66804B5EACE770D" + "58CFBA0E0D409A3054E80C00505215C7CCD7A040F23364005A47CDE7FCED1400", + base::HexEncode(master_key->Sign(base::byte_span_from_cstring("hello")))); - // 0 bytes - private_key.clear(); - EXPECT_FALSE(HDKeyEd25519::GenerateFromPrivateKey(private_key)); + key_pair.back() = 0; + EXPECT_FALSE(HDKeyEd25519::GenerateFromKeyPair(key_pair)); } } // namespace brave_wallet diff --git a/components/brave_wallet/browser/internal/hd_key_utils.cc b/components/brave_wallet/browser/internal/hd_key_utils.cc new file mode 100644 index 000000000000..04af08342922 --- /dev/null +++ b/components/brave_wallet/browser/internal/hd_key_utils.cc @@ -0,0 +1,50 @@ +/* Copyright (c) 2024 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_wallet/browser/internal/hd_key_utils.h" + +#include + +#include "base/containers/span.h" +#include "base/numerics/checked_math.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/string_split.h" + +namespace brave_wallet { + +std::optional> ParseFullHDPath(std::string_view path) { + auto entries = base::SplitStringPiece( + path, "/", base::WhitespaceHandling::TRIM_WHITESPACE, + base::SplitResult::SPLIT_WANT_NONEMPTY); + + if (entries.empty()) { + return std::nullopt; + } + if (entries.front() != kMasterNode) { + return std::nullopt; + } + + std::vector result; + result.reserve(entries.size() - 1); + for (auto node : base::span(entries).subspan(1)) { + uint32_t offset = 0; + if (node.ends_with('\'')) { + node.remove_suffix(1); + offset = kHardenedOffset; + } + uint32_t value = 0; + if (!base::StringToUint(node, &value)) { + return std::nullopt; + } + if (value >= kHardenedOffset) { + return std::nullopt; + } + result.push_back(base::CheckAdd(value, offset).ValueOrDie()); + } + + return result; +} + +} // namespace brave_wallet diff --git a/components/brave_wallet/browser/internal/hd_key_utils.h b/components/brave_wallet/browser/internal/hd_key_utils.h new file mode 100644 index 000000000000..66b86d1b1bd7 --- /dev/null +++ b/components/brave_wallet/browser/internal/hd_key_utils.h @@ -0,0 +1,25 @@ +/* Copyright (c) 2024 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_INTERNAL_HD_KEY_UTILS_H_ +#define BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_INTERNAL_HD_KEY_UTILS_H_ + +#include +#include +#include + +namespace brave_wallet { + +inline constexpr char kMasterNode[] = "m"; +inline constexpr uint32_t kHardenedOffset = 0x80000000; + +// Parses BIP-32 full derivation path into a vector of indexes. Hardened indexes +// expected to end with a single quote per BIP-44 style. +// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki +// https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki +std::optional> ParseFullHDPath(std::string_view path); + +} // namespace brave_wallet +#endif // BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_INTERNAL_HD_KEY_UTILS_H_ diff --git a/components/brave_wallet/browser/internal/hd_key_utils_unittest.cc b/components/brave_wallet/browser/internal/hd_key_utils_unittest.cc new file mode 100644 index 000000000000..e12689cbb84d --- /dev/null +++ b/components/brave_wallet/browser/internal/hd_key_utils_unittest.cc @@ -0,0 +1,50 @@ +/* Copyright (c) 2024 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_wallet/browser/internal/hd_key_utils.h" + +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using testing::ElementsAre; +using testing::IsEmpty; + +namespace brave_wallet { + +TEST(HDKeyUtilsUnitTest, ParseFullHDPath) { + // Success cases. + EXPECT_THAT(*ParseFullHDPath("m"), IsEmpty()); + + EXPECT_THAT(*ParseFullHDPath("m/0"), ElementsAre(0)); + EXPECT_THAT(*ParseFullHDPath("m/1"), ElementsAre(1)); + + EXPECT_THAT(*ParseFullHDPath("m/0'"), ElementsAre(kHardenedOffset)); + EXPECT_THAT(*ParseFullHDPath("m/2'"), ElementsAre(kHardenedOffset + 2)); + + EXPECT_THAT(*ParseFullHDPath("m/0/1/2/3/4"), ElementsAre(0, 1, 2, 3, 4)); + EXPECT_THAT(*ParseFullHDPath("m/2'/3/4'/5"), + ElementsAre(kHardenedOffset + 2, 3, kHardenedOffset + 4, 5)); + + // Index overflows. + EXPECT_THAT(*ParseFullHDPath("m/2147483647"), ElementsAre(2147483647)); + EXPECT_FALSE(ParseFullHDPath("m/2147483648")); + EXPECT_THAT(*ParseFullHDPath("m/2147483647'"), + ElementsAre(kHardenedOffset + 2147483647)); + EXPECT_FALSE(ParseFullHDPath("m/2147483648'")); + + // Incorrect format. + EXPECT_FALSE(ParseFullHDPath("")); + EXPECT_FALSE(ParseFullHDPath("a")); + EXPECT_FALSE(ParseFullHDPath("/0/1/2/3/4")); + EXPECT_FALSE(ParseFullHDPath("0/1/2/3/4")); + EXPECT_FALSE(ParseFullHDPath("m/0//1")); + EXPECT_FALSE(ParseFullHDPath("m/0/1/")); + EXPECT_FALSE(ParseFullHDPath("m/-1")); + EXPECT_FALSE(ParseFullHDPath("m/1/a")); + EXPECT_FALSE(ParseFullHDPath("m/1''")); + EXPECT_FALSE(ParseFullHDPath("m/1'1")); +} + +} // namespace brave_wallet diff --git a/components/brave_wallet/browser/solana_keyring.cc b/components/brave_wallet/browser/solana_keyring.cc index 9e80cbd9715d..7f7c2b4ade33 100644 --- a/components/brave_wallet/browser/solana_keyring.cc +++ b/components/brave_wallet/browser/solana_keyring.cc @@ -11,6 +11,7 @@ #include "base/containers/contains.h" #include "base/containers/span.h" +#include "base/containers/to_vector.h" #include "base/ranges/algorithm.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/common/brave_wallet.mojom.h" @@ -38,9 +39,7 @@ std::unique_ptr SolanaKeyring::ConstructRootHDKey( base::span seed, const std::string& hd_path) { if (!seed.empty()) { - if (auto master_key = HDKeyEd25519::GenerateFromSeed(seed)) { - return master_key->DeriveChildFromPath(hd_path); - } + return HDKeyEd25519::GenerateFromSeedAndPath(seed, hd_path); } return nullptr; @@ -65,12 +64,13 @@ void SolanaKeyring::RemoveLastHDAccount() { accounts_.pop_back(); } -std::string SolanaKeyring::ImportAccount(base::span keypair) { - // extract private key from keypair - std::vector private_key = std::vector( - keypair.begin(), keypair.begin() + kSolanaPrikeySize); +std::string SolanaKeyring::ImportAccount(base::span payload) { + auto key_pair = payload.to_fixed_extent(); + if (!key_pair) { + return std::string(); + } std::unique_ptr hd_key = - HDKeyEd25519::GenerateFromPrivateKey(private_key); + HDKeyEd25519::GenerateFromKeyPair(*key_pair); if (!hd_key) { return std::string(); } @@ -108,13 +108,12 @@ std::string SolanaKeyring::EncodePrivateKeyForExport( std::vector SolanaKeyring::SignMessage( const std::string& address, base::span message) { - HDKeyEd25519* hd_key = - static_cast(GetHDKeyFromAddress(address)); + HDKeyEd25519* hd_key = GetHDKeyFromAddress(address); if (!hd_key) { return std::vector(); } - return hd_key->Sign(message); + return base::ToVector(hd_key->Sign(message)); } std::vector SolanaKeyring::GetHDAccountsForTesting() const { @@ -177,15 +176,14 @@ std::optional SolanaKeyring::CreateProgramDerivedAddress( buffer.insert(buffer.end(), pda_marker.begin(), pda_marker.end()); auto hash_array = crypto::SHA256Hash(buffer); - std::vector hash_vec(hash_array.begin(), hash_array.end()); // Invalid because program derived addresses have to be off-curve. if (bytes_are_curve25519_point( - rust::Slice{hash_vec.data(), hash_vec.size()})) { + rust::Slice{hash_array.data(), hash_array.size()})) { return std::nullopt; } - return Base58Encode(hash_vec); + return Base58Encode(hash_array); } // Find a valid program derived address and its corresponding bump seed. diff --git a/components/brave_wallet/browser/solana_keyring.h b/components/brave_wallet/browser/solana_keyring.h index 519679275706..b97dfad0b0a5 100644 --- a/components/brave_wallet/browser/solana_keyring.h +++ b/components/brave_wallet/browser/solana_keyring.h @@ -31,7 +31,7 @@ class SolanaKeyring : public HDKeyring { std::optional AddNewHDAccount() override; void RemoveLastHDAccount() override; - std::string ImportAccount(base::span keypair) override; + std::string ImportAccount(base::span payload) override; bool RemoveImportedAccount(const std::string& address) override; std::string EncodePrivateKeyForExport(const std::string& address) override; diff --git a/components/brave_wallet/browser/solana_keyring_unittest.cc b/components/brave_wallet/browser/solana_keyring_unittest.cc index dd604364ba12..cf11f5484e17 100644 --- a/components/brave_wallet/browser/solana_keyring_unittest.cc +++ b/components/brave_wallet/browser/solana_keyring_unittest.cc @@ -95,7 +95,8 @@ TEST(SolanaKeyringUnitTest, ImportAccount) { std::vector private_key; ASSERT_TRUE(base::HexStringToBytes( - "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7", + "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7" + "a4b2856bfec510abab89753fac1ac0e1112364e7d250545963f135f2a33188ed", &private_key)); keyring.ImportAccount(private_key); EXPECT_EQ(keyring.GetImportedAccountsForTesting().size(), 1u); diff --git a/components/brave_wallet/browser/test/BUILD.gn b/components/brave_wallet/browser/test/BUILD.gn index 1cb94f2a57e1..4bc0657cac25 100644 --- a/components/brave_wallet/browser/test/BUILD.gn +++ b/components/brave_wallet/browser/test/BUILD.gn @@ -58,6 +58,7 @@ source_set("brave_wallet_unit_tests") { "//brave/components/brave_wallet/browser/filecoin_keyring_unittest.cc", "//brave/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc", "//brave/components/brave_wallet/browser/internal/hd_key_unittest.cc", + "//brave/components/brave_wallet/browser/internal/hd_key_utils_unittest.cc", "//brave/components/brave_wallet/browser/json_rpc_requests_helper_unittest.cc", "//brave/components/brave_wallet/browser/json_rpc_response_parser_unittest.cc", "//brave/components/brave_wallet/browser/json_rpc_service_test_utils_unittest.cc", diff --git a/components/brave_wallet/common/BUILD.gn b/components/brave_wallet/common/BUILD.gn index 77ebce97ad4d..c03313270678 100644 --- a/components/brave_wallet/common/BUILD.gn +++ b/components/brave_wallet/common/BUILD.gn @@ -75,7 +75,6 @@ static_library("common") { ":generated_eth_requests", ":generated_json_rpc_requests", ":pref_names", - "//brave/components/brave_wallet/rust:rust_lib", "//brave/net/base:utils", "//brave/third_party/argon2", "//brave/third_party/bitcoin-core", diff --git a/components/brave_wallet/common/hash_utils.cc b/components/brave_wallet/common/hash_utils.cc index 5d1e89639dbc..1cbeebcbe031 100644 --- a/components/brave_wallet/common/hash_utils.cc +++ b/components/brave_wallet/common/hash_utils.cc @@ -17,6 +17,7 @@ #include "brave/third_party/bitcoin-core/src/src/crypto/ripemd160.h" #include "brave/third_party/ethash/src/include/ethash/keccak.h" #include "crypto/sha2.h" +#include "third_party/boringssl/src/include/openssl/hmac.h" namespace brave_wallet { namespace { @@ -74,4 +75,14 @@ Ripemd160HashArray Hash160(base::span input) { return result; } +SHA512HashArray HmacSha512(base::span key, + base::span data) { + SHA512HashArray hmac; + unsigned int out_len = 0; + CHECK(HMAC(EVP_sha512(), key.data(), key.size(), data.data(), data.size(), + hmac.data(), &out_len)); + CHECK_EQ(out_len, hmac.size()); + return hmac; +} + } // namespace brave_wallet diff --git a/components/brave_wallet/common/hash_utils.h b/components/brave_wallet/common/hash_utils.h index f445edca8a3b..c56bb4dfd702 100644 --- a/components/brave_wallet/common/hash_utils.h +++ b/components/brave_wallet/common/hash_utils.h @@ -17,9 +17,11 @@ namespace brave_wallet { inline constexpr size_t kKeccakHashLength = 32; inline constexpr size_t kRipemd160HashLength = 20; +inline constexpr size_t kSHA512HashLength = 64; using KeccakHashArray = std::array; using SHA256HashArray = std::array; +using SHA512HashArray = std::array; using Ripemd160HashArray = std::array; KeccakHashArray KeccakHash(base::span input); @@ -40,6 +42,9 @@ SHA256HashArray DoubleSHA256Hash(base::span input); // ripemd160(sha256(input)) Ripemd160HashArray Hash160(base::span input); +SHA512HashArray HmacSha512(base::span key, + base::span data); + } // namespace brave_wallet #endif // BRAVE_COMPONENTS_BRAVE_WALLET_COMMON_HASH_UTILS_H_ diff --git a/components/brave_wallet/common/hash_utils_unittest.cc b/components/brave_wallet/common/hash_utils_unittest.cc index 587b4740a162..b57e3ff46bc1 100644 --- a/components/brave_wallet/common/hash_utils_unittest.cc +++ b/components/brave_wallet/common/hash_utils_unittest.cc @@ -79,4 +79,30 @@ TEST(HashUtilsUnitTest, Hash160) { "b472a266d0bd89c13706a4132ccfb16f7c3b9fcb"); } +TEST(HashUtilsUnitTest, HmacSha512) { + // Empty vectors test. + EXPECT_EQ(HexEncodeLower(HmacSha512({}, {})), + "b936cee86c9f87aa5d3c6f2e84cb5a4239a5fe50480a6ec66b70ab5b1f4ac673" + "0c6c515421b327ec1d69402e53dfb49ad7381eb067b338fd7b0cb22247225d47"); + + // Large vectors test. + EXPECT_EQ(HexEncodeLower(HmacSha512(std::vector(1000, 0xee), + std::vector(2000, 0x45))), + "5d6a801cf32c7d5edb17f5287653c86323599de6e8ab76819b3530494e144ec6" + "3a40f6e541d6cc8a7db3d0560349d74ca52c1e370c9a70a96096e28761d017fc"); + + // https://datatracker.ietf.org/doc/html/rfc4231#section-4.2 + EXPECT_EQ( + HexEncodeLower(HmacSha512(std::vector(20, 0x0b), + base::byte_span_from_cstring("Hi There"))), + "87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cde" + "daa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854"); + + // https://datatracker.ietf.org/doc/html/rfc4231#section-4.4 + EXPECT_EQ(HexEncodeLower(HmacSha512(std::vector(20, 0xaa), + std::vector(50, 0xdd))), + "fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39" + "bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb"); +} + } // namespace brave_wallet From 0458161e4bbec00e3734e9e214ff1eba3e898ceb Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Wed, 27 Nov 2024 14:08:03 +0700 Subject: [PATCH 2/5] remove ed25519-dalek-bip32 crate deps --- components/brave_wallet/rust/BUILD.gn | 1 - components/brave_wallet/rust/Cargo.toml | 1 - components/brave_wallet/rust/lib.rs | 182 - third_party/rust/base64ct/v1/BUILD.gn | 46 - third_party/rust/base64ct/v1/README.chromium | 12 - .../rust/chromium_crates_io/Cargo.lock | 85 - .../rust/chromium_crates_io/gnrt_config.toml | 27 - .../base64ct-1.6.0/.cargo-checksum.json | 1 - .../base64ct-1.6.0/.cargo_vcs_info.json | 6 - .../vendor/base64ct-1.6.0/CHANGELOG.md | 148 - .../vendor/base64ct-1.6.0/Cargo.toml | 55 - .../vendor/base64ct-1.6.0/Cargo.toml.orig | 29 - .../vendor/base64ct-1.6.0/LICENSE-APACHE | 201 - .../vendor/base64ct-1.6.0/LICENSE-MIT | 26 - .../vendor/base64ct-1.6.0/README.md | 86 - .../vendor/base64ct-1.6.0/benches/mod.rs | 62 - .../vendor/base64ct-1.6.0/src/alphabet.rs | 124 - .../base64ct-1.6.0/src/alphabet/bcrypt.rs | 33 - .../base64ct-1.6.0/src/alphabet/crypt.rs | 29 - .../base64ct-1.6.0/src/alphabet/shacrypt.rs | 65 - .../base64ct-1.6.0/src/alphabet/standard.rs | 54 - .../vendor/base64ct-1.6.0/src/alphabet/url.rs | 54 - .../vendor/base64ct-1.6.0/src/decoder.rs | 618 --- .../vendor/base64ct-1.6.0/src/encoder.rs | 363 -- .../vendor/base64ct-1.6.0/src/encoding.rs | 376 -- .../vendor/base64ct-1.6.0/src/errors.rs | 84 - .../vendor/base64ct-1.6.0/src/lib.rs | 105 - .../vendor/base64ct-1.6.0/src/line_ending.rs | 53 - .../vendor/base64ct-1.6.0/src/test_vectors.rs | 70 - .../vendor/base64ct-1.6.0/tests/bcrypt.rs | 68 - .../vendor/base64ct-1.6.0/tests/common/mod.rs | 80 - .../vendor/base64ct-1.6.0/tests/crypt.rs | 68 - .../tests/proptests.proptest-regressions | 10 - .../vendor/base64ct-1.6.0/tests/proptests.rs | 152 - .../vendor/base64ct-1.6.0/tests/shacrypt.rs | 98 - .../vendor/base64ct-1.6.0/tests/standard.rs | 142 - .../vendor/base64ct-1.6.0/tests/url.rs | 128 - .../const-oid-0.9.6/.cargo-checksum.json | 1 - .../const-oid-0.9.6/.cargo_vcs_info.json | 6 - .../vendor/const-oid-0.9.6/CHANGELOG.md | 197 - .../vendor/const-oid-0.9.6/Cargo.toml | 58 - .../vendor/const-oid-0.9.6/Cargo.toml.orig | 31 - .../vendor/const-oid-0.9.6/LICENSE-APACHE | 201 - .../vendor/const-oid-0.9.6/LICENSE-MIT | 25 - .../vendor/const-oid-0.9.6/README.md | 96 - .../vendor/const-oid-0.9.6/src/arcs.rs | 170 - .../vendor/const-oid-0.9.6/src/checked.rs | 11 - .../vendor/const-oid-0.9.6/src/db.rs | 164 - .../vendor/const-oid-0.9.6/src/db/gen.rs | 4248 ----------------- .../vendor/const-oid-0.9.6/src/encoder.rs | 165 - .../vendor/const-oid-0.9.6/src/error.rs | 83 - .../vendor/const-oid-0.9.6/src/lib.rs | 280 -- .../vendor/const-oid-0.9.6/src/parser.rs | 112 - .../vendor/const-oid-0.9.6/tests/lib.rs | 209 - .../vendor/der-0.7.9/.cargo-checksum.json | 1 - .../vendor/der-0.7.9/.cargo_vcs_info.json | 6 - .../vendor/der-0.7.9/CHANGELOG.md | 465 -- .../vendor/der-0.7.9/Cargo.toml | 109 - .../vendor/der-0.7.9/Cargo.toml.orig | 45 - .../vendor/der-0.7.9/LICENSE-APACHE | 201 - .../vendor/der-0.7.9/LICENSE-MIT | 25 - .../vendor/der-0.7.9/README.md | 96 - .../vendor/der-0.7.9/src/arrayvec.rs | 145 - .../vendor/der-0.7.9/src/asn1.rs | 67 - .../vendor/der-0.7.9/src/asn1/any.rs | 315 -- .../vendor/der-0.7.9/src/asn1/bit_string.rs | 552 --- .../vendor/der-0.7.9/src/asn1/bmp_string.rs | 164 - .../vendor/der-0.7.9/src/asn1/boolean.rs | 82 - .../vendor/der-0.7.9/src/asn1/choice.rs | 26 - .../der-0.7.9/src/asn1/context_specific.rs | 354 -- .../der-0.7.9/src/asn1/generalized_time.rs | 327 -- .../vendor/der-0.7.9/src/asn1/ia5_string.rs | 195 - .../vendor/der-0.7.9/src/asn1/integer.rs | 161 - .../vendor/der-0.7.9/src/asn1/integer/int.rs | 442 -- .../vendor/der-0.7.9/src/asn1/integer/uint.rs | 428 -- .../der-0.7.9/src/asn1/internal_macros.rs | 75 - .../vendor/der-0.7.9/src/asn1/null.rs | 102 - .../vendor/der-0.7.9/src/asn1/octet_string.rs | 257 - .../vendor/der-0.7.9/src/asn1/oid.rs | 100 - .../vendor/der-0.7.9/src/asn1/optional.rs | 66 - .../der-0.7.9/src/asn1/printable_string.rs | 252 - .../vendor/der-0.7.9/src/asn1/real.rs | 990 ---- .../vendor/der-0.7.9/src/asn1/sequence.rs | 53 - .../vendor/der-0.7.9/src/asn1/sequence_of.rs | 230 - .../vendor/der-0.7.9/src/asn1/set_of.rs | 539 --- .../der-0.7.9/src/asn1/teletex_string.rs | 217 - .../vendor/der-0.7.9/src/asn1/utc_time.rs | 242 - .../vendor/der-0.7.9/src/asn1/utf8_string.rs | 164 - .../der-0.7.9/src/asn1/videotex_string.rs | 98 - .../vendor/der-0.7.9/src/bytes_owned.rs | 162 - .../vendor/der-0.7.9/src/bytes_ref.rs | 152 - .../vendor/der-0.7.9/src/datetime.rs | 447 -- .../vendor/der-0.7.9/src/decode.rs | 99 - .../vendor/der-0.7.9/src/document.rs | 354 -- .../vendor/der-0.7.9/src/encode.rs | 158 - .../vendor/der-0.7.9/src/encode_ref.rs | 71 - .../vendor/der-0.7.9/src/error.rs | 369 -- .../vendor/der-0.7.9/src/header.rs | 60 - .../vendor/der-0.7.9/src/length.rs | 514 -- .../vendor/der-0.7.9/src/lib.rs | 402 -- .../vendor/der-0.7.9/src/ord.rs | 85 - .../vendor/der-0.7.9/src/reader.rs | 167 - .../vendor/der-0.7.9/src/reader/nested.rs | 96 - .../vendor/der-0.7.9/src/reader/pem.rs | 206 - .../vendor/der-0.7.9/src/reader/slice.rs | 214 - .../vendor/der-0.7.9/src/referenced.rs | 69 - .../vendor/der-0.7.9/src/str_owned.rs | 104 - .../vendor/der-0.7.9/src/str_ref.rs | 92 - .../vendor/der-0.7.9/src/tag.rs | 460 -- .../vendor/der-0.7.9/src/tag/class.rs | 50 - .../vendor/der-0.7.9/src/tag/mode.rs | 40 - .../vendor/der-0.7.9/src/tag/number.rs | 201 - .../vendor/der-0.7.9/src/writer.rs | 29 - .../vendor/der-0.7.9/src/writer/pem.rs | 41 - .../vendor/der-0.7.9/src/writer/slice.rs | 149 - .../tests/datetime.proptest-regressions | 8 - .../vendor/der-0.7.9/tests/datetime.rs | 64 - .../vendor/der-0.7.9/tests/derive.rs | 461 -- .../vendor/der-0.7.9/tests/examples/spki.der | Bin 44 -> 0 bytes .../vendor/der-0.7.9/tests/examples/spki.pem | 3 - .../vendor/der-0.7.9/tests/pem.rs | 67 - .../vendor/der-0.7.9/tests/set_of.rs | 65 - .../.cargo-checksum.json | 1 - .../.cargo_vcs_info.json | 6 - .../.github/workflows/audit.yml | 16 - .../.github/workflows/ci.yml | 82 - .../vendor/derivation-path-0.2.0/.gitignore | 2 - .../vendor/derivation-path-0.2.0/Cargo.toml | 38 - .../derivation-path-0.2.0/Cargo.toml.orig | 17 - .../vendor/derivation-path-0.2.0/README.md | 19 - .../vendor/derivation-path-0.2.0/src/lib.rs | 775 --- .../vendor/ed25519-2.2.3/.cargo-checksum.json | 1 - .../vendor/ed25519-2.2.3/.cargo_vcs_info.json | 6 - .../vendor/ed25519-2.2.3/CHANGELOG.md | 249 - .../vendor/ed25519-2.2.3/Cargo.toml | 101 - .../vendor/ed25519-2.2.3/Cargo.toml.orig | 44 - .../vendor/ed25519-2.2.3/LICENSE-APACHE | 201 - .../vendor/ed25519-2.2.3/LICENSE-MIT | 25 - .../vendor/ed25519-2.2.3/README.md | 81 - .../vendor/ed25519-2.2.3/src/hex.rs | 87 - .../vendor/ed25519-2.2.3/src/lib.rs | 419 -- .../vendor/ed25519-2.2.3/src/pkcs8.rs | 356 -- .../vendor/ed25519-2.2.3/src/serde.rs | 121 - .../ed25519-2.2.3/tests/examples/pkcs8-v1.der | Bin 48 -> 0 bytes .../ed25519-2.2.3/tests/examples/pkcs8-v1.pem | 3 - .../ed25519-2.2.3/tests/examples/pkcs8-v2.der | Bin 116 -> 0 bytes .../ed25519-2.2.3/tests/examples/pkcs8-v2.pem | 5 - .../ed25519-2.2.3/tests/examples/pubkey.der | Bin 44 -> 0 bytes .../ed25519-2.2.3/tests/examples/pubkey.pem | 3 - .../vendor/ed25519-2.2.3/tests/hex.rs | 50 - .../vendor/ed25519-2.2.3/tests/pkcs8.rs | 86 - .../vendor/ed25519-2.2.3/tests/serde.rs | 62 - .../ed25519-dalek-2.1.1/.cargo-checksum.json | 1 - .../ed25519-dalek-2.1.1/.cargo_vcs_info.json | 6 - .../vendor/ed25519-dalek-2.1.1/.travis.yml | 33 - .../vendor/ed25519-dalek-2.1.1/CHANGELOG.md | 52 - .../vendor/ed25519-dalek-2.1.1/Cargo.toml | 199 - .../ed25519-dalek-2.1.1/Cargo.toml.orig | 78 - .../vendor/ed25519-dalek-2.1.1/LICENSE | 28 - .../vendor/ed25519-dalek-2.1.1/README.md | 178 - .../benches/ed25519_benchmarks.rs | 100 - .../docs/assets/ed25519-malleability.png | Bin 44136 -> 0 bytes .../assets/rustdoc-include-katex-header.html | 12 - .../vendor/ed25519-dalek-2.1.1/src/batch.rs | 242 - .../ed25519-dalek-2.1.1/src/constants.rs | 32 - .../vendor/ed25519-dalek-2.1.1/src/context.rs | 112 - .../vendor/ed25519-dalek-2.1.1/src/errors.rs | 119 - .../vendor/ed25519-dalek-2.1.1/src/hazmat.rs | 266 -- .../vendor/ed25519-dalek-2.1.1/src/lib.rs | 293 -- .../ed25519-dalek-2.1.1/src/signature.rs | 178 - .../vendor/ed25519-dalek-2.1.1/src/signing.rs | 908 ---- .../ed25519-dalek-2.1.1/src/verifying.rs | 674 --- .../ed25519-dalek-2.1.1/tests/ed25519.rs | 657 --- .../tests/examples/pkcs8-v1.der | Bin 48 -> 0 bytes .../tests/examples/pkcs8-v2.der | Bin 116 -> 0 bytes .../tests/examples/pubkey.der | Bin 44 -> 0 bytes .../vendor/ed25519-dalek-2.1.1/tests/pkcs8.rs | 71 - .../tests/validation_criteria.rs | 231 - .../ed25519-dalek-2.1.1/tests/x25519.rs | 80 - .../.cargo-checksum.json | 1 - .../.cargo_vcs_info.json | 6 - .../.github/workflows/audit.yml | 16 - .../.github/workflows/ci.yml | 82 - .../ed25519-dalek-bip32-0.3.0/.gitignore | 2 - .../ed25519-dalek-bip32-0.3.0/Cargo.toml | 61 - .../ed25519-dalek-bip32-0.3.0/Cargo.toml.orig | 26 - .../ed25519-dalek-bip32-0.3.0/README.md | 9 - .../ed25519-dalek-bip32-0.3.0/src/lib.rs | 452 -- .../vendor/pkcs8-0.10.2/.cargo-checksum.json | 1 - .../vendor/pkcs8-0.10.2/.cargo_vcs_info.json | 6 - .../vendor/pkcs8-0.10.2/CHANGELOG.md | 234 - .../vendor/pkcs8-0.10.2/Cargo.toml | 108 - .../vendor/pkcs8-0.10.2/Cargo.toml.orig | 44 - .../vendor/pkcs8-0.10.2/LICENSE-APACHE | 201 - .../vendor/pkcs8-0.10.2/LICENSE-MIT | 25 - .../vendor/pkcs8-0.10.2/README.md | 94 - .../src/encrypted_private_key_info.rs | 165 - .../vendor/pkcs8-0.10.2/src/error.rs | 93 - .../vendor/pkcs8-0.10.2/src/lib.rs | 111 - .../pkcs8-0.10.2/src/private_key_info.rs | 295 -- .../vendor/pkcs8-0.10.2/src/traits.rs | 140 - .../vendor/pkcs8-0.10.2/src/version.rs | 63 - .../tests/encrypted_private_key.rs | 234 - .../ed25519-encpriv-aes128-pbkdf2-sha1.der | Bin 144 -> 0 bytes .../ed25519-encpriv-aes256-pbkdf2-sha256.der | Bin 158 -> 0 bytes .../ed25519-encpriv-aes256-pbkdf2-sha256.pem | 6 - .../ed25519-encpriv-aes256-scrypt.der | Bin 151 -> 0 bytes .../ed25519-encpriv-aes256-scrypt.pem | 6 - .../ed25519-encpriv-des-pbkdf2-sha256.der | Bin 138 -> 0 bytes .../ed25519-encpriv-des3-pbkdf2-sha256.der | Bin 141 -> 0 bytes .../tests/examples/ed25519-priv-pkcs8v1.der | Bin 48 -> 0 bytes .../tests/examples/ed25519-priv-pkcs8v1.pem | 3 - .../tests/examples/ed25519-priv-pkcs8v2.der | Bin 116 -> 0 bytes .../tests/examples/ed25519-priv-pkcs8v2.pem | 5 - .../tests/examples/ed25519-pub.der | Bin 44 -> 0 bytes .../tests/examples/ed25519-pub.pem | 3 - .../pkcs8-0.10.2/tests/examples/p256-priv.der | Bin 138 -> 0 bytes .../pkcs8-0.10.2/tests/examples/p256-priv.pem | 5 - .../pkcs8-0.10.2/tests/examples/p256-pub.der | Bin 91 -> 0 bytes .../pkcs8-0.10.2/tests/examples/p256-pub.pem | 4 - .../tests/examples/rsa2048-priv.der | Bin 1217 -> 0 bytes .../tests/examples/rsa2048-priv.pem | 28 - .../tests/examples/rsa2048-pub.der | Bin 294 -> 0 bytes .../tests/examples/rsa2048-pub.pem | 9 - .../tests/examples/x25519-priv.der | Bin 48 -> 0 bytes .../tests/examples/x25519-priv.pem | 3 - .../vendor/pkcs8-0.10.2/tests/private_key.rs | 187 - .../vendor/pkcs8-0.10.2/tests/traits.rs | 102 - .../signature-2.2.0/.cargo-checksum.json | 1 - .../signature-2.2.0/.cargo_vcs_info.json | 6 - .../vendor/signature-2.2.0/CHANGELOG.md | 247 - .../vendor/signature-2.2.0/Cargo.toml | 69 - .../vendor/signature-2.2.0/Cargo.toml.orig | 30 - .../vendor/signature-2.2.0/LICENSE-APACHE | 201 - .../vendor/signature-2.2.0/LICENSE-MIT | 25 - .../vendor/signature-2.2.0/README.md | 71 - .../vendor/signature-2.2.0/src/encoding.rs | 31 - .../vendor/signature-2.2.0/src/error.rs | 116 - .../vendor/signature-2.2.0/src/hazmat.rs | 70 - .../vendor/signature-2.2.0/src/keypair.rs | 29 - .../vendor/signature-2.2.0/src/lib.rs | 158 - .../signature-2.2.0/src/prehash_signature.rs | 31 - .../vendor/signature-2.2.0/src/signer.rs | 118 - .../vendor/signature-2.2.0/src/verifier.rs | 41 - .../vendor/signature-2.2.0/tests/derive.rs | 82 - .../vendor/spki-0.7.3/.cargo-checksum.json | 1 - .../vendor/spki-0.7.3/.cargo_vcs_info.json | 6 - .../vendor/spki-0.7.3/CHANGELOG.md | 152 - .../vendor/spki-0.7.3/Cargo.toml | 87 - .../vendor/spki-0.7.3/Cargo.toml.orig | 40 - .../vendor/spki-0.7.3/LICENSE-APACHE | 201 - .../vendor/spki-0.7.3/LICENSE-MIT | 25 - .../vendor/spki-0.7.3/README.md | 56 - .../vendor/spki-0.7.3/src/algorithm.rs | 194 - .../vendor/spki-0.7.3/src/error.rs | 68 - .../vendor/spki-0.7.3/src/fingerprint.rs | 42 - .../vendor/spki-0.7.3/src/lib.rs | 71 - .../vendor/spki-0.7.3/src/spki.rs | 217 - .../vendor/spki-0.7.3/src/traits.rs | 184 - .../spki-0.7.3/tests/examples/ed25519-pub.der | Bin 44 -> 0 bytes .../spki-0.7.3/tests/examples/ed25519-pub.pem | 3 - .../spki-0.7.3/tests/examples/p256-pub.der | Bin 91 -> 0 bytes .../spki-0.7.3/tests/examples/p256-pub.pem | 4 - .../spki-0.7.3/tests/examples/rsa2048-pub.der | Bin 294 -> 0 bytes .../spki-0.7.3/tests/examples/rsa2048-pub.pem | 9 - .../vendor/spki-0.7.3/tests/spki.rs | 161 - .../vendor/spki-0.7.3/tests/traits.rs | 102 - third_party/rust/const_oid/v0_9/BUILD.gn | 40 - .../rust/const_oid/v0_9/README.chromium | 12 - third_party/rust/der/v0_7/BUILD.gn | 96 - third_party/rust/der/v0_7/README.chromium | 12 - .../rust/derivation_path/v0_2/BUILD.gn | 33 - .../rust/derivation_path/v0_2/README.chromium | 9 - third_party/rust/ed25519/v2/BUILD.gn | 44 - third_party/rust/ed25519/v2/README.chromium | 12 - third_party/rust/ed25519_dalek/v2/BUILD.gn | 56 - .../rust/ed25519_dalek/v2/README.chromium | 9 - .../rust/ed25519_dalek_bip32/v0_3/BUILD.gn | 38 - .../ed25519_dalek_bip32/v0_3/README.chromium | 9 - third_party/rust/pkcs8/v0_10/BUILD.gn | 46 - third_party/rust/pkcs8/v0_10/README.chromium | 12 - third_party/rust/signature/v2/BUILD.gn | 46 - third_party/rust/signature/v2/README.chromium | 9 - third_party/rust/spki/v0_7/BUILD.gn | 47 - third_party/rust/spki/v0_7/README.chromium | 11 - 285 files changed, 36575 deletions(-) delete mode 100644 third_party/rust/base64ct/v1/BUILD.gn delete mode 100644 third_party/rust/base64ct/v1/README.chromium delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/CHANGELOG.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-APACHE delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-MIT delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/benches/mod.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/bcrypt.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/crypt.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/shacrypt.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/standard.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/url.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/decoder.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoder.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoding.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/errors.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/line_ending.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/test_vectors.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/bcrypt.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/common/mod.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/crypt.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/proptests.proptest-regressions delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/proptests.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/shacrypt.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/standard.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/url.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/CHANGELOG.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-APACHE delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-MIT delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/arcs.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/checked.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db/gen.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/encoder.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/error.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/parser.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/tests/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/CHANGELOG.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-APACHE delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-MIT delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/arrayvec.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/any.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bit_string.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bmp_string.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/boolean.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/choice.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/context_specific.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/generalized_time.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/ia5_string.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/int.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/uint.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/internal_macros.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/null.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/octet_string.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/oid.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/optional.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/printable_string.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/real.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence_of.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/set_of.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/teletex_string.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utc_time.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utf8_string.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/videotex_string.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_owned.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_ref.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/datetime.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/decode.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/document.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode_ref.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/error.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/header.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/length.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/ord.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/nested.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/pem.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/slice.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/referenced.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_owned.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_ref.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/class.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/mode.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/number.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/pem.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/slice.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/datetime.proptest-regressions delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/datetime.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/derive.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/examples/spki.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/examples/spki.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/pem.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/set_of.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.github/workflows/audit.yml delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.github/workflows/ci.yml delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.gitignore delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/CHANGELOG.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-APACHE delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-MIT delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/hex.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/pkcs8.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/serde.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v1.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v1.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v2.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v2.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pubkey.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pubkey.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/hex.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/pkcs8.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/serde.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.travis.yml delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/CHANGELOG.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/LICENSE delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/benches/ed25519_benchmarks.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/docs/assets/ed25519-malleability.png delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/docs/assets/rustdoc-include-katex-header.html delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/batch.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/constants.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/context.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/errors.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/hazmat.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signature.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signing.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/verifying.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/ed25519.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pkcs8-v1.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pkcs8-v2.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pubkey.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/pkcs8.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/validation_criteria.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/x25519.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.github/workflows/audit.yml delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.github/workflows/ci.yml delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.gitignore delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/CHANGELOG.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-APACHE delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-MIT delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/encrypted_private_key_info.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/error.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/private_key_info.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/traits.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/version.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/encrypted_private_key.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes128-pbkdf2-sha1.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-pbkdf2-sha256.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-pbkdf2-sha256.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-scrypt.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-scrypt.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-des-pbkdf2-sha256.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-des3-pbkdf2-sha256.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-priv-pkcs8v1.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-priv-pkcs8v1.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-priv-pkcs8v2.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-priv-pkcs8v2.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-pub.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-pub.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/p256-priv.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/p256-priv.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/p256-pub.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/p256-pub.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-priv.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-priv.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-pub.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-pub.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/x25519-priv.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/x25519-priv.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/private_key.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/traits.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/CHANGELOG.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-APACHE delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-MIT delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/encoding.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/error.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/hazmat.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/keypair.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/prehash_signature.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/signer.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/verifier.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/signature-2.2.0/tests/derive.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/.cargo-checksum.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/.cargo_vcs_info.json delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/CHANGELOG.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/Cargo.toml delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/Cargo.toml.orig delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-APACHE delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-MIT delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/README.md delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/algorithm.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/error.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/fingerprint.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/lib.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/spki.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/traits.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/ed25519-pub.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/ed25519-pub.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/p256-pub.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/p256-pub.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/rsa2048-pub.der delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/rsa2048-pub.pem delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/spki.rs delete mode 100644 third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/traits.rs delete mode 100644 third_party/rust/const_oid/v0_9/BUILD.gn delete mode 100644 third_party/rust/const_oid/v0_9/README.chromium delete mode 100644 third_party/rust/der/v0_7/BUILD.gn delete mode 100644 third_party/rust/der/v0_7/README.chromium delete mode 100644 third_party/rust/derivation_path/v0_2/BUILD.gn delete mode 100644 third_party/rust/derivation_path/v0_2/README.chromium delete mode 100644 third_party/rust/ed25519/v2/BUILD.gn delete mode 100644 third_party/rust/ed25519/v2/README.chromium delete mode 100644 third_party/rust/ed25519_dalek/v2/BUILD.gn delete mode 100644 third_party/rust/ed25519_dalek/v2/README.chromium delete mode 100644 third_party/rust/ed25519_dalek_bip32/v0_3/BUILD.gn delete mode 100644 third_party/rust/ed25519_dalek_bip32/v0_3/README.chromium delete mode 100644 third_party/rust/pkcs8/v0_10/BUILD.gn delete mode 100644 third_party/rust/pkcs8/v0_10/README.chromium delete mode 100644 third_party/rust/signature/v2/BUILD.gn delete mode 100644 third_party/rust/signature/v2/README.chromium delete mode 100644 third_party/rust/spki/v0_7/BUILD.gn delete mode 100644 third_party/rust/spki/v0_7/README.chromium diff --git a/components/brave_wallet/rust/BUILD.gn b/components/brave_wallet/rust/BUILD.gn index edd1bbbc7ca7..66c3d173e419 100644 --- a/components/brave_wallet/rust/BUILD.gn +++ b/components/brave_wallet/rust/BUILD.gn @@ -15,6 +15,5 @@ rust_static_library("rust_lib") { deps = [ "//brave/third_party/rust/bech32/v0_9:lib", "//brave/third_party/rust/curve25519_dalek/v4:lib", - "//brave/third_party/rust/ed25519_dalek_bip32/v0_3:lib", ] } diff --git a/components/brave_wallet/rust/Cargo.toml b/components/brave_wallet/rust/Cargo.toml index 0d5cb009ca6c..9272f4eb9fb8 100644 --- a/components/brave_wallet/rust/Cargo.toml +++ b/components/brave_wallet/rust/Cargo.toml @@ -8,7 +8,6 @@ license = "MPL-2.0" [dependencies] cxx = { version = "1.0", features = [ "alloc", "std" ] } -ed25519-dalek-bip32 = "0.3.0" curve25519-dalek = "4.1.3" bech32 = "0.9.1" diff --git a/components/brave_wallet/rust/lib.rs b/components/brave_wallet/rust/lib.rs index 8fdd2f987045..9d188ead054c 100644 --- a/components/brave_wallet/rust/lib.rs +++ b/components/brave_wallet/rust/lib.rs @@ -6,15 +6,6 @@ use bech32::Error as Bech32Error; use bech32::FromBase32; use core::fmt; -use ed25519_dalek_bip32::derivation_path::{ - ChildIndexError, DerivationPath, DerivationPathParseError, -}; -use ed25519_dalek_bip32::ed25519_dalek::{ - Signature, SignatureError, Signer, SigningKey, KEYPAIR_LENGTH, PUBLIC_KEY_LENGTH, - SECRET_KEY_LENGTH, SIGNATURE_LENGTH, -}; -use ed25519_dalek_bip32::Error as Ed25519Bip32Error; -use ed25519_dalek_bip32::{ChildIndex, ExtendedSigningKey}; use ffi::Bech32DecodeVariant; #[macro_export] @@ -71,65 +62,16 @@ mod ffi { } extern "Rust" { - type Ed25519DalekExtendedSecretKey; - type Ed25519DalekSignature; type Bech32DecodeValue; - - type Ed25519DalekExtendedSecretKeyResult; - type Ed25519DalekSignatureResult; - type Ed25519DalekVerificationResult; type Bech32DecodeResult; - fn generate_ed25519_extended_secret_key_from_seed( - bytes: &[u8], - ) -> Box; - - fn generate_ed25519_extended_secret_key_from_bytes( - bytes: &[u8], - ) -> Box; - fn bytes_are_curve25519_point(bytes: &[u8]) -> bool; - fn derive( - self: &Ed25519DalekExtendedSecretKey, - path: String, - ) -> Box; - fn derive_hardened_child( - self: &Ed25519DalekExtendedSecretKey, - index: u32, - ) -> Box; - fn keypair_raw(self: &Ed25519DalekExtendedSecretKey) -> [u8; 64]; - fn secret_key_raw(self: &Ed25519DalekExtendedSecretKey) -> [u8; 32]; - fn public_key_raw(self: &Ed25519DalekExtendedSecretKey) -> [u8; 32]; - fn sign( - self: &Ed25519DalekExtendedSecretKey, - msg: &[u8], - ) -> Box; - fn verify( - self: &Ed25519DalekExtendedSecretKey, - msg: &[u8], - sig: &[u8], - ) -> Box; - - fn to_bytes(self: &Ed25519DalekSignature) -> [u8; 64]; - fn data(self: &Bech32DecodeValue) -> Vec; fn hrp(self: &Bech32DecodeValue) -> String; fn variant(self: &Bech32DecodeValue) -> Bech32DecodeVariant; fn decode_bech32(input: &str) -> Box; - - fn is_ok(self: &Ed25519DalekExtendedSecretKeyResult) -> bool; - fn error_message(self: &Ed25519DalekExtendedSecretKeyResult) -> String; - fn unwrap(self: &Ed25519DalekExtendedSecretKeyResult) -> &Ed25519DalekExtendedSecretKey; - - fn is_ok(self: &Ed25519DalekSignatureResult) -> bool; - fn error_message(self: &Ed25519DalekSignatureResult) -> String; - fn unwrap(self: &Ed25519DalekSignatureResult) -> &Ed25519DalekSignature; - - fn is_ok(self: &Ed25519DalekVerificationResult) -> bool; - fn error_message(self: &Ed25519DalekVerificationResult) -> String; - fn is_ok(self: &Bech32DecodeResult) -> bool; fn error_message(self: &Bech32DecodeResult) -> String; fn unwrap(self: &Bech32DecodeResult) -> &Bech32DecodeValue; @@ -138,27 +80,15 @@ mod ffi { #[derive(Debug)] pub enum Error { - Ed25519Bip32(Ed25519Bip32Error), - DerivationPathParse(DerivationPathParseError), - ChildIndex(ChildIndexError), - Signature(SignatureError), Bech32(Bech32Error), KeyLengthMismatch, } -impl_error!(Ed25519Bip32Error, Ed25519Bip32); -impl_error!(DerivationPathParseError, DerivationPathParse); -impl_error!(ChildIndexError, ChildIndex); -impl_error!(SignatureError, Signature); impl_error!(Bech32Error, Bech32); impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self { - Error::Ed25519Bip32(e) => write!(f, "Error: {}", e.to_string()), - Error::DerivationPathParse(e) => write!(f, "Error: {}", e.to_string()), - Error::ChildIndex(e) => write!(f, "Error: {}", e.to_string()), - Error::Signature(e) => write!(f, "Error: {}", e.to_string()), Error::Bech32(e) => write!(f, "Error: {}", e.to_string()), Error::KeyLengthMismatch => { write!(f, "Error: raw key bytes were not the expected length") @@ -173,20 +103,9 @@ pub struct Bech32Decoded { } pub struct Bech32DecodeValue(Bech32Decoded); -pub struct Ed25519DalekExtendedSecretKey(ExtendedSigningKey); -pub struct Ed25519DalekSignature(Signature); -struct Ed25519DalekExtendedSecretKeyResult(Result); -struct Ed25519DalekSignatureResult(Result); -struct Ed25519DalekVerificationResult(Result<(), Error>); struct Bech32DecodeResult(Result); -impl_result!( - Ed25519DalekExtendedSecretKey, - Ed25519DalekExtendedSecretKeyResult, - ExtendedSigningKey -); -impl_result!(Ed25519DalekSignature, Ed25519DalekSignatureResult, Signature); impl_result!(Bech32DecodeValue, Bech32DecodeResult, Bech32Decoded); impl From for Bech32DecodeVariant { @@ -198,57 +117,6 @@ impl From for Bech32DecodeVariant { } } -impl Ed25519DalekVerificationResult { - fn error_message(&self) -> String { - match &self.0 { - Err(e) => e.to_string(), - Ok(_) => "".to_string(), - } - } - - fn is_ok(&self) -> bool { - match &self.0 { - Err(_) => false, - Ok(_) => true, - } - } -} - -impl From> for Ed25519DalekVerificationResult { - fn from(result: Result<(), Error>) -> Self { - match result { - Ok(v) => Self(Ok(v)), - Err(e) => Self(Err(e)), - } - } -} - -fn generate_ed25519_extended_secret_key_from_seed( - bytes: &[u8], -) -> Box { - Box::new(Ed25519DalekExtendedSecretKeyResult::from( - ExtendedSigningKey::from_seed(bytes).map_err(Error::from), - )) -} - -fn generate_ed25519_extended_secret_key_from_bytes( - bytes: &[u8], -) -> Box { - let key_result = match bytes.try_into() { - Err(_) => Err(Error::KeyLengthMismatch), - Ok(array) => { - let signing_key = SigningKey::from_bytes(array); - Ok(ExtendedSigningKey { - depth: 0, - child_index: ChildIndex::Normal(0), - signing_key, - chain_code: [0; 32], - }) - } - }; - Box::new(Ed25519DalekExtendedSecretKeyResult::from(key_result)) -} - fn bytes_are_curve25519_point(bytes: &[u8]) -> bool { match curve25519_dalek::edwards::CompressedEdwardsY::from_slice(bytes) { // If the y coordinate decompresses, it represents a curve point. @@ -278,56 +146,6 @@ fn decode_bech32(input: &str) -> Box { } } -impl Ed25519DalekExtendedSecretKey { - fn derive(&self, path: String) -> Box { - Box::new(Ed25519DalekExtendedSecretKeyResult::from( - path.parse::() - .map_err(|err| Error::from(err)) - .and_then(|d_path| Ok(self.0.derive(&d_path)?)), - )) - } - fn derive_hardened_child(&self, index: u32) -> Box { - Box::new(Ed25519DalekExtendedSecretKeyResult::from( - ChildIndex::hardened(index) - .map_err(|err| Error::from(err)) - .and_then(|child_index| Ok(self.0.derive_child(child_index)?)), - )) - } - fn keypair_raw(&self) -> [u8; KEYPAIR_LENGTH] { - self.0.signing_key.to_keypair_bytes() - } - fn secret_key_raw(&self) -> [u8; SECRET_KEY_LENGTH] { - self.0.signing_key.to_bytes() - } - fn public_key_raw(&self) -> [u8; PUBLIC_KEY_LENGTH] { - self.0.verifying_key().to_bytes() - } - - fn sign(self: &Ed25519DalekExtendedSecretKey, msg: &[u8]) -> Box { - Box::new(Ed25519DalekSignatureResult::from( - self.0.signing_key.try_sign(msg).map_err(Error::from), - )) - } - - fn verify( - self: &Ed25519DalekExtendedSecretKey, - msg: &[u8], - sig: &[u8], - ) -> Box { - let sig_result = match Signature::from_slice(sig) { - Ok(signature) => self.0.signing_key.verify(msg, &signature).map_err(Error::from), - Err(e) => Err(Error::from(e)), - }; - Box::new(Ed25519DalekVerificationResult::from(sig_result)) - } -} - -impl Ed25519DalekSignature { - fn to_bytes(self: &Ed25519DalekSignature) -> [u8; SIGNATURE_LENGTH] { - self.0.to_bytes() - } -} - impl Bech32DecodeValue { fn hrp(self: &Bech32DecodeValue) -> String { self.0.hrp.clone() diff --git a/third_party/rust/base64ct/v1/BUILD.gn b/third_party/rust/base64ct/v1/BUILD.gn deleted file mode 100644 index b12df1fbd307..000000000000 --- a/third_party/rust/base64ct/v1/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "base64ct" - epoch = "1" - crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/lib.rs" - sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/bcrypt.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/crypt.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/shacrypt.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/standard.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/url.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/decoder.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoder.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoding.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/errors.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/line_ending.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/test_vectors.rs", - ] - inputs = [ "//brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/../README.md" ] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "1.6.0" - cargo_pkg_authors = "RustCrypto Developers" - cargo_pkg_name = "base64ct" - cargo_pkg_description = "Pure Rust implementation of Base64 (RFC 4648) which avoids any usages of data-dependent branches/LUTs and thereby provides portable \"best effort\" constant-time operation and embedded-friendly no_std support" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - features = [ "alloc" ] -} diff --git a/third_party/rust/base64ct/v1/README.chromium b/third_party/rust/base64ct/v1/README.chromium deleted file mode 100644 index 46bbf52c3f47..000000000000 --- a/third_party/rust/base64ct/v1/README.chromium +++ /dev/null @@ -1,12 +0,0 @@ -Name: base64ct -URL: https://crates.io/crates/base64ct -Description: Pure Rust implementation of Base64 (RFC 4648) which avoids any usages of -data-dependent branches/LUTs and thereby provides portable "best effort" -constant-time operation and embedded-friendly no_std support - -Version: 1.6.0 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-APACHE -Revision: 084b09a7a694009a6f3d66e3ed5e11ca4fd2ac80 diff --git a/third_party/rust/chromium_crates_io/Cargo.lock b/third_party/rust/chromium_crates_io/Cargo.lock index cf1e12a92442..f0f079478d02 100644 --- a/third_party/rust/chromium_crates_io/Cargo.lock +++ b/third_party/rust/chromium_crates_io/Cargo.lock @@ -147,11 +147,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "base64" version = "0.13.1" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bech32" version = "0.9.1" @@ -281,7 +276,6 @@ dependencies = [ "bech32", "curve25519-dalek", "cxx", - "ed25519-dalek-bip32", ] [[package]] @@ -430,11 +424,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "constant_time_eq" version = "0.2.5" @@ -620,15 +609,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "deranged" version = "0.3.11" @@ -637,11 +617,6 @@ dependencies = [ "powerfmt", ] -[[package]] -name = "derivation-path" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "derive_more" version = "0.99.17" @@ -685,40 +660,6 @@ dependencies = [ "dtoa", ] -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "pkcs8", - "signature", -] - -[[package]] -name = "ed25519-dalek" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "curve25519-dalek", - "ed25519", - "rand_core 0.6.4", - "serde", - "sha2 0.10.8", - "subtle", - "zeroize", -] - -[[package]] -name = "ed25519-dalek-bip32" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "derivation-path", - "ed25519-dalek", - "hmac 0.12.1", - "sha2 0.10.8", -] - [[package]] name = "either" version = "1.8.1" @@ -1812,15 +1753,6 @@ name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "der", - "spki", -] - [[package]] name = "poly1305" version = "0.8.0" @@ -2238,14 +2170,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.6.4", -] - [[package]] name = "siphasher" version = "0.3.10" @@ -2330,15 +2254,6 @@ name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "sta-rs" version = "0.3.0" diff --git a/third_party/rust/chromium_crates_io/gnrt_config.toml b/third_party/rust/chromium_crates_io/gnrt_config.toml index d66b0280bcfd..1fd5dcee4684 100644 --- a/third_party/rust/chromium_crates_io/gnrt_config.toml +++ b/third_party/rust/chromium_crates_io/gnrt_config.toml @@ -105,9 +105,6 @@ license_files = ['LICENCE'] [crate.arrayref] license_files = ['LICENSE'] -[crate.base64ct] -extra_input_roots = [ "../README.md" ] - [crate.bitvec] extra_input_roots = ['../doc', '../README.md' ] license_files = ['LICENSE.txt'] @@ -115,9 +112,6 @@ license_files = ['LICENSE.txt'] [crate.cid] license_files = ['LICENSE'] -[crate.const-oid] -extra_input_roots = [ "../README.md" ] - [crate.cbor4ii] extra_input_roots = [ "../README.md" ] @@ -173,21 +167,9 @@ extra_input_roots = [ "../README.md" ] [crate.deranged] license_files = ['LICENSE-Apache'] -[crate.der] -extra_input_roots = [ "../README.md" ] - -[crate.derivation-path] -license_files = ['../../../../../common/licenses/Apache-2.0'] - [crate.dtoa-short] license_files = ['LICENSE'] -[crate.ed25519] -extra_input_roots = [ "../README.md" ] - -[crate.ed25519-dalek-bip32] -license_files = ['../../../../../common/licenses/Apache-2.0'] - [crate.encoding_rs] license_files = ['LICENSE-APACHE'] @@ -308,9 +290,6 @@ license_files = ['LICENSE-Apache'] [crate.num-traits] extra_kv = { rustflags = [ "--cfg", "has_i128", "--cfg", "has_to_int_unchecked", "--cfg", "has_reverse_bits", "--cfg", "has_leading_trailing_ones", "--cfg", "has_int_assignop_ref", "--cfg", "has_div_euclid", "--cfg", "has_copysign" ] } -[crate.pkcs8] -extra_input_roots = [ "../README.md" ] - [crate.powerfmt] license_files = ['LICENSE-Apache'] @@ -353,15 +332,9 @@ license_files = ['../../../../../common/licenses/Apache-2.0'] [crate.servo_arc] license_files = ['../../../../../common/licenses/Apache-2.0'] -[crate.signature] -extra_input_roots = [ "../README.md" ] - [crate.siphasher] license_files = ['../../../../../common/licenses/Apache-2.0'] -[crate.spki] -extra_input_roots = [ "../README.md" ] - [crate.sta-rs] license_files = ['LICENSE'] diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/.cargo_vcs_info.json deleted file mode 100644 index ecd2e9ca9a18..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "084b09a7a694009a6f3d66e3ed5e11ca4fd2ac80" - }, - "path_in_vcs": "base64ct" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/CHANGELOG.md b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/CHANGELOG.md deleted file mode 100644 index 73d4ddd9a5db..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/CHANGELOG.md +++ /dev/null @@ -1,148 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## 1.6.0 (2023-02-26) -### Changed -- MSRV 1.60 ([#802]) -- Lint improvements ([#824]) - -[#802]: https://github.com/RustCrypto/formats/pull/802 -[#824]: https://github.com/RustCrypto/formats/pull/824 - -## 1.5.3 (2022-10-18) -### Added -- `Base64ShaCrypt` alphabet ([#742]) - -### Changed -- Use `RangeInclusive` for `DecodeStep` ([#713]) - -[#713]: https://github.com/RustCrypto/formats/pull/713 -[#742]: https://github.com/RustCrypto/formats/pull/742 - -## 1.5.2 (2022-08-22) -### Fixed -- Return `Ok(0)` in `io::Read` impl to signal end of stream ([#704]) - -[#704]: https://github.com/RustCrypto/formats/pull/704 - -## 1.5.1 (2022-06-26) -### Fixed -- Last block validation ([#680]) - -[#680]: https://github.com/RustCrypto/formats/pull/680 - -## 1.5.0 (2022-03-29) -### Fixed -- Ensure checked arithmetic with `clippy::integer_arithmetic` lint ([#557]) -- Prevent foreign impls of `Encoding` by bounding sealed `Variant` trait ([#562]) - -[#557]: https://github.com/RustCrypto/formats/pull/557 -[#562]: https://github.com/RustCrypto/formats/pull/562 - -## 1.4.1 (2022-03-11) -### Changed -- Rename `Decoder::decoded_len` => `::remaining_len` ([#500]) - -[#500]: https://github.com/RustCrypto/formats/pull/500 - -## 1.4.0 (2022-03-10) [YANKED] -### Added -- Buffered `Encoder` type ([#366], [#455], [#457]) -- `Decoder::decoded_len` method ([#403]) -- Impl `std::io::Read` for `Decoder` ([#404]) -- Bounds for `Encoding`/`Variant` ZSTs ([#405], [#408]) - -[#366]: https://github.com/RustCrypto/formats/pull/366 -[#403]: https://github.com/RustCrypto/formats/pull/403 -[#404]: https://github.com/RustCrypto/formats/pull/404 -[#405]: https://github.com/RustCrypto/formats/pull/405 -[#408]: https://github.com/RustCrypto/formats/pull/408 -[#455]: https://github.com/RustCrypto/formats/pull/455 -[#457]: https://github.com/RustCrypto/formats/pull/457 - -## 1.3.3 (2021-12-28) -### Fixed -- Potential infinite loop in `Decoder::decode` ([#305]) - -[#305]: https://github.com/RustCrypto/formats/pull/305 - -## 1.3.2 (2021-12-26) [YANKED] -### Fixed -- `Decoder` unpadding ([#299]) -- Edge case when using `Decoder::new_wrapped` ([#300]) - -[#299]: https://github.com/RustCrypto/formats/pull/299 -[#300]: https://github.com/RustCrypto/formats/pull/300 - -## 1.3.1 (2021-12-20) [YANKED] -### Added -- `Decoder::new_wrapped` with support for line-wrapped Base64 ([#292], [#293], [#294]) - -[#292]: https://github.com/RustCrypto/formats/pull/292 -[#293]: https://github.com/RustCrypto/formats/pull/292 -[#294]: https://github.com/RustCrypto/formats/pull/294 - -## 1.3.0 (2021-12-02) [YANKED] -### Added -- Stateful `Decoder` type ([#266]) - -[#266]: https://github.com/RustCrypto/formats/pull/266 - -## 1.2.0 (2021-11-03) -### Changed -- Rust 2021 edition upgrade; MSRV 1.56 ([#136]) - -### Fixed -- Benchmarks ([#135]) - -[#135]: https://github.com/RustCrypto/formats/pull/135 -[#136]: https://github.com/RustCrypto/formats/pull/136 - -## 1.1.1 (2021-10-14) -### Changed -- Update `Util::Lookup` paper references ([#32]) - -[#32]: https://github.com/RustCrypto/formats/pull/32 - -## 1.1.0 (2021-09-14) -### Changed -- Moved to `formats` repo; MSRV 1.51+ ([#2]) - -[#2]: https://github.com/RustCrypto/formats/pull/2 - -## 1.0.1 (2021-08-14) -### Fixed -- Make `Encoding::decode` reject invalid padding - -## 1.0.0 (2021-03-17) -### Changed -- Bump MSRV to 1.47+ - -### Fixed -- MSRV-dependent TODOs in implementation - -## 0.2.1 (2021-03-07) -### Fixed -- MSRV docs - -## 0.2.0 (2021-02-01) -### Changed -- Refactor with `Encoding` trait -- Internal refactoring - -## 0.1.2 (2021-01-31) -### Added -- bcrypt encoding -- `crypt(3)` encoding - -### Changed -- Internal refactoring - -## 0.1.1 (2021-01-27) -- Minor code improvements - -## 0.1.0 (2021-01-26) -- Initial release diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/Cargo.toml deleted file mode 100644 index 6cf4e32c254e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/Cargo.toml +++ /dev/null @@ -1,55 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -rust-version = "1.60" -name = "base64ct" -version = "1.6.0" -authors = ["RustCrypto Developers"] -description = """ -Pure Rust implementation of Base64 (RFC 4648) which avoids any usages of -data-dependent branches/LUTs and thereby provides portable \"best effort\" -constant-time operation and embedded-friendly no_std support -""" -documentation = "https://docs.rs/base64ct" -readme = "README.md" -keywords = [ - "crypto", - "base64", - "pem", - "phc", -] -categories = [ - "cryptography", - "encoding", - "no-std", - "parser-implementations", -] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/formats/tree/master/base64ct" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = [ - "--cfg", - "docsrs", -] - -[dev-dependencies.base64] -version = "0.21" - -[dev-dependencies.proptest] -version = "1" - -[features] -alloc = [] -std = ["alloc"] diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/Cargo.toml.orig deleted file mode 100644 index d8c6cf890602..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/Cargo.toml.orig +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "base64ct" -version = "1.6.0" -description = """ -Pure Rust implementation of Base64 (RFC 4648) which avoids any usages of -data-dependent branches/LUTs and thereby provides portable "best effort" -constant-time operation and embedded-friendly no_std support -""" -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" -documentation = "https://docs.rs/base64ct" -repository = "https://github.com/RustCrypto/formats/tree/master/base64ct" -categories = ["cryptography", "encoding", "no-std", "parser-implementations"] -keywords = ["crypto", "base64", "pem", "phc"] -readme = "README.md" -edition = "2021" -rust-version = "1.60" - -[dev-dependencies] -base64 = "0.21" -proptest = "1" - -[features] -alloc = [] -std = ["alloc"] - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-APACHE b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-APACHE deleted file mode 100644 index 78173fa2e753..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - 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. diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-MIT b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-MIT deleted file mode 100644 index da278e6844d5..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/LICENSE-MIT +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com) -Copyright (c) 2021 The RustCrypto Project Developers - -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. diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/README.md b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/README.md deleted file mode 100644 index b808f43096e5..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# [RustCrypto]: Constant-Time Base64 - -[![crate][crate-image]][crate-link] -[![Docs][docs-image]][docs-link] -[![Build Status][build-image]][build-link] -![Apache2/MIT licensed][license-image] -![Rust Version][rustc-image] -[![Project Chat][chat-image]][chat-link] - -Pure Rust implementation of Base64 ([RFC 4648]). - -Implements multiple Base64 alphabets without data-dependent branches or lookup -tables, thereby providing portable "best effort" constant-time operation. - -Supports `no_std` environments and avoids heap allocations in the core API -(but also provides optional `alloc` support for convenience). - -[Documentation][docs-link] - -## About - -This crate implements several Base64 alphabets in constant-time for sidechannel -resistance, aimed at purposes like encoding/decoding the "PEM" format used to -store things like cryptographic private keys (i.e. in the [`pem-rfc7468`] crate). - -The paper [Util::Lookup: Exploiting key decoding in cryptographic libraries][Util::Lookup] -demonstrates how the leakage from non-constant-time Base64 parsers can be used -to practically extract RSA private keys from SGX enclaves. - -The padded variants require (`=`) padding. Unpadded variants expressly -reject such padding. - -Whitespace is expressly disallowed, with the exception of the -[`Decoder::new_wrapped`] and [`Encoder::new_wrapped`] modes which provide -fixed-width line wrapping. - -## Supported Base64 variants - -- Standard Base64: `[A-Z]`, `[a-z]`, `[0-9]`, `+`, `/` -- URL-safe Base64: `[A-Z]`, `[a-z]`, `[0-9]`, `-`, `_` -- bcrypt Base64: `.`, `/`, `[A-Z]`, `[a-z]`, `[0-9]` -- `crypt(3)` Base64: `.`, `-`, `[0-9]`, `[A-Z]`, `[a-z]` - -## Minimum Supported Rust Version - -This crate requires **Rust 1.60** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - -## License - -Licensed under either of: - - * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) - * [MIT license](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. - -[//]: # (badges) - -[crate-image]: https://buildstats.info/crate/base64ct -[crate-link]: https://crates.io/crates/base64ct -[docs-image]: https://docs.rs/base64ct/badge.svg -[docs-link]: https://docs.rs/base64ct/ -[build-image]: https://github.com/RustCrypto/formats/actions/workflows/base64ct.yml/badge.svg -[build-link]: https://github.com/RustCrypto/formats/actions/workflows/base64ct.yml -[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.60+-blue.svg -[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg -[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/300570-formats - -[//]: # (links) - -[RustCrypto]: https://github.com/rustcrypto -[RFC 4648]: https://tools.ietf.org/html/rfc4648 -[`pem-rfc7468`]: https://github.com/RustCrypto/formats/tree/master/pem-rfc7468 -[Util::Lookup]: https://arxiv.org/pdf/2108.04600.pdf -[`Decoder::new_wrapped`]: https://docs.rs/base64ct/latest/base64ct/struct.Decoder.html#method.new_wrapped -[`Encoder::new_wrapped`]: https://docs.rs/base64ct/latest/base64ct/struct.Encoder.html#method.new_wrapped diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/benches/mod.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/benches/mod.rs deleted file mode 100644 index 4d1b8c65b4a7..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/benches/mod.rs +++ /dev/null @@ -1,62 +0,0 @@ -//! `base64ct` benchmarks - -#![feature(test)] -extern crate test; - -use base64ct::{Base64Unpadded, Encoding}; -use test::Bencher; - -const B64_LEN: usize = 100_002; -const RAW_LEN: usize = (3 * B64_LEN) / 4; - -#[inline(never)] -fn get_raw_data() -> Vec { - (0..RAW_LEN).map(|i| i as u8).collect() -} - -#[inline(never)] -fn get_b64_data() -> String { - (0..B64_LEN) - .map(|i| match (i % 64) as u8 { - v @ 0..=25 => (v + 'A' as u8) as char, - v @ 26..=51 => (v - 26 + 'a' as u8) as char, - v @ 52..=61 => (v - 52 + '0' as u8) as char, - 62 => '+', - _ => '/', - }) - .collect() -} - -#[bench] -fn decode_bench(b: &mut Bencher) { - let b64_data = get_b64_data(); - let mut buf = get_raw_data(); - b.iter(|| { - let out = Base64Unpadded::decode(&b64_data, &mut buf).unwrap(); - test::black_box(out); - }); - b.bytes = RAW_LEN as u64; -} - -#[bench] -fn decode_in_place_bench(b: &mut Bencher) { - let mut b64_data = get_b64_data().into_bytes(); - b.iter(|| { - // since it works on the same buffer over and over, - // almost always `out` will be an error - let out = Base64Unpadded::decode_in_place(&mut b64_data); - let _ = test::black_box(out); - }); - b.bytes = RAW_LEN as u64; -} - -#[bench] -fn encode_bench(b: &mut Bencher) { - let mut buf = get_b64_data().into_bytes(); - let raw_data = get_raw_data(); - b.iter(|| { - let out = Base64Unpadded::encode(&raw_data, &mut buf).unwrap(); - test::black_box(out); - }); - b.bytes = RAW_LEN as u64; -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet.rs deleted file mode 100644 index d888e72e71c9..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet.rs +++ /dev/null @@ -1,124 +0,0 @@ -//! Base64 alphabets. - -// TODO(tarcieri): explicitly checked/wrapped arithmetic -#![allow(clippy::integer_arithmetic)] - -use core::{fmt::Debug, ops::RangeInclusive}; - -pub mod bcrypt; -pub mod crypt; -pub mod shacrypt; -pub mod standard; -pub mod url; - -/// Core encoder/decoder functions for a particular Base64 alphabet. -pub trait Alphabet: 'static + Copy + Debug + Eq + Send + Sized + Sync { - /// First character in this Base64 alphabet. - const BASE: u8; - - /// Decoder passes - const DECODER: &'static [DecodeStep]; - - /// Encoder passes - const ENCODER: &'static [EncodeStep]; - - /// Is this encoding padded? - const PADDED: bool; - - /// Unpadded equivalent of this alphabet. - /// - /// For alphabets that are unpadded to begin with, this should be `Self`. - type Unpadded: Alphabet; - - /// Decode 3 bytes of a Base64 message. - #[inline(always)] - fn decode_3bytes(src: &[u8], dst: &mut [u8]) -> i16 { - debug_assert_eq!(src.len(), 4); - debug_assert!(dst.len() >= 3, "dst too short: {}", dst.len()); - - let c0 = Self::decode_6bits(src[0]); - let c1 = Self::decode_6bits(src[1]); - let c2 = Self::decode_6bits(src[2]); - let c3 = Self::decode_6bits(src[3]); - - dst[0] = ((c0 << 2) | (c1 >> 4)) as u8; - dst[1] = ((c1 << 4) | (c2 >> 2)) as u8; - dst[2] = ((c2 << 6) | c3) as u8; - - ((c0 | c1 | c2 | c3) >> 8) & 1 - } - - /// Decode 6-bits of a Base64 message. - fn decode_6bits(src: u8) -> i16 { - let mut ret: i16 = -1; - - for step in Self::DECODER { - ret += match step { - DecodeStep::Range(range, offset) => { - // Compute exclusive range from inclusive one - let start = *range.start() as i16 - 1; - let end = *range.end() as i16 + 1; - (((start - src as i16) & (src as i16 - end)) >> 8) & (src as i16 + *offset) - } - DecodeStep::Eq(value, offset) => { - let start = *value as i16 - 1; - let end = *value as i16 + 1; - (((start - src as i16) & (src as i16 - end)) >> 8) & *offset - } - }; - } - - ret - } - - /// Encode 3-bytes of a Base64 message. - #[inline(always)] - fn encode_3bytes(src: &[u8], dst: &mut [u8]) { - debug_assert_eq!(src.len(), 3); - debug_assert!(dst.len() >= 4, "dst too short: {}", dst.len()); - - let b0 = src[0] as i16; - let b1 = src[1] as i16; - let b2 = src[2] as i16; - - dst[0] = Self::encode_6bits(b0 >> 2); - dst[1] = Self::encode_6bits(((b0 << 4) | (b1 >> 4)) & 63); - dst[2] = Self::encode_6bits(((b1 << 2) | (b2 >> 6)) & 63); - dst[3] = Self::encode_6bits(b2 & 63); - } - - /// Encode 6-bits of a Base64 message. - #[inline(always)] - fn encode_6bits(src: i16) -> u8 { - let mut diff = src + Self::BASE as i16; - - for &step in Self::ENCODER { - diff += match step { - EncodeStep::Apply(threshold, offset) => ((threshold as i16 - diff) >> 8) & offset, - EncodeStep::Diff(threshold, offset) => ((threshold as i16 - src) >> 8) & offset, - }; - } - - diff as u8 - } -} - -/// Constant-time decoder step. -#[derive(Debug)] -pub enum DecodeStep { - /// Match the given range, offsetting the input on match. - Range(RangeInclusive, i16), - - /// Match the given value, returning the associated offset on match. - Eq(u8, i16), -} - -/// Constant-time encoder step. -#[derive(Copy, Clone, Debug)] -pub enum EncodeStep { - /// Apply the given offset to the cumulative result on match. - Apply(u8, i16), - - /// Compute a difference using the given offset on match. - Diff(u8, i16), -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/bcrypt.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/bcrypt.rs deleted file mode 100644 index 4227dbfcf055..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/bcrypt.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! bcrypt Base64 encoding. - -use super::{Alphabet, DecodeStep, EncodeStep}; - -/// bcrypt Base64 encoding. -/// -/// ```text -/// ./ [A-Z] [a-z] [0-9] -/// 0x2e-0x2f, 0x41-0x5a, 0x61-0x7a, 0x30-0x39 -/// ``` -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Base64Bcrypt; - -impl Alphabet for Base64Bcrypt { - const BASE: u8 = b'.'; - - const DECODER: &'static [DecodeStep] = &[ - DecodeStep::Range(b'.'..=b'/', -45), - DecodeStep::Range(b'A'..=b'Z', -62), - DecodeStep::Range(b'a'..=b'z', -68), - DecodeStep::Range(b'0'..=b'9', 7), - ]; - - const ENCODER: &'static [EncodeStep] = &[ - EncodeStep::Apply(b'/', 17), - EncodeStep::Apply(b'Z', 6), - EncodeStep::Apply(b'z', -75), - ]; - - const PADDED: bool = false; - - type Unpadded = Self; -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/crypt.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/crypt.rs deleted file mode 100644 index 5d97c33ac5bf..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/crypt.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! `crypt(3)` Base64 encoding. - -use super::{Alphabet, DecodeStep, EncodeStep}; - -/// `crypt(3)` Base64 encoding. -/// -/// ```text -/// [.-9] [A-Z] [a-z] -/// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a -/// ``` -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Base64Crypt; - -impl Alphabet for Base64Crypt { - const BASE: u8 = b'.'; - - const DECODER: &'static [DecodeStep] = &[ - DecodeStep::Range(b'.'..=b'9', -45), - DecodeStep::Range(b'A'..=b'Z', -52), - DecodeStep::Range(b'a'..=b'z', -58), - ]; - - const ENCODER: &'static [EncodeStep] = - &[EncodeStep::Apply(b'9', 7), EncodeStep::Apply(b'Z', 6)]; - - const PADDED: bool = false; - - type Unpadded = Self; -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/shacrypt.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/shacrypt.rs deleted file mode 100644 index ef8d362f94da..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/shacrypt.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! `crypt(3)` Base64 encoding for sha* family. - -use super::{Alphabet, DecodeStep, EncodeStep}; - -/// `crypt(3)` Base64 encoding for the following schemes. -/// * sha1_crypt, -/// * sha256_crypt, -/// * sha512_crypt, -/// * md5_crypt -/// -/// ```text -/// [.-9] [A-Z] [a-z] -/// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a -/// ``` -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Base64ShaCrypt; - -impl Alphabet for Base64ShaCrypt { - const BASE: u8 = b'.'; - - const DECODER: &'static [DecodeStep] = &[ - DecodeStep::Range(b'.'..=b'9', -45), - DecodeStep::Range(b'A'..=b'Z', -52), - DecodeStep::Range(b'a'..=b'z', -58), - ]; - - const ENCODER: &'static [EncodeStep] = - &[EncodeStep::Apply(b'9', 7), EncodeStep::Apply(b'Z', 6)]; - - const PADDED: bool = false; - - type Unpadded = Self; - - #[inline(always)] - fn decode_3bytes(src: &[u8], dst: &mut [u8]) -> i16 { - debug_assert_eq!(src.len(), 4); - debug_assert!(dst.len() >= 3, "dst too short: {}", dst.len()); - - let c0 = Self::decode_6bits(src[0]); - let c1 = Self::decode_6bits(src[1]); - let c2 = Self::decode_6bits(src[2]); - let c3 = Self::decode_6bits(src[3]); - - dst[0] = (c0 | ((c1 & 0x3) << 6)) as u8; - dst[1] = ((c1 >> 2) | ((c2 & 0xF) << 4)) as u8; - dst[2] = ((c2 >> 4) | (c3 << 2)) as u8; - - ((c0 | c1 | c2 | c3) >> 8) & 1 - } - - #[inline(always)] - fn encode_3bytes(src: &[u8], dst: &mut [u8]) { - debug_assert_eq!(src.len(), 3); - debug_assert!(dst.len() >= 4, "dst too short: {}", dst.len()); - - let b0 = src[0] as i16; - let b1 = src[1] as i16; - let b2 = src[2] as i16; - - dst[0] = Self::encode_6bits(b0 & 63); - dst[1] = Self::encode_6bits(((b1 << 2) | (b0 >> 6)) & 63); - dst[2] = Self::encode_6bits(((b2 << 4) | (b1 >> 4)) & 63); - dst[3] = Self::encode_6bits(b2 >> 2); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/standard.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/standard.rs deleted file mode 100644 index 90eab69f16cc..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/standard.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! Standard Base64 encoding. - -use super::{Alphabet, DecodeStep, EncodeStep}; - -/// Standard Base64 encoding with `=` padding. -/// -/// ```text -/// [A-Z] [a-z] [0-9] + / -/// 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2b, 0x2f -/// ``` -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Base64; - -impl Alphabet for Base64 { - const BASE: u8 = b'A'; - const DECODER: &'static [DecodeStep] = DECODER; - const ENCODER: &'static [EncodeStep] = ENCODER; - const PADDED: bool = true; - type Unpadded = Base64Unpadded; -} - -/// Standard Base64 encoding *without* padding. -/// -/// ```text -/// [A-Z] [a-z] [0-9] + / -/// 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2b, 0x2f -/// ``` -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Base64Unpadded; - -impl Alphabet for Base64Unpadded { - const BASE: u8 = b'A'; - const DECODER: &'static [DecodeStep] = DECODER; - const ENCODER: &'static [EncodeStep] = ENCODER; - const PADDED: bool = false; - type Unpadded = Self; -} - -/// Standard Base64 decoder -const DECODER: &[DecodeStep] = &[ - DecodeStep::Range(b'A'..=b'Z', -64), - DecodeStep::Range(b'a'..=b'z', -70), - DecodeStep::Range(b'0'..=b'9', 5), - DecodeStep::Eq(b'+', 63), - DecodeStep::Eq(b'/', 64), -]; - -/// Standard Base64 encoder -const ENCODER: &[EncodeStep] = &[ - EncodeStep::Diff(25, 6), - EncodeStep::Diff(51, -75), - EncodeStep::Diff(61, -(b'+' as i16 - 0x1c)), - EncodeStep::Diff(62, b'/' as i16 - b'+' as i16 - 1), -]; diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/url.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/url.rs deleted file mode 100644 index 432edb85277e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/alphabet/url.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! URL-safe Base64 encoding. - -use super::{Alphabet, DecodeStep, EncodeStep}; - -/// URL-safe Base64 encoding with `=` padding. -/// -/// ```text -/// [A-Z] [a-z] [0-9] - _ -/// 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2d, 0x5f -/// ``` -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Base64Url; - -impl Alphabet for Base64Url { - const BASE: u8 = b'A'; - const DECODER: &'static [DecodeStep] = DECODER; - const ENCODER: &'static [EncodeStep] = ENCODER; - const PADDED: bool = true; - type Unpadded = Base64UrlUnpadded; -} - -/// URL-safe Base64 encoding *without* padding. -/// -/// ```text -/// [A-Z] [a-z] [0-9] - _ -/// 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2d, 0x5f -/// ``` -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Base64UrlUnpadded; - -impl Alphabet for Base64UrlUnpadded { - const BASE: u8 = b'A'; - const DECODER: &'static [DecodeStep] = DECODER; - const ENCODER: &'static [EncodeStep] = ENCODER; - const PADDED: bool = false; - type Unpadded = Self; -} - -/// URL-safe Base64 decoder -const DECODER: &[DecodeStep] = &[ - DecodeStep::Range(b'A'..=b'Z', -64), - DecodeStep::Range(b'a'..=b'z', -70), - DecodeStep::Range(b'0'..=b'9', 5), - DecodeStep::Eq(b'-', 63), - DecodeStep::Eq(b'_', 64), -]; - -/// URL-safe Base64 encoder -const ENCODER: &[EncodeStep] = &[ - EncodeStep::Diff(25, 6), - EncodeStep::Diff(51, -75), - EncodeStep::Diff(61, -(b'-' as i16 - 0x20)), - EncodeStep::Diff(62, b'_' as i16 - b'-' as i16 - 1), -]; diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/decoder.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/decoder.rs deleted file mode 100644 index b1010469162a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/decoder.rs +++ /dev/null @@ -1,618 +0,0 @@ -//! Buffered Base64 decoder. - -use crate::{ - encoding, - line_ending::{CHAR_CR, CHAR_LF}, - Encoding, - Error::{self, InvalidLength}, - MIN_LINE_WIDTH, -}; -use core::{cmp, marker::PhantomData}; - -#[cfg(feature = "alloc")] -use {alloc::vec::Vec, core::iter}; - -#[cfg(feature = "std")] -use std::io; - -#[cfg(doc)] -use crate::{Base64, Base64Unpadded}; - -/// Stateful Base64 decoder with support for buffered, incremental decoding. -/// -/// The `E` type parameter can be any type which impls [`Encoding`] such as -/// [`Base64`] or [`Base64Unpadded`]. -#[derive(Clone)] -pub struct Decoder<'i, E: Encoding> { - /// Current line being processed. - line: Line<'i>, - - /// Base64 input data reader. - line_reader: LineReader<'i>, - - /// Length of the remaining data after Base64 decoding. - remaining_len: usize, - - /// Block buffer used for non-block-aligned data. - block_buffer: BlockBuffer, - - /// Phantom parameter for the Base64 encoding in use. - encoding: PhantomData, -} - -impl<'i, E: Encoding> Decoder<'i, E> { - /// Create a new decoder for a byte slice containing contiguous - /// (non-newline-delimited) Base64-encoded data. - /// - /// # Returns - /// - `Ok(decoder)` on success. - /// - `Err(Error::InvalidLength)` if the input buffer is empty. - pub fn new(input: &'i [u8]) -> Result { - let line_reader = LineReader::new_unwrapped(input)?; - let remaining_len = line_reader.decoded_len::()?; - - Ok(Self { - line: Line::default(), - line_reader, - remaining_len, - block_buffer: BlockBuffer::default(), - encoding: PhantomData, - }) - } - - /// Create a new decoder for a byte slice containing Base64 which - /// line wraps at the given line length. - /// - /// Trailing newlines are not supported and must be removed in advance. - /// - /// Newlines are handled according to what are roughly [RFC7468] conventions: - /// - /// ```text - /// [parsers] MUST handle different newline conventions - /// ``` - /// - /// RFC7468 allows any of the following as newlines, and allows a mixture - /// of different types of newlines: - /// - /// ```text - /// eol = CRLF / CR / LF - /// ``` - /// - /// # Returns - /// - `Ok(decoder)` on success. - /// - `Err(Error::InvalidLength)` if the input buffer is empty or the line - /// width is zero. - /// - /// [RFC7468]: https://datatracker.ietf.org/doc/html/rfc7468 - pub fn new_wrapped(input: &'i [u8], line_width: usize) -> Result { - let line_reader = LineReader::new_wrapped(input, line_width)?; - let remaining_len = line_reader.decoded_len::()?; - - Ok(Self { - line: Line::default(), - line_reader, - remaining_len, - block_buffer: BlockBuffer::default(), - encoding: PhantomData, - }) - } - - /// Fill the provided buffer with data decoded from Base64. - /// - /// Enough Base64 input data must remain to fill the entire buffer. - /// - /// # Returns - /// - `Ok(bytes)` if the expected amount of data was read - /// - `Err(Error::InvalidLength)` if the exact amount of data couldn't be read - pub fn decode<'o>(&mut self, out: &'o mut [u8]) -> Result<&'o [u8], Error> { - if self.is_finished() { - return Err(InvalidLength); - } - - let mut out_pos = 0; - - while out_pos < out.len() { - // If there's data in the block buffer, use it - if !self.block_buffer.is_empty() { - let out_rem = out.len().checked_sub(out_pos).ok_or(InvalidLength)?; - let bytes = self.block_buffer.take(out_rem)?; - out[out_pos..][..bytes.len()].copy_from_slice(bytes); - out_pos = out_pos.checked_add(bytes.len()).ok_or(InvalidLength)?; - } - - // Advance the line reader if necessary - if self.line.is_empty() && !self.line_reader.is_empty() { - self.advance_line()?; - } - - // Attempt to decode a stride of block-aligned data - let in_blocks = self.line.len() / 4; - let out_rem = out.len().checked_sub(out_pos).ok_or(InvalidLength)?; - let out_blocks = out_rem / 3; - let blocks = cmp::min(in_blocks, out_blocks); - let in_aligned = self.line.take(blocks.checked_mul(4).ok_or(InvalidLength)?); - - if !in_aligned.is_empty() { - let out_buf = &mut out[out_pos..][..blocks.checked_mul(3).ok_or(InvalidLength)?]; - let decoded_len = self.perform_decode(in_aligned, out_buf)?.len(); - out_pos = out_pos.checked_add(decoded_len).ok_or(InvalidLength)?; - } - - if out_pos < out.len() { - if self.is_finished() { - // If we're out of input then we've been requested to decode - // more data than is actually available. - return Err(InvalidLength); - } else { - // If we still have data available but haven't completely - // filled the output slice, we're in a situation where - // either the input or output isn't block-aligned, so fill - // the internal block buffer. - self.fill_block_buffer()?; - } - } - } - - self.remaining_len = self - .remaining_len - .checked_sub(out.len()) - .ok_or(InvalidLength)?; - - Ok(out) - } - - /// Decode all remaining Base64 data, placing the result into `buf`. - /// - /// If successful, this function will return the total number of bytes - /// decoded into `buf`. - #[cfg(feature = "alloc")] - pub fn decode_to_end<'o>(&mut self, buf: &'o mut Vec) -> Result<&'o [u8], Error> { - let start_len = buf.len(); - let remaining_len = self.remaining_len(); - let total_len = start_len.checked_add(remaining_len).ok_or(InvalidLength)?; - - if total_len > buf.capacity() { - buf.reserve(total_len.checked_sub(buf.capacity()).ok_or(InvalidLength)?); - } - - // Append `decoded_len` zeroes to the vector - buf.extend(iter::repeat(0).take(remaining_len)); - self.decode(&mut buf[start_len..])?; - Ok(&buf[start_len..]) - } - - /// Get the length of the remaining data after Base64 decoding. - /// - /// Decreases every time data is decoded. - pub fn remaining_len(&self) -> usize { - self.remaining_len - } - - /// Has all of the input data been decoded? - pub fn is_finished(&self) -> bool { - self.line.is_empty() && self.line_reader.is_empty() && self.block_buffer.is_empty() - } - - /// Fill the block buffer with data. - fn fill_block_buffer(&mut self) -> Result<(), Error> { - let mut buf = [0u8; BlockBuffer::SIZE]; - - let decoded = if self.line.len() < 4 && !self.line_reader.is_empty() { - // Handle input block which is split across lines - let mut tmp = [0u8; 4]; - - // Copy remaining data in the line into tmp - let line_end = self.line.take(4); - tmp[..line_end.len()].copy_from_slice(line_end); - - // Advance the line and attempt to fill tmp - self.advance_line()?; - let len = 4usize.checked_sub(line_end.len()).ok_or(InvalidLength)?; - let line_begin = self.line.take(len); - tmp[line_end.len()..][..line_begin.len()].copy_from_slice(line_begin); - - let tmp_len = line_begin - .len() - .checked_add(line_end.len()) - .ok_or(InvalidLength)?; - - self.perform_decode(&tmp[..tmp_len], &mut buf) - } else { - let block = self.line.take(4); - self.perform_decode(block, &mut buf) - }?; - - self.block_buffer.fill(decoded) - } - - /// Advance the internal buffer to the next line. - fn advance_line(&mut self) -> Result<(), Error> { - debug_assert!(self.line.is_empty(), "expected line buffer to be empty"); - - if let Some(line) = self.line_reader.next().transpose()? { - self.line = line; - Ok(()) - } else { - Err(InvalidLength) - } - } - - /// Perform Base64 decoding operation. - fn perform_decode<'o>(&self, src: &[u8], dst: &'o mut [u8]) -> Result<&'o [u8], Error> { - if self.is_finished() { - E::decode(src, dst) - } else { - E::Unpadded::decode(src, dst) - } - } -} - -#[cfg(feature = "std")] -impl<'i, E: Encoding> io::Read for Decoder<'i, E> { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - if self.is_finished() { - return Ok(0); - } - let slice = match buf.get_mut(..self.remaining_len()) { - Some(bytes) => bytes, - None => buf, - }; - - self.decode(slice)?; - Ok(slice.len()) - } - - fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { - if self.is_finished() { - return Ok(0); - } - Ok(self.decode_to_end(buf)?.len()) - } - - fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { - self.decode(buf)?; - Ok(()) - } -} - -/// Base64 decode buffer for a 1-block input. -/// -/// This handles a partially decoded block of data, i.e. data which has been -/// decoded but not read. -#[derive(Clone, Default, Debug)] -struct BlockBuffer { - /// 3 decoded bytes from a 4-byte Base64-encoded input. - decoded: [u8; Self::SIZE], - - /// Length of the buffer. - length: usize, - - /// Position within the buffer. - position: usize, -} - -impl BlockBuffer { - /// Size of the buffer in bytes. - const SIZE: usize = 3; - - /// Fill the buffer by decoding up to 3 bytes of decoded Base64 input. - fn fill(&mut self, decoded_input: &[u8]) -> Result<(), Error> { - debug_assert!(self.is_empty()); - - if decoded_input.len() > Self::SIZE { - return Err(InvalidLength); - } - - self.position = 0; - self.length = decoded_input.len(); - self.decoded[..decoded_input.len()].copy_from_slice(decoded_input); - Ok(()) - } - - /// Take a specified number of bytes from the buffer. - /// - /// Returns as many bytes as possible, or an empty slice if the buffer has - /// already been read to completion. - fn take(&mut self, mut nbytes: usize) -> Result<&[u8], Error> { - debug_assert!(self.position <= self.length); - let start_pos = self.position; - let remaining_len = self.length.checked_sub(start_pos).ok_or(InvalidLength)?; - - if nbytes > remaining_len { - nbytes = remaining_len; - } - - self.position = self.position.checked_add(nbytes).ok_or(InvalidLength)?; - Ok(&self.decoded[start_pos..][..nbytes]) - } - - /// Have all of the bytes in this buffer been consumed? - fn is_empty(&self) -> bool { - self.position == self.length - } -} - -/// A single line of linewrapped data, providing a read buffer. -#[derive(Clone, Debug)] -pub struct Line<'i> { - /// Remaining data in the line - remaining: &'i [u8], -} - -impl<'i> Default for Line<'i> { - fn default() -> Self { - Self::new(&[]) - } -} - -impl<'i> Line<'i> { - /// Create a new line which wraps the given input data. - fn new(bytes: &'i [u8]) -> Self { - Self { remaining: bytes } - } - - /// Take up to `nbytes` from this line buffer. - fn take(&mut self, nbytes: usize) -> &'i [u8] { - let (bytes, rest) = if nbytes < self.remaining.len() { - self.remaining.split_at(nbytes) - } else { - (self.remaining, [].as_ref()) - }; - - self.remaining = rest; - bytes - } - - /// Slice off a tail of a given length. - fn slice_tail(&self, nbytes: usize) -> Result<&'i [u8], Error> { - let offset = self.len().checked_sub(nbytes).ok_or(InvalidLength)?; - self.remaining.get(offset..).ok_or(InvalidLength) - } - - /// Get the number of bytes remaining in this line. - fn len(&self) -> usize { - self.remaining.len() - } - - /// Is the buffer for this line empty? - fn is_empty(&self) -> bool { - self.len() == 0 - } - - /// Trim the newline off the end of this line. - fn trim_end(&self) -> Self { - Line::new(match self.remaining { - [line @ .., CHAR_CR, CHAR_LF] => line, - [line @ .., CHAR_CR] => line, - [line @ .., CHAR_LF] => line, - line => line, - }) - } -} - -/// Iterator over multi-line Base64 input. -#[derive(Clone)] -struct LineReader<'i> { - /// Remaining linewrapped data to be processed. - remaining: &'i [u8], - - /// Line width. - line_width: Option, -} - -impl<'i> LineReader<'i> { - /// Create a new reader which operates over continugous unwrapped data. - fn new_unwrapped(bytes: &'i [u8]) -> Result { - if bytes.is_empty() { - Err(InvalidLength) - } else { - Ok(Self { - remaining: bytes, - line_width: None, - }) - } - } - - /// Create a new reader which operates over linewrapped data. - fn new_wrapped(bytes: &'i [u8], line_width: usize) -> Result { - if line_width < MIN_LINE_WIDTH { - return Err(InvalidLength); - } - - let mut reader = Self::new_unwrapped(bytes)?; - reader.line_width = Some(line_width); - Ok(reader) - } - - /// Is this line reader empty? - fn is_empty(&self) -> bool { - self.remaining.is_empty() - } - - /// Get the total length of the data decoded from this line reader. - fn decoded_len(&self) -> Result { - let mut buffer = [0u8; 4]; - let mut lines = self.clone(); - let mut line = match lines.next().transpose()? { - Some(l) => l, - None => return Ok(0), - }; - let mut base64_len = 0usize; - - loop { - base64_len = base64_len.checked_add(line.len()).ok_or(InvalidLength)?; - - match lines.next().transpose()? { - Some(l) => { - // Store the end of the line in the buffer so we can - // reassemble the last block to determine the real length - buffer.copy_from_slice(line.slice_tail(4)?); - - line = l - } - - // To compute an exact decoded length we need to decode the - // last Base64 block and get the decoded length. - // - // This is what the somewhat complex code below is doing. - None => { - // Compute number of bytes in the last block (may be unpadded) - let base64_last_block_len = match base64_len % 4 { - 0 => 4, - n => n, - }; - - // Compute decoded length without the last block - let decoded_len = encoding::decoded_len( - base64_len - .checked_sub(base64_last_block_len) - .ok_or(InvalidLength)?, - ); - - // Compute the decoded length of the last block - let mut out = [0u8; 3]; - let last_block_len = if line.len() < base64_last_block_len { - let buffered_part_len = base64_last_block_len - .checked_sub(line.len()) - .ok_or(InvalidLength)?; - - let offset = 4usize.checked_sub(buffered_part_len).ok_or(InvalidLength)?; - - for i in 0..buffered_part_len { - buffer[i] = buffer[offset.checked_add(i).ok_or(InvalidLength)?]; - } - - buffer[buffered_part_len..][..line.len()].copy_from_slice(line.remaining); - let buffer_len = buffered_part_len - .checked_add(line.len()) - .ok_or(InvalidLength)?; - - E::decode(&buffer[..buffer_len], &mut out)?.len() - } else { - let last_block = line.slice_tail(base64_last_block_len)?; - E::decode(last_block, &mut out)?.len() - }; - - return decoded_len.checked_add(last_block_len).ok_or(InvalidLength); - } - } - } - } -} - -impl<'i> Iterator for LineReader<'i> { - type Item = Result, Error>; - - fn next(&mut self) -> Option, Error>> { - if let Some(line_width) = self.line_width { - let rest = match self.remaining.get(line_width..) { - None | Some([]) => { - if self.remaining.is_empty() { - return None; - } else { - let line = Line::new(self.remaining).trim_end(); - self.remaining = &[]; - return Some(Ok(line)); - } - } - Some([CHAR_CR, CHAR_LF, rest @ ..]) => rest, - Some([CHAR_CR, rest @ ..]) => rest, - Some([CHAR_LF, rest @ ..]) => rest, - _ => { - // Expected a leading newline - return Some(Err(Error::InvalidEncoding)); - } - }; - - let line = Line::new(&self.remaining[..line_width]); - self.remaining = rest; - Some(Ok(line)) - } else if !self.remaining.is_empty() { - let line = Line::new(self.remaining).trim_end(); - self.remaining = b""; - - if line.is_empty() { - None - } else { - Some(Ok(line)) - } - } else { - None - } - } -} - -#[cfg(test)] -mod tests { - use crate::{alphabet::Alphabet, test_vectors::*, Base64, Base64Unpadded, Decoder}; - - #[cfg(feature = "std")] - use {alloc::vec::Vec, std::io::Read}; - - #[test] - fn decode_padded() { - decode_test(PADDED_BIN, || { - Decoder::::new(PADDED_BASE64.as_bytes()).unwrap() - }) - } - - #[test] - fn decode_unpadded() { - decode_test(UNPADDED_BIN, || { - Decoder::::new(UNPADDED_BASE64.as_bytes()).unwrap() - }) - } - - #[test] - fn decode_multiline_padded() { - decode_test(MULTILINE_PADDED_BIN, || { - Decoder::::new_wrapped(MULTILINE_PADDED_BASE64.as_bytes(), 70).unwrap() - }) - } - - #[test] - fn decode_multiline_unpadded() { - decode_test(MULTILINE_UNPADDED_BIN, || { - Decoder::::new_wrapped(MULTILINE_UNPADDED_BASE64.as_bytes(), 70) - .unwrap() - }) - } - - #[cfg(feature = "std")] - #[test] - fn read_multiline_padded() { - let mut decoder = - Decoder::::new_wrapped(MULTILINE_PADDED_BASE64.as_bytes(), 70).unwrap(); - - let mut buf = Vec::new(); - let len = decoder.read_to_end(&mut buf).unwrap(); - - assert_eq!(len, MULTILINE_PADDED_BIN.len()); - assert_eq!(buf.as_slice(), MULTILINE_PADDED_BIN); - } - - /// Core functionality of a decoding test - fn decode_test<'a, F, V>(expected: &[u8], f: F) - where - F: Fn() -> Decoder<'a, V>, - V: Alphabet, - { - for chunk_size in 1..expected.len() { - let mut decoder = f(); - let mut remaining_len = decoder.remaining_len(); - let mut buffer = [0u8; 1024]; - - for chunk in expected.chunks(chunk_size) { - assert!(!decoder.is_finished()); - let decoded = decoder.decode(&mut buffer[..chunk.len()]).unwrap(); - assert_eq!(chunk, decoded); - - remaining_len -= decoded.len(); - assert_eq!(remaining_len, decoder.remaining_len()); - } - - assert!(decoder.is_finished()); - assert_eq!(decoder.remaining_len(), 0); - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoder.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoder.rs deleted file mode 100644 index 0ce8c2f36345..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoder.rs +++ /dev/null @@ -1,363 +0,0 @@ -//! Buffered Base64 encoder. - -use crate::{ - Encoding, - Error::{self, InvalidLength}, - LineEnding, MIN_LINE_WIDTH, -}; -use core::{cmp, marker::PhantomData, str}; - -#[cfg(feature = "std")] -use std::io; - -#[cfg(doc)] -use crate::{Base64, Base64Unpadded}; - -/// Stateful Base64 encoder with support for buffered, incremental encoding. -/// -/// The `E` type parameter can be any type which impls [`Encoding`] such as -/// [`Base64`] or [`Base64Unpadded`]. -pub struct Encoder<'o, E: Encoding> { - /// Output buffer. - output: &'o mut [u8], - - /// Cursor within the output buffer. - position: usize, - - /// Block buffer used for non-block-aligned data. - block_buffer: BlockBuffer, - - /// Configuration and state for line-wrapping the output at a specified - /// column. - line_wrapper: Option, - - /// Phantom parameter for the Base64 encoding in use. - encoding: PhantomData, -} - -impl<'o, E: Encoding> Encoder<'o, E> { - /// Create a new encoder which writes output to the given byte slice. - /// - /// Output constructed using this method is not line-wrapped. - pub fn new(output: &'o mut [u8]) -> Result { - if output.is_empty() { - return Err(InvalidLength); - } - - Ok(Self { - output, - position: 0, - block_buffer: BlockBuffer::default(), - line_wrapper: None, - encoding: PhantomData, - }) - } - - /// Create a new encoder which writes line-wrapped output to the given byte - /// slice. - /// - /// Output will be wrapped at the specified interval, using the provided - /// line ending. Use [`LineEnding::default()`] to use the conventional line - /// ending for the target OS. - /// - /// Minimum allowed line width is 4. - pub fn new_wrapped( - output: &'o mut [u8], - width: usize, - ending: LineEnding, - ) -> Result { - let mut encoder = Self::new(output)?; - encoder.line_wrapper = Some(LineWrapper::new(width, ending)?); - Ok(encoder) - } - - /// Encode the provided buffer as Base64, writing it to the output buffer. - /// - /// # Returns - /// - `Ok(bytes)` if the expected amount of data was read - /// - `Err(Error::InvalidLength)` if there is insufficient space in the output buffer - pub fn encode(&mut self, mut input: &[u8]) -> Result<(), Error> { - // If there's data in the block buffer, fill it - if !self.block_buffer.is_empty() { - self.process_buffer(&mut input)?; - } - - while !input.is_empty() { - // Attempt to encode a stride of block-aligned data - let in_blocks = input.len() / 3; - let out_blocks = self.remaining().len() / 4; - let mut blocks = cmp::min(in_blocks, out_blocks); - - // When line wrapping, cap the block-aligned stride at near/at line length - if let Some(line_wrapper) = &self.line_wrapper { - line_wrapper.wrap_blocks(&mut blocks)?; - } - - if blocks > 0 { - let len = blocks.checked_mul(3).ok_or(InvalidLength)?; - let (in_aligned, in_rem) = input.split_at(len); - input = in_rem; - self.perform_encode(in_aligned)?; - } - - // If there's remaining non-aligned data, fill the block buffer - if !input.is_empty() { - self.process_buffer(&mut input)?; - } - } - - Ok(()) - } - - /// Get the position inside of the output buffer where the write cursor - /// is currently located. - pub fn position(&self) -> usize { - self.position - } - - /// Finish encoding data, returning the resulting Base64 as a `str`. - pub fn finish(self) -> Result<&'o str, Error> { - self.finish_with_remaining().map(|(base64, _)| base64) - } - - /// Finish encoding data, returning the resulting Base64 as a `str` - /// along with the remaining space in the output buffer. - pub fn finish_with_remaining(mut self) -> Result<(&'o str, &'o mut [u8]), Error> { - if !self.block_buffer.is_empty() { - let buffer_len = self.block_buffer.position; - let block = self.block_buffer.bytes; - self.perform_encode(&block[..buffer_len])?; - } - - let (base64, remaining) = self.output.split_at_mut(self.position); - Ok((str::from_utf8(base64)?, remaining)) - } - - /// Borrow the remaining data in the buffer. - fn remaining(&mut self) -> &mut [u8] { - &mut self.output[self.position..] - } - - /// Fill the block buffer with data, consuming and encoding it when the - /// buffer is full. - fn process_buffer(&mut self, input: &mut &[u8]) -> Result<(), Error> { - self.block_buffer.fill(input)?; - - if self.block_buffer.is_full() { - let block = self.block_buffer.take(); - self.perform_encode(&block)?; - } - - Ok(()) - } - - /// Perform Base64 encoding operation. - fn perform_encode(&mut self, input: &[u8]) -> Result { - let mut len = E::encode(input, self.remaining())?.as_bytes().len(); - - // Insert newline characters into the output as needed - if let Some(line_wrapper) = &mut self.line_wrapper { - line_wrapper.insert_newlines(&mut self.output[self.position..], &mut len)?; - } - - self.position = self.position.checked_add(len).ok_or(InvalidLength)?; - Ok(len) - } -} - -#[cfg(feature = "std")] -impl<'o, E: Encoding> io::Write for Encoder<'o, E> { - fn write(&mut self, buf: &[u8]) -> io::Result { - self.encode(buf)?; - Ok(buf.len()) - } - - fn flush(&mut self) -> io::Result<()> { - // TODO(tarcieri): return an error if there's still data remaining in the buffer? - Ok(()) - } -} - -/// Base64 encode buffer for a 1-block output. -/// -/// This handles a partial block of data, i.e. data which hasn't been -#[derive(Clone, Default, Debug)] -struct BlockBuffer { - /// 3 decoded bytes to be encoded to a 4-byte Base64-encoded input. - bytes: [u8; Self::SIZE], - - /// Position within the buffer. - position: usize, -} - -impl BlockBuffer { - /// Size of the buffer in bytes: 3-bytes of unencoded input which - /// Base64 encode to 4-bytes of output. - const SIZE: usize = 3; - - /// Fill the remaining space in the buffer with the input data. - fn fill(&mut self, input: &mut &[u8]) -> Result<(), Error> { - let remaining = Self::SIZE.checked_sub(self.position).ok_or(InvalidLength)?; - let len = cmp::min(input.len(), remaining); - self.bytes[self.position..][..len].copy_from_slice(&input[..len]); - self.position = self.position.checked_add(len).ok_or(InvalidLength)?; - *input = &input[len..]; - Ok(()) - } - - /// Take the output buffer, resetting the position to 0. - fn take(&mut self) -> [u8; Self::SIZE] { - debug_assert!(self.is_full()); - let result = self.bytes; - *self = Default::default(); - result - } - - /// Is the buffer empty? - fn is_empty(&self) -> bool { - self.position == 0 - } - - /// Is the buffer full? - fn is_full(&self) -> bool { - self.position == Self::SIZE - } -} - -/// Helper for wrapping Base64 at a given line width. -#[derive(Debug)] -struct LineWrapper { - /// Number of bytes remaining in the current line. - remaining: usize, - - /// Column at which Base64 should be wrapped. - width: usize, - - /// Newline characters to use at the end of each line. - ending: LineEnding, -} - -impl LineWrapper { - /// Create a new linewrapper. - fn new(width: usize, ending: LineEnding) -> Result { - if width < MIN_LINE_WIDTH { - return Err(InvalidLength); - } - - Ok(Self { - remaining: width, - width, - ending, - }) - } - - /// Wrap the number of blocks to encode near/at EOL. - fn wrap_blocks(&self, blocks: &mut usize) -> Result<(), Error> { - if blocks.checked_mul(4).ok_or(InvalidLength)? >= self.remaining { - *blocks = self.remaining / 4; - } - - Ok(()) - } - - /// Insert newlines into the output buffer as needed. - fn insert_newlines(&mut self, mut buffer: &mut [u8], len: &mut usize) -> Result<(), Error> { - let mut buffer_len = *len; - - if buffer_len <= self.remaining { - self.remaining = self - .remaining - .checked_sub(buffer_len) - .ok_or(InvalidLength)?; - - return Ok(()); - } - - buffer = &mut buffer[self.remaining..]; - buffer_len = buffer_len - .checked_sub(self.remaining) - .ok_or(InvalidLength)?; - - // The `wrap_blocks` function should ensure the buffer is no larger than a Base64 block - debug_assert!(buffer_len <= 4, "buffer too long: {}", buffer_len); - - // Ensure space in buffer to add newlines - let buffer_end = buffer_len - .checked_add(self.ending.len()) - .ok_or(InvalidLength)?; - - if buffer_end >= buffer.len() { - return Err(InvalidLength); - } - - // Shift the buffer contents to make space for the line ending - for i in (0..buffer_len).rev() { - buffer[i.checked_add(self.ending.len()).ok_or(InvalidLength)?] = buffer[i]; - } - - buffer[..self.ending.len()].copy_from_slice(self.ending.as_bytes()); - *len = (*len).checked_add(self.ending.len()).ok_or(InvalidLength)?; - self.remaining = self.width.checked_sub(buffer_len).ok_or(InvalidLength)?; - - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use crate::{alphabet::Alphabet, test_vectors::*, Base64, Base64Unpadded, Encoder, LineEnding}; - - #[test] - fn encode_padded() { - encode_test::(PADDED_BIN, PADDED_BASE64, None); - } - - #[test] - fn encode_unpadded() { - encode_test::(UNPADDED_BIN, UNPADDED_BASE64, None); - } - - #[test] - fn encode_multiline_padded() { - encode_test::(MULTILINE_PADDED_BIN, MULTILINE_PADDED_BASE64, Some(70)); - } - - #[test] - fn encode_multiline_unpadded() { - encode_test::(MULTILINE_UNPADDED_BIN, MULTILINE_UNPADDED_BASE64, Some(70)); - } - - #[test] - fn no_trailing_newline_when_aligned() { - let mut buffer = [0u8; 64]; - let mut encoder = Encoder::::new_wrapped(&mut buffer, 64, LineEnding::LF).unwrap(); - encoder.encode(&[0u8; 48]).unwrap(); - - // Ensure no newline character is present in this case - assert_eq!( - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - encoder.finish().unwrap() - ); - } - - /// Core functionality of an encoding test. - fn encode_test(input: &[u8], expected: &str, wrapped: Option) { - let mut buffer = [0u8; 1024]; - - for chunk_size in 1..input.len() { - let mut encoder = match wrapped { - Some(line_width) => { - Encoder::::new_wrapped(&mut buffer, line_width, LineEnding::LF) - } - None => Encoder::::new(&mut buffer), - } - .unwrap(); - - for chunk in input.chunks(chunk_size) { - encoder.encode(chunk).unwrap(); - } - - assert_eq!(expected, encoder.finish().unwrap()); - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoding.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoding.rs deleted file mode 100644 index 83cbc32fe74f..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/encoding.rs +++ /dev/null @@ -1,376 +0,0 @@ -//! Base64 encodings - -use crate::{ - alphabet::Alphabet, - errors::{Error, InvalidEncodingError, InvalidLengthError}, -}; -use core::str; - -#[cfg(feature = "alloc")] -use alloc::{string::String, vec::Vec}; - -#[cfg(doc)] -use crate::{Base64, Base64Bcrypt, Base64Crypt, Base64Unpadded, Base64Url, Base64UrlUnpadded}; - -/// Padding character -const PAD: u8 = b'='; - -/// Base64 encoding trait. -/// -/// This trait must be imported to make use of any Base64 alphabet defined -/// in this crate. -/// -/// The following encoding types impl this trait: -/// -/// - [`Base64`]: standard Base64 encoding with `=` padding. -/// - [`Base64Bcrypt`]: bcrypt Base64 encoding. -/// - [`Base64Crypt`]: `crypt(3)` Base64 encoding. -/// - [`Base64Unpadded`]: standard Base64 encoding *without* padding. -/// - [`Base64Url`]: URL-safe Base64 encoding with `=` padding. -/// - [`Base64UrlUnpadded`]: URL-safe Base64 encoding *without* padding. -pub trait Encoding: Alphabet { - /// Decode a Base64 string into the provided destination buffer. - fn decode(src: impl AsRef<[u8]>, dst: &mut [u8]) -> Result<&[u8], Error>; - - /// Decode a Base64 string in-place. - /// - /// NOTE: this method does not (yet) validate that padding is well-formed, - /// if the given Base64 encoding is padded. - fn decode_in_place(buf: &mut [u8]) -> Result<&[u8], InvalidEncodingError>; - - /// Decode a Base64 string into a byte vector. - #[cfg(feature = "alloc")] - fn decode_vec(input: &str) -> Result, Error>; - - /// Encode the input byte slice as Base64. - /// - /// Writes the result into the provided destination slice, returning an - /// ASCII-encoded Base64 string value. - fn encode<'a>(src: &[u8], dst: &'a mut [u8]) -> Result<&'a str, InvalidLengthError>; - - /// Encode input byte slice into a [`String`] containing Base64. - /// - /// # Panics - /// If `input` length is greater than `usize::MAX/4`. - #[cfg(feature = "alloc")] - fn encode_string(input: &[u8]) -> String; - - /// Get the length of Base64 produced by encoding the given bytes. - /// - /// WARNING: this function will return `0` for lengths greater than `usize::MAX/4`! - fn encoded_len(bytes: &[u8]) -> usize; -} - -impl Encoding for T { - fn decode(src: impl AsRef<[u8]>, dst: &mut [u8]) -> Result<&[u8], Error> { - let (src_unpadded, mut err) = if T::PADDED { - let (unpadded_len, e) = decode_padding(src.as_ref())?; - (&src.as_ref()[..unpadded_len], e) - } else { - (src.as_ref(), 0) - }; - - let dlen = decoded_len(src_unpadded.len()); - - if dlen > dst.len() { - return Err(Error::InvalidLength); - } - - let dst = &mut dst[..dlen]; - - let mut src_chunks = src_unpadded.chunks_exact(4); - let mut dst_chunks = dst.chunks_exact_mut(3); - for (s, d) in (&mut src_chunks).zip(&mut dst_chunks) { - err |= Self::decode_3bytes(s, d); - } - let src_rem = src_chunks.remainder(); - let dst_rem = dst_chunks.into_remainder(); - - err |= !(src_rem.is_empty() || src_rem.len() >= 2) as i16; - let mut tmp_out = [0u8; 3]; - let mut tmp_in = [b'A'; 4]; - tmp_in[..src_rem.len()].copy_from_slice(src_rem); - err |= Self::decode_3bytes(&tmp_in, &mut tmp_out); - dst_rem.copy_from_slice(&tmp_out[..dst_rem.len()]); - - if err == 0 { - validate_last_block::(src.as_ref(), dst)?; - Ok(dst) - } else { - Err(Error::InvalidEncoding) - } - } - - // TODO(tarcieri): explicitly checked/wrapped arithmetic - #[allow(clippy::integer_arithmetic)] - fn decode_in_place(mut buf: &mut [u8]) -> Result<&[u8], InvalidEncodingError> { - // TODO: eliminate unsafe code when LLVM12 is stable - // See: https://github.com/rust-lang/rust/issues/80963 - let mut err = if T::PADDED { - let (unpadded_len, e) = decode_padding(buf)?; - buf = &mut buf[..unpadded_len]; - e - } else { - 0 - }; - - let dlen = decoded_len(buf.len()); - let full_chunks = buf.len() / 4; - - for chunk in 0..full_chunks { - // SAFETY: `p3` and `p4` point inside `buf`, while they may overlap, - // read and write are clearly separated from each other and done via - // raw pointers. - #[allow(unsafe_code)] - unsafe { - debug_assert!(3 * chunk + 3 <= buf.len()); - debug_assert!(4 * chunk + 4 <= buf.len()); - - let p3 = buf.as_mut_ptr().add(3 * chunk) as *mut [u8; 3]; - let p4 = buf.as_ptr().add(4 * chunk) as *const [u8; 4]; - - let mut tmp_out = [0u8; 3]; - err |= Self::decode_3bytes(&*p4, &mut tmp_out); - *p3 = tmp_out; - } - } - - let src_rem_pos = 4 * full_chunks; - let src_rem_len = buf.len() - src_rem_pos; - let dst_rem_pos = 3 * full_chunks; - let dst_rem_len = dlen - dst_rem_pos; - - err |= !(src_rem_len == 0 || src_rem_len >= 2) as i16; - let mut tmp_in = [b'A'; 4]; - tmp_in[..src_rem_len].copy_from_slice(&buf[src_rem_pos..]); - let mut tmp_out = [0u8; 3]; - - err |= Self::decode_3bytes(&tmp_in, &mut tmp_out); - - if err == 0 { - // SAFETY: `dst_rem_len` is always smaller than 4, so we don't - // read outside of `tmp_out`, write and the final slicing never go - // outside of `buf`. - #[allow(unsafe_code)] - unsafe { - debug_assert!(dst_rem_pos + dst_rem_len <= buf.len()); - debug_assert!(dst_rem_len <= tmp_out.len()); - debug_assert!(dlen <= buf.len()); - - core::ptr::copy_nonoverlapping( - tmp_out.as_ptr(), - buf.as_mut_ptr().add(dst_rem_pos), - dst_rem_len, - ); - Ok(buf.get_unchecked(..dlen)) - } - } else { - Err(InvalidEncodingError) - } - } - - #[cfg(feature = "alloc")] - fn decode_vec(input: &str) -> Result, Error> { - let mut output = vec![0u8; decoded_len(input.len())]; - let len = Self::decode(input, &mut output)?.len(); - - if len <= output.len() { - output.truncate(len); - Ok(output) - } else { - Err(Error::InvalidLength) - } - } - - fn encode<'a>(src: &[u8], dst: &'a mut [u8]) -> Result<&'a str, InvalidLengthError> { - let elen = match encoded_len_inner(src.len(), T::PADDED) { - Some(v) => v, - None => return Err(InvalidLengthError), - }; - - if elen > dst.len() { - return Err(InvalidLengthError); - } - - let dst = &mut dst[..elen]; - - let mut src_chunks = src.chunks_exact(3); - let mut dst_chunks = dst.chunks_exact_mut(4); - - for (s, d) in (&mut src_chunks).zip(&mut dst_chunks) { - Self::encode_3bytes(s, d); - } - - let src_rem = src_chunks.remainder(); - - if T::PADDED { - if let Some(dst_rem) = dst_chunks.next() { - let mut tmp = [0u8; 3]; - tmp[..src_rem.len()].copy_from_slice(src_rem); - Self::encode_3bytes(&tmp, dst_rem); - - let flag = src_rem.len() == 1; - let mask = (flag as u8).wrapping_sub(1); - dst_rem[2] = (dst_rem[2] & mask) | (PAD & !mask); - dst_rem[3] = PAD; - } - } else { - let dst_rem = dst_chunks.into_remainder(); - - let mut tmp_in = [0u8; 3]; - let mut tmp_out = [0u8; 4]; - tmp_in[..src_rem.len()].copy_from_slice(src_rem); - Self::encode_3bytes(&tmp_in, &mut tmp_out); - dst_rem.copy_from_slice(&tmp_out[..dst_rem.len()]); - } - - debug_assert!(str::from_utf8(dst).is_ok()); - - // SAFETY: values written by `encode_3bytes` are valid one-byte UTF-8 chars - #[allow(unsafe_code)] - Ok(unsafe { str::from_utf8_unchecked(dst) }) - } - - #[cfg(feature = "alloc")] - fn encode_string(input: &[u8]) -> String { - let elen = encoded_len_inner(input.len(), T::PADDED).expect("input is too big"); - let mut dst = vec![0u8; elen]; - let res = Self::encode(input, &mut dst).expect("encoding error"); - - debug_assert_eq!(elen, res.len()); - debug_assert!(str::from_utf8(&dst).is_ok()); - - // SAFETY: `dst` is fully written and contains only valid one-byte UTF-8 chars - #[allow(unsafe_code)] - unsafe { - String::from_utf8_unchecked(dst) - } - } - - fn encoded_len(bytes: &[u8]) -> usize { - encoded_len_inner(bytes.len(), T::PADDED).unwrap_or(0) - } -} - -/// Validate padding is of the expected length compute unpadded length. -/// -/// Note that this method does not explicitly check that the padded data -/// is valid in and of itself: that is performed by `validate_last_block` as a -/// final step. -/// -/// Returns length-related errors eagerly as a [`Result`], and data-dependent -/// errors (i.e. malformed padding bytes) as `i16` to be combined with other -/// encoding-related errors prior to branching. -#[inline(always)] -pub(crate) fn decode_padding(input: &[u8]) -> Result<(usize, i16), InvalidEncodingError> { - if input.len() % 4 != 0 { - return Err(InvalidEncodingError); - } - - let unpadded_len = match *input { - [.., b0, b1] => is_pad_ct(b0) - .checked_add(is_pad_ct(b1)) - .and_then(|len| len.try_into().ok()) - .and_then(|len| input.len().checked_sub(len)) - .ok_or(InvalidEncodingError)?, - _ => input.len(), - }; - - let padding_len = input - .len() - .checked_sub(unpadded_len) - .ok_or(InvalidEncodingError)?; - - let err = match *input { - [.., b0] if padding_len == 1 => is_pad_ct(b0) ^ 1, - [.., b0, b1] if padding_len == 2 => (is_pad_ct(b0) & is_pad_ct(b1)) ^ 1, - _ => { - if padding_len == 0 { - 0 - } else { - return Err(InvalidEncodingError); - } - } - }; - - Ok((unpadded_len, err)) -} - -/// Validate that the last block of the decoded data round-trips back to the -/// encoded data. -fn validate_last_block(encoded: &[u8], decoded: &[u8]) -> Result<(), Error> { - if encoded.is_empty() && decoded.is_empty() { - return Ok(()); - } - - // TODO(tarcieri): explicitly checked/wrapped arithmetic - #[allow(clippy::integer_arithmetic)] - fn last_block_start(bytes: &[u8], block_size: usize) -> usize { - (bytes.len().saturating_sub(1) / block_size) * block_size - } - - let enc_block = encoded - .get(last_block_start(encoded, 4)..) - .ok_or(Error::InvalidEncoding)?; - - let dec_block = decoded - .get(last_block_start(decoded, 3)..) - .ok_or(Error::InvalidEncoding)?; - - // Round-trip encode the decoded block - let mut buf = [0u8; 4]; - let block = T::encode(dec_block, &mut buf)?; - - // Non-short-circuiting comparison of padding - // TODO(tarcieri): better constant-time mechanisms (e.g. `subtle`)? - if block - .as_bytes() - .iter() - .zip(enc_block.iter()) - .fold(0, |acc, (a, b)| acc | (a ^ b)) - == 0 - { - Ok(()) - } else { - Err(Error::InvalidEncoding) - } -} - -/// Get the length of the output from decoding the provided *unpadded* -/// Base64-encoded input. -/// -/// Note that this function does not fully validate the Base64 is well-formed -/// and may return incorrect results for malformed Base64. -// TODO(tarcieri): explicitly checked/wrapped arithmetic -#[allow(clippy::integer_arithmetic)] -#[inline(always)] -pub(crate) fn decoded_len(input_len: usize) -> usize { - // overflow-proof computation of `(3*n)/4` - let k = input_len / 4; - let l = input_len - 4 * k; - 3 * k + (3 * l) / 4 -} - -/// Branchless match that a given byte is the `PAD` character -// TODO(tarcieri): explicitly checked/wrapped arithmetic -#[allow(clippy::integer_arithmetic)] -#[inline(always)] -fn is_pad_ct(input: u8) -> i16 { - ((((PAD as i16 - 1) - input as i16) & (input as i16 - (PAD as i16 + 1))) >> 8) & 1 -} - -// TODO(tarcieri): explicitly checked/wrapped arithmetic -#[allow(clippy::integer_arithmetic)] -#[inline(always)] -const fn encoded_len_inner(n: usize, padded: bool) -> Option { - match n.checked_mul(4) { - Some(q) => { - if padded { - Some(((q / 3) + 3) & !3) - } else { - Some((q / 3) + (q % 3 != 0) as usize) - } - } - None => None, - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/errors.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/errors.rs deleted file mode 100644 index de08e6981015..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/errors.rs +++ /dev/null @@ -1,84 +0,0 @@ -//! Error types - -use core::fmt; - -const INVALID_ENCODING_MSG: &str = "invalid Base64 encoding"; -const INVALID_LENGTH_MSG: &str = "invalid Base64 length"; - -/// Insufficient output buffer length. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct InvalidLengthError; - -impl fmt::Display for InvalidLengthError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - f.write_str(INVALID_LENGTH_MSG) - } -} - -#[cfg(feature = "std")] -impl std::error::Error for InvalidLengthError {} - -/// Invalid encoding of provided Base64 string. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct InvalidEncodingError; - -impl fmt::Display for InvalidEncodingError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - f.write_str(INVALID_ENCODING_MSG) - } -} - -#[cfg(feature = "std")] -impl std::error::Error for InvalidEncodingError {} - -/// Generic error, union of [`InvalidLengthError`] and [`InvalidEncodingError`]. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub enum Error { - /// Invalid encoding of provided Base64 string. - InvalidEncoding, - - /// Insufficient output buffer length. - InvalidLength, -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - let s = match self { - Self::InvalidEncoding => INVALID_ENCODING_MSG, - Self::InvalidLength => INVALID_LENGTH_MSG, - }; - f.write_str(s) - } -} - -impl From for Error { - #[inline] - fn from(_: InvalidEncodingError) -> Error { - Error::InvalidEncoding - } -} - -impl From for Error { - #[inline] - fn from(_: InvalidLengthError) -> Error { - Error::InvalidLength - } -} - -impl From for Error { - #[inline] - fn from(_: core::str::Utf8Error) -> Error { - Error::InvalidEncoding - } -} - -#[cfg(feature = "std")] -impl From for std::io::Error { - fn from(err: Error) -> std::io::Error { - // TODO(tarcieri): better customize `ErrorKind`? - std::io::Error::new(std::io::ErrorKind::InvalidData, err) - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/lib.rs deleted file mode 100644 index f1094f9f15a6..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/lib.rs +++ /dev/null @@ -1,105 +0,0 @@ -#![no_std] -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" -)] -#![doc = include_str!("../README.md")] -#![warn( - clippy::integer_arithmetic, - clippy::mod_module_files, - clippy::panic, - clippy::panic_in_result_fn, - clippy::unwrap_used, - missing_docs, - rust_2018_idioms, - unsafe_code, - unused_lifetimes, - unused_qualifications -)] - -//! # Usage -//! -//! ## Allocating (enable `alloc` crate feature) -//! -//! ``` -//! # #[cfg(feature = "alloc")] -//! # { -//! use base64ct::{Base64, Encoding}; -//! -//! let bytes = b"example bytestring!"; -//! let encoded = Base64::encode_string(bytes); -//! assert_eq!(encoded, "ZXhhbXBsZSBieXRlc3RyaW5nIQ=="); -//! -//! let decoded = Base64::decode_vec(&encoded).unwrap(); -//! assert_eq!(decoded, bytes); -//! # } -//! ``` -//! -//! ## Heapless `no_std` usage -//! -//! ``` -//! use base64ct::{Base64, Encoding}; -//! -//! const BUF_SIZE: usize = 128; -//! -//! let bytes = b"example bytestring!"; -//! assert!(Base64::encoded_len(bytes) <= BUF_SIZE); -//! -//! let mut enc_buf = [0u8; BUF_SIZE]; -//! let encoded = Base64::encode(bytes, &mut enc_buf).unwrap(); -//! assert_eq!(encoded, "ZXhhbXBsZSBieXRlc3RyaW5nIQ=="); -//! -//! let mut dec_buf = [0u8; BUF_SIZE]; -//! let decoded = Base64::decode(encoded, &mut dec_buf).unwrap(); -//! assert_eq!(decoded, bytes); -//! ``` -//! -//! # Implementation -//! -//! Implemented using integer arithmetic alone without any lookup tables or -//! data-dependent branches, thereby providing portable "best effort" -//! constant-time operation. -//! -//! Not constant-time with respect to message length (only data). -//! -//! Adapted from the following constant-time C++ implementation of Base64: -//! -//! -//! -//! Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com). -//! Derived code is dual licensed MIT + Apache 2 (with permission from Sc00bz). - -#[cfg(feature = "alloc")] -#[macro_use] -extern crate alloc; -#[cfg(feature = "std")] -extern crate std; - -mod alphabet; -mod decoder; -mod encoder; -mod encoding; -mod errors; -mod line_ending; - -#[cfg(test)] -mod test_vectors; - -pub use crate::{ - alphabet::{ - bcrypt::Base64Bcrypt, - crypt::Base64Crypt, - shacrypt::Base64ShaCrypt, - standard::{Base64, Base64Unpadded}, - url::{Base64Url, Base64UrlUnpadded}, - }, - decoder::Decoder, - encoder::Encoder, - encoding::Encoding, - errors::{Error, InvalidEncodingError, InvalidLengthError}, - line_ending::LineEnding, -}; - -/// Minimum supported line width. -const MIN_LINE_WIDTH: usize = 4; diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/line_ending.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/line_ending.rs deleted file mode 100644 index dfb168eab82f..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/line_ending.rs +++ /dev/null @@ -1,53 +0,0 @@ -//! Line endings. - -/// Carriage return -pub(crate) const CHAR_CR: u8 = 0x0d; - -/// Line feed -pub(crate) const CHAR_LF: u8 = 0x0a; - -/// Line endings: variants of newline characters that can be used with Base64. -/// -/// Use [`LineEnding::default`] to get an appropriate line ending for the -/// current operating system. -#[allow(clippy::upper_case_acronyms)] -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub enum LineEnding { - /// Carriage return: `\r` (Pre-OS X Macintosh) - CR, - - /// Line feed: `\n` (Unix OSes) - LF, - - /// Carriage return + line feed: `\r\n` (Windows) - CRLF, -} - -impl Default for LineEnding { - // Default line ending matches conventions for target OS - #[cfg(windows)] - fn default() -> LineEnding { - LineEnding::CRLF - } - #[cfg(not(windows))] - fn default() -> LineEnding { - LineEnding::LF - } -} - -#[allow(clippy::len_without_is_empty)] -impl LineEnding { - /// Get the byte serialization of this [`LineEnding`]. - pub fn as_bytes(self) -> &'static [u8] { - match self { - LineEnding::CR => &[CHAR_CR], - LineEnding::LF => &[CHAR_LF], - LineEnding::CRLF => &[CHAR_CR, CHAR_LF], - } - } - - /// Get the encoded length of this [`LineEnding`]. - pub fn len(self) -> usize { - self.as_bytes().len() - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/test_vectors.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/test_vectors.rs deleted file mode 100644 index 61f49581eddb..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/src/test_vectors.rs +++ /dev/null @@ -1,70 +0,0 @@ -//! Base64 test vectors. - -/// Padded Base64-encoded example -pub(crate) const PADDED_BASE64: &str = - "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHwf2HMM5TRXvo2SQJjsNkiDD5KqiiNjrGVv3UUh+mMT5RHxiRtOnlqvjhQtBq0VpmpCV/PwUdhOig4vkbqAcEc="; -pub(crate) const PADDED_BIN: &[u8] = &[ - 0, 0, 0, 19, 101, 99, 100, 115, 97, 45, 115, 104, 97, 50, 45, 110, 105, 115, 116, 112, 50, 53, - 54, 0, 0, 0, 8, 110, 105, 115, 116, 112, 50, 53, 54, 0, 0, 0, 65, 4, 124, 31, 216, 115, 12, - 229, 52, 87, 190, 141, 146, 64, 152, 236, 54, 72, 131, 15, 146, 170, 138, 35, 99, 172, 101, - 111, 221, 69, 33, 250, 99, 19, 229, 17, 241, 137, 27, 78, 158, 90, 175, 142, 20, 45, 6, 173, - 21, 166, 106, 66, 87, 243, 240, 81, 216, 78, 138, 14, 47, 145, 186, 128, 112, 71, -]; - -/// Unpadded Base64-encoded example -pub(crate) const UNPADDED_BASE64: &str = - "AAAAC3NzaC1lZDI1NTE5AAAAILM+rvN+ot98qgEN796jTiQfZfG1KaT0PtFDJ/XFSqti"; -pub(crate) const UNPADDED_BIN: &[u8] = &[ - 0, 0, 0, 11, 115, 115, 104, 45, 101, 100, 50, 53, 53, 49, 57, 0, 0, 0, 32, 179, 62, 174, 243, - 126, 162, 223, 124, 170, 1, 13, 239, 222, 163, 78, 36, 31, 101, 241, 181, 41, 164, 244, 62, - 209, 67, 39, 245, 197, 74, 171, 98, -]; - -/// Padded multi-line Base64 example (from the `ssh-key` crate's `id_ed25519`) -pub(crate) const MULTILINE_PADDED_BASE64: &str = - "b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW\n\ - QyNTUxOQAAACCzPq7zfqLffKoBDe/eo04kH2XxtSmk9D7RQyf1xUqrYgAAAJgAIAxdACAM\n\ - XQAAAAtzc2gtZWQyNTUxOQAAACCzPq7zfqLffKoBDe/eo04kH2XxtSmk9D7RQyf1xUqrYg\n\ - AAAEC2BsIi0QwW2uFscKTUUXNHLsYX4FxlaSDSblbAj7WR7bM+rvN+ot98qgEN796jTiQf\n\ - ZfG1KaT0PtFDJ/XFSqtiAAAAEHVzZXJAZXhhbXBsZS5jb20BAgMEBQ=="; -pub(crate) const MULTILINE_PADDED_BIN: &[u8] = &[ - 111, 112, 101, 110, 115, 115, 104, 45, 107, 101, 121, 45, 118, 49, 0, 0, 0, 0, 4, 110, 111, - 110, 101, 0, 0, 0, 4, 110, 111, 110, 101, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 51, 0, 0, 0, 11, - 115, 115, 104, 45, 101, 100, 50, 53, 53, 49, 57, 0, 0, 0, 32, 179, 62, 174, 243, 126, 162, 223, - 124, 170, 1, 13, 239, 222, 163, 78, 36, 31, 101, 241, 181, 41, 164, 244, 62, 209, 67, 39, 245, - 197, 74, 171, 98, 0, 0, 0, 152, 0, 32, 12, 93, 0, 32, 12, 93, 0, 0, 0, 11, 115, 115, 104, 45, - 101, 100, 50, 53, 53, 49, 57, 0, 0, 0, 32, 179, 62, 174, 243, 126, 162, 223, 124, 170, 1, 13, - 239, 222, 163, 78, 36, 31, 101, 241, 181, 41, 164, 244, 62, 209, 67, 39, 245, 197, 74, 171, 98, - 0, 0, 0, 64, 182, 6, 194, 34, 209, 12, 22, 218, 225, 108, 112, 164, 212, 81, 115, 71, 46, 198, - 23, 224, 92, 101, 105, 32, 210, 110, 86, 192, 143, 181, 145, 237, 179, 62, 174, 243, 126, 162, - 223, 124, 170, 1, 13, 239, 222, 163, 78, 36, 31, 101, 241, 181, 41, 164, 244, 62, 209, 67, 39, - 245, 197, 74, 171, 98, 0, 0, 0, 16, 117, 115, 101, 114, 64, 101, 120, 97, 109, 112, 108, 101, - 46, 99, 111, 109, 1, 2, 3, 4, 5, -]; - -/// Unpadded multi-line Base64 example (from the `ssh-key` crate's `id_ecdsa_p256`). -pub(crate) const MULTILINE_UNPADDED_BASE64: &str = - "b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS\n\ - 1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQR8H9hzDOU0V76NkkCY7DZIgw+Sqooj\n\ - Y6xlb91FIfpjE+UR8YkbTp5ar44ULQatFaZqQlfz8FHYTooOL5G6gHBHAAAAsB8RBhUfEQ\n\ - YVAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHwf2HMM5TRXvo2S\n\ - QJjsNkiDD5KqiiNjrGVv3UUh+mMT5RHxiRtOnlqvjhQtBq0VpmpCV/PwUdhOig4vkbqAcE\n\ - cAAAAhAMp4pkd0v643EjIkk38DmJYBiXB6ygqGRc60NZxCO6B5AAAAEHVzZXJAZXhhbXBs\n\ - ZS5jb20BAgMEBQYH"; -pub(crate) const MULTILINE_UNPADDED_BIN: &[u8] = &[ - 111, 112, 101, 110, 115, 115, 104, 45, 107, 101, 121, 45, 118, 49, 0, 0, 0, 0, 4, 110, 111, - 110, 101, 0, 0, 0, 4, 110, 111, 110, 101, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 104, 0, 0, 0, 19, - 101, 99, 100, 115, 97, 45, 115, 104, 97, 50, 45, 110, 105, 115, 116, 112, 50, 53, 54, 0, 0, 0, - 8, 110, 105, 115, 116, 112, 50, 53, 54, 0, 0, 0, 65, 4, 124, 31, 216, 115, 12, 229, 52, 87, - 190, 141, 146, 64, 152, 236, 54, 72, 131, 15, 146, 170, 138, 35, 99, 172, 101, 111, 221, 69, - 33, 250, 99, 19, 229, 17, 241, 137, 27, 78, 158, 90, 175, 142, 20, 45, 6, 173, 21, 166, 106, - 66, 87, 243, 240, 81, 216, 78, 138, 14, 47, 145, 186, 128, 112, 71, 0, 0, 0, 176, 31, 17, 6, - 21, 31, 17, 6, 21, 0, 0, 0, 19, 101, 99, 100, 115, 97, 45, 115, 104, 97, 50, 45, 110, 105, 115, - 116, 112, 50, 53, 54, 0, 0, 0, 8, 110, 105, 115, 116, 112, 50, 53, 54, 0, 0, 0, 65, 4, 124, 31, - 216, 115, 12, 229, 52, 87, 190, 141, 146, 64, 152, 236, 54, 72, 131, 15, 146, 170, 138, 35, 99, - 172, 101, 111, 221, 69, 33, 250, 99, 19, 229, 17, 241, 137, 27, 78, 158, 90, 175, 142, 20, 45, - 6, 173, 21, 166, 106, 66, 87, 243, 240, 81, 216, 78, 138, 14, 47, 145, 186, 128, 112, 71, 0, 0, - 0, 33, 0, 202, 120, 166, 71, 116, 191, 174, 55, 18, 50, 36, 147, 127, 3, 152, 150, 1, 137, 112, - 122, 202, 10, 134, 69, 206, 180, 53, 156, 66, 59, 160, 121, 0, 0, 0, 16, 117, 115, 101, 114, - 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 1, 2, 3, 4, 5, 6, 7, -]; diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/bcrypt.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/bcrypt.rs deleted file mode 100644 index 4ecbfa74d4b3..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/bcrypt.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! bcrypt Base64 tests - -#[macro_use] -mod common; - -use crate::common::*; -use base64ct::Base64Bcrypt; - -const TEST_VECTORS: &[TestVector] = &[ - TestVector { raw: b"", b64: "" }, - TestVector { - raw: b"\0", - b64: "..", - }, - TestVector { - raw: b"***", - b64: "Igmo", - }, - TestVector { - raw: b"\x01\x02\x03\x04", - b64: ".OGB/.", - }, - TestVector { - raw: b"\xAD\xAD\xAD\xAD\xAD", - b64: "pY0rpYy", - }, - TestVector { - raw: b"\xFF\xEF\xFE\xFF\xEF\xFE", - b64: "98989898", - }, - TestVector { - raw: b"\xFF\xFF\xFF\xFF\xFF", - b64: "9999996", - }, - TestVector { - raw: b"\x40\xC1\x3F\xBD\x05\x4C\x72\x2A\xA3\xC2\xF2\x11\x73\xC0\x69\xEA\ - \x49\x7D\x35\x29\x6B\xCC\x24\x65\xF6\xF9\xD0\x41\x08\x7B\xD7\xA9", - b64: "OKC9tOTKagohutGPa6/n4ij7LQjpxAPj7tlOOOf5z4i", - }, - TestVector { - raw: b"\x00\x10\x83\x10Q\x87 \x92\x8B0\xD3\x8FA\x14\x93QU\x97a\x96\x9Bq\ - \xD7\x9F\x82\x18\xA3\x92Y\xA7\xA2\x9A\xAB\xB2\xDB\xAF\xC3\x1C\xB3\ - \xFB\xF0\x00", - b64: "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx89..", - }, -]; - -impl_tests!(Base64Bcrypt); - -#[test] -fn reject_trailing_whitespace() { - let input = "OKC9tOTKagohutGPa6/n4ij7LQjpxAPj7tlOOOf5z4i\n"; - let mut buf = [0u8; 1024]; - assert_eq!( - Base64Bcrypt::decode(input, &mut buf), - Err(Error::InvalidEncoding) - ); -} - -#[test] -fn unpadded_reject_trailing_equals() { - let input = "OKC9tOTKagohutGPa6/n4ij7LQjpxAPj7tlOOOf5z4i="; - let mut buf = [0u8; 1024]; - assert_eq!( - Base64Bcrypt::decode(input, &mut buf), - Err(Error::InvalidEncoding) - ); -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/common/mod.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/common/mod.rs deleted file mode 100644 index 3910b33b9759..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/common/mod.rs +++ /dev/null @@ -1,80 +0,0 @@ -//! Common testing functionality - -/// Base64 test vector -pub struct TestVector { - pub raw: &'static [u8], - pub b64: &'static str, -} - -/// Generate test suite for a particular Base64 flavor -#[macro_export] -macro_rules! impl_tests { - ($encoding:ty) => { - use base64ct::{Encoding, Error}; - - #[test] - fn encode_test_vectors() { - let mut buf = [0u8; 1024]; - - for vector in TEST_VECTORS { - let out = <$encoding>::encode(vector.raw, &mut buf).unwrap(); - assert_eq!(<$encoding>::encoded_len(vector.raw), vector.b64.len()); - assert_eq!(vector.b64, &out[..]); - - #[cfg(feature = "alloc")] - { - let out = <$encoding>::encode_string(vector.raw); - assert_eq!(vector.b64, &out[..]); - } - } - } - - #[test] - fn decode_test_vectors() { - let mut buf = [0u8; 1024]; - - for vector in TEST_VECTORS { - let out = <$encoding>::decode(vector.b64, &mut buf).unwrap(); - assert_eq!(vector.raw, &out[..]); - - let n = vector.b64.len(); - buf[..n].copy_from_slice(vector.b64.as_bytes()); - let out = <$encoding>::decode_in_place(&mut buf[..n]).unwrap(); - assert_eq!(vector.raw, out); - - #[cfg(feature = "alloc")] - { - let out = <$encoding>::decode_vec(vector.b64).unwrap(); - assert_eq!(vector.raw, &out[..]); - } - } - } - - #[test] - fn encode_and_decode_various_lengths() { - let data = [b'X'; 64]; - let mut inbuf = [0u8; 1024]; - let mut outbuf = [0u8; 1024]; - - for i in 0..data.len() { - let encoded = <$encoding>::encode(&data[..i], &mut inbuf).unwrap(); - - // Make sure it round trips - let decoded = <$encoding>::decode(encoded, &mut outbuf).unwrap(); - assert_eq!(decoded, &data[..i]); - - let elen = <$encoding>::encode(&data[..i], &mut inbuf).unwrap().len(); - let buf = &mut inbuf[..elen]; - let decoded = <$encoding>::decode_in_place(buf).unwrap(); - assert_eq!(decoded, &data[..i]); - - #[cfg(feature = "alloc")] - { - let encoded = <$encoding>::encode_string(&data[..i]); - let decoded = <$encoding>::decode_vec(&encoded).unwrap(); - assert_eq!(decoded, &data[..i]); - } - } - } - }; -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/crypt.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/crypt.rs deleted file mode 100644 index cc285f9bd607..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/crypt.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! `crypt(3)` Base64 tests - -#[macro_use] -mod common; - -use crate::common::*; -use base64ct::Base64Crypt; - -const TEST_VECTORS: &[TestVector] = &[ - TestVector { raw: b"", b64: "" }, - TestVector { - raw: b"\0", - b64: "..", - }, - TestVector { - raw: b"***", - b64: "8Wce", - }, - TestVector { - raw: b"\x01\x02\x03\x04", - b64: ".E61/.", - }, - TestVector { - raw: b"\xAD\xAD\xAD\xAD\xAD", - b64: "fOqhfOo", - }, - TestVector { - raw: b"\xFF\xEF\xFE\xFF\xEF\xFE", - b64: "zyzyzyzy", - }, - TestVector { - raw: b"\xFF\xFF\xFF\xFF\xFF", - b64: "zzzzzzw", - }, - TestVector { - raw: b"\x40\xC1\x3F\xBD\x05\x4C\x72\x2A\xA3\xC2\xF2\x11\x73\xC0\x69\xEA\ - \x49\x7D\x35\x29\x6B\xCC\x24\x65\xF6\xF9\xD0\x41\x08\x7B\xD7\xA9", - b64: "EA2zjEJAQWeXkj6FQw/duYZxBGZfn0FZxjbEEEVvpuY", - }, - TestVector { - raw: b"\x00\x10\x83\x10Q\x87 \x92\x8B0\xD3\x8FA\x14\x93QU\x97a\x96\x9Bq\ - \xD7\x9F\x82\x18\xA3\x92Y\xA7\xA2\x9A\xAB\xB2\xDB\xAF\xC3\x1C\xB3\ - \xFB\xF0\x00", - b64: "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnyz..", - }, -]; - -impl_tests!(Base64Crypt); - -#[test] -fn reject_trailing_whitespace() { - let input = "OKC9tOTKagohutGPa6/n4ij7LQjpxAPj7tlOOOf5z4i\n"; - let mut buf = [0u8; 1024]; - assert_eq!( - Base64Crypt::decode(input, &mut buf), - Err(Error::InvalidEncoding) - ); -} - -#[test] -fn unpadded_reject_trailing_equals() { - let input = "OKC9tOTKagohutGPa6/n4ij7LQjpxAPj7tlOOOf5z4i="; - let mut buf = [0u8; 1024]; - assert_eq!( - Base64Crypt::decode(input, &mut buf), - Err(Error::InvalidEncoding) - ); -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/proptests.proptest-regressions b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/proptests.proptest-regressions deleted file mode 100644 index 473fcecd2a7b..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/proptests.proptest-regressions +++ /dev/null @@ -1,10 +0,0 @@ -# Seeds for failure cases proptest has generated in the past. It is -# automatically read and these particular cases re-run before any -# novel cases are generated. -# -# It is recommended to check this file in to source control so that -# everyone who runs the test benefits from these saved cases. -cc ea4af6a6a3c5feddd17be51d3bb3d863881547acf50b553e76da3f34f8b755d4 # shrinks to base64ish = "" -cc 348d4acf2c3d1e8db3772f5645179e24b50178747469da9709e60800175eef80 # shrinks to bytes = [240, 144, 128, 128, 240, 144, 128, 128, 32, 32, 32, 194, 161, 48, 97, 97, 65, 194, 161, 32, 97, 194, 161, 32, 240, 144, 128, 128, 194, 161, 48, 32, 97, 194, 161, 240, 144, 128, 128, 32, 224, 160, 128, 97, 224, 160, 128, 48, 48, 194, 161, 32, 240, 144, 128, 128, 11, 65, 97, 48, 65, 65, 97, 11, 240, 144, 128, 128, 240, 144, 128, 128, 48, 224, 160, 128, 194, 161, 32, 32, 194, 161, 32, 48, 97, 240, 144, 128, 128, 224, 160, 128, 240, 144, 128, 128, 0, 224, 160, 128, 32, 240, 144, 128, 128, 0, 32, 32, 97, 240, 144, 128, 128, 240, 144, 128, 128, 240, 144, 128, 128, 240, 144, 128, 128, 0, 0, 240, 144, 128, 128, 32, 240, 144, 128, 128, 32, 48, 65, 11, 32, 65, 48, 48, 65, 65, 194, 161, 32, 224, 160, 128, 240, 144, 128, 128, 224, 160, 128, 0, 65, 0, 65, 32, 194, 161, 240, 144, 128, 128, 32, 65, 32, 0, 97, 32, 97, 11, 11, 48, 97, 97, 240, 144, 128, 128, 65, 240, 144, 128, 128, 194, 161], line_width = 10, chunk_size = 163 -cc 0c0ee7f6a60d24431333f5c39c506b818a6c21022e39288619c8f78f29d30b1c # shrinks to bytes = [240, 144, 128, 128, 194, 161, 194, 161, 240, 144, 128, 128, 194, 161, 240, 144, 128, 128, 65, 224, 160, 128, 97, 224, 160, 128, 32, 97, 32, 65, 224, 160, 128, 0, 97, 0, 240, 144, 128, 128, 97, 194, 161, 32, 240, 144, 128, 128, 11, 48, 32, 65, 32, 240, 144, 128, 128, 97, 194, 161, 48, 48, 240, 144, 128, 128, 194, 161, 194, 161, 32, 194, 161, 48, 0, 32, 48, 224, 160, 128, 65, 240, 144, 128, 128, 11, 65, 11, 240, 144, 128, 128, 32, 32, 194, 161, 240, 144, 128, 128, 224, 160, 128, 240, 144, 128, 128, 194, 161, 224, 160, 128, 65, 32, 240, 144, 128, 128, 32, 240, 144, 128, 128, 48, 240, 144, 128, 128, 0, 48, 240, 144, 128, 128, 48, 65, 65, 11, 0, 65, 240, 144, 128, 128, 240, 144, 128, 128, 32, 65, 240, 144, 128, 128, 112, 75, 46, 232, 143, 132, 240, 159, 149, 180, 101, 92, 11, 42, 98, 244, 142, 150, 136, 83, 13, 243, 189, 168, 131, 194, 154, 9, 243, 129, 165, 130, 241, 138, 188, 150, 39, 241, 170, 133, 154, 39, 61, 244, 136, 146, 157, 46, 91, 108, 34, 66, 0, 239, 187, 191, 34, 240, 158, 187, 152, 241, 187, 172, 188, 46, 239, 191, 189, 244, 143, 139, 131, 13, 13, 226, 128, 174, 60, 200, 186, 194, 151, 27, 105, 43, 226, 128, 174, 70, 0, 38, 127, 194, 133, 195, 177, 123, 127, 121, 241, 128, 141, 141, 244, 137, 146, 189, 55, 54, 9, 240, 159, 149, 180, 2, 209, 168, 239, 187, 191, 11, 34, 123, 32, 42, 242, 171, 149, 149, 102, 241, 174, 190, 188, 242, 144, 186, 145, 1, 84, 34, 56, 7, 0, 194, 188, 43, 117, 48, 96, 11, 60, 242, 190, 170, 187, 47, 99, 37, 241, 175, 142, 186, 240, 178, 162, 136, 46, 2, 241, 176, 162, 162, 37, 242, 148, 135, 179, 11, 36, 104, 244, 130, 136, 177], line_width = 24, chunk_size = 240 -cc b6d81102accbff17f00786b06c6040fc59fee8aa087033c9b5604d2a3f246afd # shrinks to bytes = [32, 65, 11, 97, 97, 32, 240, 144, 128, 128, 97, 32, 65, 0, 0, 32, 240, 144, 128, 128, 97, 65, 97, 97, 240, 144, 128, 128, 240, 144, 128, 128, 65, 48, 240, 144, 128, 128, 240, 144, 128, 128, 32, 0, 97, 97, 240, 144, 128, 128, 65, 32, 194, 161, 65, 0, 32, 11, 97, 32, 32, 11, 32, 240, 144, 128, 128, 240, 144, 128, 128, 194, 128, 32, 48, 65, 32, 240, 144, 128, 128, 240, 144, 128, 128, 240, 144, 128, 128, 194, 161, 32, 194, 161, 48, 224, 160, 128, 240, 144, 128, 128, 97, 32, 0, 48, 240, 144, 128, 128, 0, 11, 240, 144, 128, 128, 97, 240, 144, 128, 128, 11, 32, 0, 32, 0, 194, 161, 194, 161, 56, 242, 150, 180, 168, 243, 187, 153, 181, 46, 36, 121, 70, 8, 226, 128, 174, 242, 135, 172, 189, 0, 194, 169, 244, 130, 145, 146, 240, 159, 149, 180, 63, 240, 184, 155, 139, 27, 243, 185, 138, 139, 194, 162, 46, 242, 148, 129, 171, 195, 143, 56, 241, 147, 151, 173, 240, 159, 149, 180, 33, 89, 36, 37, 240, 159, 149, 180, 200, 186, 117, 194, 165, 77, 241, 171, 180, 143, 60, 96, 242, 175, 134, 177, 27, 1, 42, 242, 145, 189, 151, 92, 39, 96, 38, 243, 181, 148, 171, 243, 164, 185, 188, 47, 195, 181, 0, 226, 128, 174, 13, 233, 136, 141, 57, 200, 186, 243, 129, 145, 159, 242, 137, 177, 176, 122, 61, 243, 140, 180, 151, 239, 191, 189, 80, 194, 144, 121, 42, 239, 191, 189, 231, 173, 145, 75, 91, 0, 123, 238, 154, 139, 58, 240, 179, 187, 172, 107, 13, 13, 123, 241, 152, 132, 160, 242, 130, 149, 190, 92, 239, 187, 191, 117, 241, 182, 130, 165, 241, 165, 155, 168, 39, 60, 0, 0, 13, 200, 186, 83, 37, 243, 174, 183, 166, 11, 0, 237, 134, 157, 39, 58, 113, 44, 243, 135, 142, 174, 9, 9, 195, 184, 74, 241, 146, 132, 133, 34, 58, 92, 123, 239, 187, 191, 37, 58, 239, 187, 191, 77, 9, 243, 183, 143, 189, 243, 159, 143, 171, 243, 162, 128, 179, 241, 137, 158, 163, 127, 60, 195, 159, 106, 47, 242, 135, 154, 161, 51, 243, 160, 136, 149, 91, 241, 175, 181, 149, 96, 58, 46, 11, 37, 107, 32, 52, 237, 136, 144, 77, 194, 156, 42, 13, 39, 61, 2, 59, 48, 58, 240, 159, 149, 180, 4, 96, 127, 230, 166, 145, 58, 239, 187, 191, 242, 135, 132, 146, 241, 178, 129, 185, 36], line_width = 118, chunk_size = 147 diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/proptests.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/proptests.rs deleted file mode 100644 index 4d5e1890a466..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/proptests.rs +++ /dev/null @@ -1,152 +0,0 @@ -//! Equivalence tests between `base64` crate and `base64ct`. - -#![cfg(feature = "std")] -// TODO(tarcieri): fix `base64` crate deprecations -// warning: use of deprecated function `base64::encode`: Use Engine::encode -#![allow(deprecated)] - -use base64ct::{Base64 as Base64ct, Encoding}; -use proptest::{prelude::*, string::*}; -use std::iter; - -/// Incremental Base64 decoder. -type Decoder<'a> = base64ct::Decoder<'a, Base64ct>; - -/// Incremental Base64 encoder. -type Encoder<'a> = base64ct::Encoder<'a, Base64ct>; - -proptest! { - /// Ensure `base64ct` decodes data encoded by `base64` ref crate - #[test] - fn decode_equiv(bytes in bytes_regex(".{0,256}").unwrap()) { - let encoded = base64::encode(&bytes); - let decoded = Base64ct::decode_vec(&encoded); - prop_assert_eq!(Ok(bytes), decoded); - } - - /// Ensure that `base64ct`'s incremental decoder is able to decode randomly - /// generated inputs encoded by the `base64` ref crate - #[test] - fn decode_incremental(bytes in bytes_regex(".{1,256}").unwrap(), chunk_size in 1..256usize) { - let encoded = base64::encode(&bytes); - let chunk_size = match chunk_size % bytes.len() { - 0 => 1, - n => n - }; - - let mut buffer = [0u8; 384]; - let mut decoder = Decoder::new(encoded.as_bytes()).unwrap(); - let mut remaining_len = decoder.remaining_len(); - - for chunk in bytes.chunks(chunk_size) { - prop_assert!(!decoder.is_finished()); - - let decoded = decoder.decode(&mut buffer[..chunk.len()]); - prop_assert_eq!(Ok(chunk), decoded); - - remaining_len -= decoded.unwrap().len(); - prop_assert_eq!(remaining_len, decoder.remaining_len()); - } - - prop_assert!(decoder.is_finished()); - prop_assert_eq!(decoder.remaining_len(), 0); - } - - #[test] - fn decode_incremental_wrapped( - bytes in bytes_regex(".{1,256}").unwrap(), - line_width in 4..128usize, - chunk_size in 1..256usize - ) { - for line_ending in ["\r", "\n", "\r\n"] { - let encoded = base64::encode(&bytes); - - let mut encoded_wrapped = Vec::new(); - let mut lines = encoded.as_bytes().chunks_exact(line_width); - - for line in &mut lines { - encoded_wrapped.extend_from_slice(line); - encoded_wrapped.extend_from_slice(line_ending.as_bytes()); - } - - let last = lines.remainder(); - - if last.is_empty() { - encoded_wrapped.truncate(encoded_wrapped.len() - line_ending.len()); - } else { - encoded_wrapped.extend_from_slice(last); - } - - let chunk_size = match chunk_size % bytes.len() { - 0 => 1, - n => n - }; - - let mut buffer = [0u8; 384]; - let mut decoder = Decoder::new_wrapped(&encoded_wrapped, line_width).unwrap(); - let mut remaining_len = decoder.remaining_len(); - - for chunk in bytes.chunks(chunk_size) { - prop_assert!(!decoder.is_finished()); - - let decoded = decoder.decode(&mut buffer[..chunk.len()]); - prop_assert_eq!(Ok(chunk), decoded); - - remaining_len -= decoded.unwrap().len(); - prop_assert_eq!(remaining_len, decoder.remaining_len()); - } - - prop_assert!(decoder.is_finished()); - prop_assert_eq!(decoder.remaining_len(), 0); - } - } - - /// Ensure `base64ct` and `base64` ref crate decode randomly generated - /// inputs equivalently. - /// - /// Inputs are selected to be valid characters in the standard Base64 - /// padded alphabet, but are not necessarily valid Base64. - #[test] - fn decode_random(base64ish in string_regex("[A-Za-z0-9+/]{0,256}").unwrap()) { - let base64ish_padded = match base64ish.len() % 4 { - 0 => base64ish, - n => { - let padding_len = 4 - n; - base64ish + &iter::repeat("=").take(padding_len).collect::() - } - }; - - let decoded_ct = Base64ct::decode_vec(&base64ish_padded).ok(); - let decoded_ref = base64::decode(&base64ish_padded).ok(); - prop_assert_eq!(decoded_ct, decoded_ref); - } - - /// Ensure `base64ct` and the `base64` ref crate encode randomly generated - /// inputs equivalently. - #[test] - fn encode_equiv(bytes in bytes_regex(".{0,256}").unwrap()) { - let encoded_ct = Base64ct::encode_string(&bytes); - let encoded_ref = base64::encode(&bytes); - prop_assert_eq!(encoded_ct, encoded_ref); - } - - /// Ensure that `base64ct`'s incremental encoder is able to encode randomly - /// generated inputs which match what's encoded by the `base64` ref crate - #[test] - fn encode_incremental(bytes in bytes_regex(".{1,256}").unwrap(), chunk_size in 1..256usize) { - let expected = base64::encode(&bytes); - let chunk_size = match chunk_size % bytes.len() { - 0 => 1, - n => n - }; - - let mut buffer = [0u8; 1024]; - let mut encoder = Encoder::new(&mut buffer).unwrap(); - - for chunk in bytes.chunks(chunk_size) { - encoder.encode(chunk).unwrap(); - } - - prop_assert_eq!(expected, encoder.finish().unwrap()); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/shacrypt.rs b/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/shacrypt.rs deleted file mode 100644 index a69f7c7d14dc..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/base64ct-1.6.0/tests/shacrypt.rs +++ /dev/null @@ -1,98 +0,0 @@ -//! `crypt(3)` Base64 tests - -#[macro_use] -mod common; - -use crate::common::*; -use base64ct::Base64ShaCrypt; - -const TEST_VECTORS: &[TestVector] = &[ - TestVector { raw: b"", b64: "" }, - TestVector { - raw: b"\x55", - b64: "J/", - }, - TestVector { - raw: b"\x55\xaa", - b64: "Jd8", - }, - TestVector { - raw: b"\x55\xaa\x55", - b64: "JdOJ", - }, - TestVector { - raw: b"\x55\xaa\x55\xaa", - b64: "JdOJe0", - }, - TestVector { - raw: b"\x55\xaa\x55\xaa\x55", - b64: "JdOJeK3", - }, - TestVector { - raw: b"\x55\xaa\x55\xaa\x55\xaa", - b64: "JdOJeKZe", - }, - TestVector { - raw: b"\x55\xaa\x55\xaf", - b64: "JdOJj0", - }, - TestVector { - raw: b"\x55\xaa\x55\xaa\x5f", - b64: "JdOJey3", - }, - TestVector { - raw: b"\0", - b64: "..", - }, - TestVector { - raw: b"***", - b64: "ecW8", - }, - TestVector { - raw: b"\x01\x02\x03\x04", - b64: "/6k.2.", - }, - TestVector { - raw: b"\xAD\xAD\xAD\xAD\xAD", - b64: "hqOfhq8", - }, - TestVector { - raw: b"\xFF\xEF\xFE\xFF\xEF\xFE", - b64: "zzizzziz", - }, - TestVector { - raw: b"\xFF\xFF\xFF\xFF\xFF", - b64: "zzzzzzD", - }, - TestVector { - raw: b"\x40\xC1\x3F\xBD\x05\x4C\x72\x2A\xA3\xC2\xF2\x11\x73\xC0\x69\xEA\ - \x49\x7D\x35\x29\x6B\xCC\x24\x65\xF6\xF9\xD0\x41\x08\x7B\xD7\xA9", - b64: ".3wDxK.Hmdmc09T2n/QOebITpYmOAHGNqbDo/VkSLb8", - }, - TestVector { - raw: b"@ \x0cDa\x1cH\xa2,L\xe3` impl on `ObjectIdentifier` - -## Changed -- MSRV 1.47+ -- Renamed the following methods: - - `ObjectIdentifier::new` => `ObjectIdentifier::from_arcs` - - `ObjectIdentifier::parse` => `ObjectIdentifier::new` - - `ObjectIdentifier::from_ber` => `ObjectIdentifier::from_bytes` - -### Removed -- Deprecated methods -- `alloc` feature - only used by aforementioned deprecated methods -- `TryFrom<&[Arc]>` impl on `ObjectIdentifier` - use `::from_arcs` - -## 0.4.5 (2021-03-04) -### Added -- `Hash` and `Ord` impls on `ObjectIdentifier` - -## 0.4.4 (2021-02-28) -### Added -- `ObjectIdentifier::as_bytes` method - -### Changed -- Internal representation changed to BER/DER -- Deprecated `ObjectIdentifier::ber_len`, `::write_ber`, and `::to_ber` - -## 0.4.3 (2021-02-24) -### Added -- Const-friendly OID string parser - -## 0.4.2 (2021-02-19) -### Fixed -- Bug in root arc calculation - -## 0.4.1 (2020-12-21) -### Fixed -- Bug in const initializer - -## 0.4.0 (2020-12-16) -### Added -- `Arcs` iterator - -### Changed -- Rename "nodes" to "arcs" -- Layout optimization -- Refactor and improve length limits - -## 0.3.5 (2020-12-12) -### Added -- `ObjectIdentifier::{write_ber, to_ber}` methods - -## 0.3.4 (2020-12-06) -### Changed -- Documentation improvements - -## 0.3.3 (2020-12-05) -### Changed -- Improve description in Cargo.toml/README.md - -## 0.3.2 (2020-12-05) -### Changed -- Documentation improvements - -## 0.3.1 (2020-12-05) -### Added -- Impl `TryFrom<&[u32]>` for ObjectIdentifier - -## 0.3.0 (2020-12-05) [YANKED] -### Added -- Byte and string parsers - -## 0.2.0 (2020-09-05) -### Changed -- Validate OIDs are well-formed; MSRV 1.46+ - -## 0.1.0 (2020-08-04) -- Initial release diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/Cargo.toml deleted file mode 100644 index cc58c4ccbffa..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/Cargo.toml +++ /dev/null @@ -1,58 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -rust-version = "1.57" -name = "const-oid" -version = "0.9.6" -authors = ["RustCrypto Developers"] -description = """ -Const-friendly implementation of the ISO/IEC Object Identifier (OID) standard -as defined in ITU X.660, with support for BER/DER encoding/decoding as well as -heapless no_std (i.e. embedded) support -""" -documentation = "https://docs.rs/const-oid" -readme = "README.md" -keywords = [ - "iso", - "iec", - "itu", - "oid", -] -categories = [ - "cryptography", - "data-structures", - "encoding", - "no-std", - "parser-implementations", -] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/formats/tree/master/const-oid" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = [ - "--cfg", - "docsrs", -] - -[dependencies.arbitrary] -version = "1.2" -features = ["derive"] -optional = true - -[dev-dependencies.hex-literal] -version = "0.3" - -[features] -db = [] -std = [] diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/Cargo.toml.orig deleted file mode 100644 index 368373d15cf2..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/Cargo.toml.orig +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "const-oid" -version = "0.9.6" -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" -description = """ -Const-friendly implementation of the ISO/IEC Object Identifier (OID) standard -as defined in ITU X.660, with support for BER/DER encoding/decoding as well as -heapless no_std (i.e. embedded) support -""" -documentation = "https://docs.rs/const-oid" -repository = "https://github.com/RustCrypto/formats/tree/master/const-oid" -categories = ["cryptography", "data-structures", "encoding", "no-std", "parser-implementations"] -keywords = ["iso", "iec", "itu", "oid"] -readme = "README.md" -edition = "2021" -rust-version = "1.57" - -[dependencies] -arbitrary = { version = "1.2", optional = true, features = ["derive"] } - -[dev-dependencies] -hex-literal = "0.3" - -[features] -std = [] -db = [] - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-APACHE b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-APACHE deleted file mode 100644 index 78173fa2e753..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - 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. diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-MIT b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-MIT deleted file mode 100644 index 1b78809158a4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2020-2022 The RustCrypto Project Developers - -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. diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/README.md b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/README.md deleted file mode 100644 index fae3cfc3f9a3..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/README.md +++ /dev/null @@ -1,96 +0,0 @@ -# [RustCrypto]: Object Identifiers (OIDs) - -[![crate][crate-image]][crate-link] -[![Docs][docs-image]][docs-link] -[![Build Status][build-image]][build-link] -![Apache2/MIT licensed][license-image] -![Rust Version][rustc-image] -[![Project Chat][chat-image]][chat-link] - -Const-friendly implementation of the ISO/IEC Object Identifier (OID) standard -as defined in ITU [X.660], with support for BER/DER encoding/decoding as well -as heapless `no_std` (i.e. embedded) environments. - -[Documentation][docs-link] - -## About OIDs - -Object Identifiers, a.k.a. OIDs, are an International Telecommunications -Union (ITU) and ISO/IEC standard for naming any object, concept, or "thing" -with a globally unambiguous persistent name. - -The ITU's [X.660] standard provides the OID specification. Every OID is part of -a hierarchical namespace which begins with a *root OID*, which is either the -ITU's root OID (0), the ISO's root OID (1), or the joint ISO/ITU root OID (2). - -The following is an example of an OID, in this case identifying the -`rsaEncryption` algorithm: - -```text -1.2.840.113549.1.1.1 -``` - -For more information, see: - -## Implementation - -This library supports parsing OIDs in const contexts, e.g.: - -```rust -use const_oid::ObjectIdentifier; - -pub const MY_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.1"); -``` - -The OID parser is implemented entirely in terms of `const fn` and without the -use of proc macros. - -Additionally, it also includes a `const fn` OID serializer, and stores the OIDs -parsed from const contexts encoded using the BER/DER serialization -(sans header). - -This allows `ObjectIdentifier` to impl `AsRef<[u8]>` which can be used to -obtain the BER/DER serialization of an OID, even one declared `const`. - -Additionally, it impls `FromStr` and `TryFrom<&[u8]>` and functions just as -well as a runtime OID library. - -## Minimum Supported Rust Version - -This crate requires **Rust 1.57** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - -## License - -Licensed under either of: - -* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) -* [MIT license](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. - -[//]: # (badges) - -[crate-image]: https://buildstats.info/crate/const-oid -[crate-link]: https://crates.io/crates/const-oid -[docs-image]: https://docs.rs/const-oid/badge.svg -[docs-link]: https://docs.rs/const-oid/ -[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.57+-blue.svg -[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg -[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/300570-formats -[build-image]: https://github.com/RustCrypto/formats/workflows/const-oid/badge.svg?branch=master&event=push -[build-link]: https://github.com/RustCrypto/formats/actions - -[//]: # (links) - -[RustCrypto]: https://github.com/rustcrypto -[X.660]: https://www.itu.int/rec/T-REC-X.660 diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/arcs.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/arcs.rs deleted file mode 100644 index 7bf7a9a13e10..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/arcs.rs +++ /dev/null @@ -1,170 +0,0 @@ -//! Arcs are integer values which exist within an OID's hierarchy. - -use crate::{Error, ObjectIdentifier, Result}; -use core::mem; - -/// Type alias used to represent an "arc" (i.e. integer identifier value). -/// -/// X.660 does not define a maximum size of an arc. -/// -/// The current representation is `u32`, which has been selected as being -/// sufficient to cover the current PKCS/PKIX use cases this library has been -/// used in conjunction with. -/// -/// Future versions may potentially make it larger if a sufficiently important -/// use case is discovered. -pub type Arc = u32; - -/// Maximum value of the first arc in an OID. -pub(crate) const ARC_MAX_FIRST: Arc = 2; - -/// Maximum value of the second arc in an OID. -pub(crate) const ARC_MAX_SECOND: Arc = 39; - -/// Maximum number of bytes supported in an arc. -const ARC_MAX_BYTES: usize = mem::size_of::(); - -/// Maximum value of the last byte in an arc. -const ARC_MAX_LAST_OCTET: u8 = 0b11110000; // Max bytes of leading 1-bits - -/// [`Iterator`] over [`Arc`] values (a.k.a. nodes) in an [`ObjectIdentifier`]. -/// -/// This iterates over all arcs in an OID, including the root. -pub struct Arcs<'a> { - /// OID we're iterating over - oid: &'a ObjectIdentifier, - - /// Current position within the serialized DER bytes of this OID - cursor: Option, -} - -impl<'a> Arcs<'a> { - /// Create a new iterator over the arcs of this OID - pub(crate) fn new(oid: &'a ObjectIdentifier) -> Self { - Self { oid, cursor: None } - } - - /// Try to parse the next arc in this OID. - /// - /// This method is fallible so it can be used as a first pass to determine - /// that the arcs in the OID are well-formed. - pub(crate) fn try_next(&mut self) -> Result> { - match self.cursor { - // Indicates we're on the root OID - None => { - let root = RootArcs::try_from(self.oid.as_bytes()[0])?; - self.cursor = Some(0); - Ok(Some(root.first_arc())) - } - Some(0) => { - let root = RootArcs::try_from(self.oid.as_bytes()[0])?; - self.cursor = Some(1); - Ok(Some(root.second_arc())) - } - Some(offset) => { - let mut result = 0; - let mut arc_bytes = 0; - - loop { - let len = checked_add!(offset, arc_bytes); - - match self.oid.as_bytes().get(len).cloned() { - // The arithmetic below includes advance checks - // against `ARC_MAX_BYTES` and `ARC_MAX_LAST_OCTET` - // which ensure the operations will not overflow. - #[allow(clippy::integer_arithmetic)] - Some(byte) => { - arc_bytes = checked_add!(arc_bytes, 1); - - if (arc_bytes > ARC_MAX_BYTES) && (byte & ARC_MAX_LAST_OCTET != 0) { - return Err(Error::ArcTooBig); - } - - result = result << 7 | (byte & 0b1111111) as Arc; - - if byte & 0b10000000 == 0 { - self.cursor = Some(checked_add!(offset, arc_bytes)); - return Ok(Some(result)); - } - } - None => { - if arc_bytes == 0 { - return Ok(None); - } else { - return Err(Error::Base128); - } - } - } - } - } - } - } -} - -impl<'a> Iterator for Arcs<'a> { - type Item = Arc; - - fn next(&mut self) -> Option { - // ObjectIdentifier constructors should ensure the OID is well-formed - self.try_next().expect("OID malformed") - } -} - -/// Byte containing the first and second arcs of an OID. -/// -/// This is represented this way in order to reduce the overall size of the -/// [`ObjectIdentifier`] struct. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -struct RootArcs(u8); - -impl RootArcs { - /// Create [`RootArcs`] from the first and second arc values represented - /// as `Arc` integers. - pub(crate) const fn new(first_arc: Arc, second_arc: Arc) -> Result { - if first_arc > ARC_MAX_FIRST { - return Err(Error::ArcInvalid { arc: first_arc }); - } - - if second_arc > ARC_MAX_SECOND { - return Err(Error::ArcInvalid { arc: second_arc }); - } - - // The checks above ensure this operation will not overflow - #[allow(clippy::integer_arithmetic)] - let byte = (first_arc * (ARC_MAX_SECOND + 1)) as u8 + second_arc as u8; - - Ok(Self(byte)) - } - - /// Get the value of the first arc - #[allow(clippy::integer_arithmetic)] - pub(crate) const fn first_arc(self) -> Arc { - self.0 as Arc / (ARC_MAX_SECOND + 1) - } - - /// Get the value of the second arc - #[allow(clippy::integer_arithmetic)] - pub(crate) const fn second_arc(self) -> Arc { - self.0 as Arc % (ARC_MAX_SECOND + 1) - } -} - -impl TryFrom for RootArcs { - type Error = Error; - - // Ensured not to overflow by constructor invariants - #[allow(clippy::integer_arithmetic)] - fn try_from(octet: u8) -> Result { - let first = octet as Arc / (ARC_MAX_SECOND + 1); - let second = octet as Arc % (ARC_MAX_SECOND + 1); - let result = Self::new(first, second)?; - debug_assert_eq!(octet, result.0); - Ok(result) - } -} - -impl From for u8 { - fn from(root_arcs: RootArcs) -> u8 { - root_arcs.0 - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/checked.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/checked.rs deleted file mode 100644 index 7ff16a2a7b33..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/checked.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Checked arithmetic helpers. - -/// `const fn`-friendly checked addition helper. -macro_rules! checked_add { - ($a:expr, $b:expr) => { - match $a.checked_add($b) { - Some(n) => n, - None => return Err(Error::Length), - } - }; -} diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db.rs deleted file mode 100644 index e4b7a47b4b95..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db.rs +++ /dev/null @@ -1,164 +0,0 @@ -//! OID Names Database -//! -//! The contents of this database are generated from the official IANA -//! [Object Identifier Descriptors] Registry CSV file and from [RFC 5280]. -//! If we are missing values you care about, please contribute a patch to -//! `oiddbgen` (a subcrate in the source code) to generate the values from -//! the relevant standard. -//! -//! [RFC 5280]: https://datatracker.ietf.org/doc/html/rfc5280 -//! [Object Identifier Descriptors]: https://www.iana.org/assignments/ldap-parameters/ldap-parameters.xhtml#ldap-parameters-3 - -#![allow(clippy::integer_arithmetic, missing_docs)] - -mod gen; - -pub use gen::*; - -use crate::{Error, ObjectIdentifier}; - -/// A const implementation of byte equals. -const fn eq(lhs: &[u8], rhs: &[u8]) -> bool { - if lhs.len() != rhs.len() { - return false; - } - - let mut i = 0usize; - while i < lhs.len() { - if lhs[i] != rhs[i] { - return false; - } - - i += 1; - } - - true -} - -/// A const implementation of case-insensitive ASCII equals. -const fn eq_case(lhs: &[u8], rhs: &[u8]) -> bool { - if lhs.len() != rhs.len() { - return false; - } - - let mut i = 0usize; - while i < lhs.len() { - if !lhs[i].eq_ignore_ascii_case(&rhs[i]) { - return false; - } - - i += 1; - } - - true -} - -/// A query interface for OIDs/Names. -#[derive(Copy, Clone)] -pub struct Database<'a>(&'a [(&'a ObjectIdentifier, &'a str)]); - -impl<'a> Database<'a> { - /// Looks up a name for an OID. - /// - /// Errors if the input is not a valid OID. - /// Returns the input if no name is found. - pub fn resolve<'b>(&self, oid: &'b str) -> Result<&'b str, Error> - where - 'a: 'b, - { - Ok(self.by_oid(&oid.parse()?).unwrap_or(oid)) - } - - /// Finds a named oid by its associated OID. - pub const fn by_oid(&self, oid: &ObjectIdentifier) -> Option<&'a str> { - let mut i = 0; - - while i < self.0.len() { - let lhs = self.0[i].0; - if lhs.length == oid.length && eq(&lhs.bytes, &oid.bytes) { - return Some(self.0[i].1); - } - - i += 1; - } - - None - } - - /// Finds a named oid by its associated name. - pub const fn by_name(&self, name: &str) -> Option<&'a ObjectIdentifier> { - let mut i = 0; - - while i < self.0.len() { - let lhs = self.0[i].1; - if eq_case(lhs.as_bytes(), name.as_bytes()) { - return Some(self.0[i].0); - } - - i += 1; - } - - None - } - - /// Return the list of matched name for the OID. - pub const fn find_names_for_oid(&self, oid: ObjectIdentifier) -> Names<'a> { - Names { - database: *self, - oid, - position: 0, - } - } -} - -/// Iterator returning the multiple names that may be associated with an OID. -pub struct Names<'a> { - database: Database<'a>, - oid: ObjectIdentifier, - position: usize, -} - -impl<'a> Iterator for Names<'a> { - type Item = &'a str; - - fn next(&mut self) -> Option<&'a str> { - let mut i = self.position; - - while i < self.database.0.len() { - let lhs = self.database.0[i].0; - - if lhs.as_bytes().eq(self.oid.as_bytes()) { - self.position = i + 1; - return Some(self.database.0[i].1); - } - - i += 1; - } - - None - } -} - -#[cfg(test)] -mod tests { - use crate::ObjectIdentifier; - - use super::rfc4519::CN; - - #[test] - fn by_oid() { - let cn = super::DB.by_oid(&CN).expect("cn not found"); - assert_eq!("cn", cn); - - let none = ObjectIdentifier::new_unwrap("0.1.2.3.4.5.6.7.8.9"); - assert_eq!(None, super::DB.by_oid(&none)); - } - - #[test] - fn by_name() { - let cn = super::DB.by_name("CN").expect("cn not found"); - assert_eq!(&CN, cn); - - assert_eq!(None, super::DB.by_name("purplePeopleEater")); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db/gen.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db/gen.rs deleted file mode 100644 index 9c603d824fc2..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db/gen.rs +++ /dev/null @@ -1,4248 +0,0 @@ -#![doc = "!! DO NOT EDIT !!: This file is auto-generated by oiddbgen."] -pub mod rfc1274 { - pub const TEXT_ENCODED_OR_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.2"); - pub const OTHER_MAILBOX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.22"); - pub const LAST_MODIFIED_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.23"); - pub const LAST_MODIFIED_BY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.24"); - pub const A_RECORD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.26"); - pub const MD_RECORD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.27"); - pub const MX_RECORD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.28"); - pub const NS_RECORD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.29"); - pub const SOA_RECORD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.30"); - pub const CNAME_RECORD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.31"); - pub const JANET_MAILBOX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.46"); - pub const MAIL_PREFERENCE_OPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.47"); - pub const DSA_QUALITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.49"); - pub const SUBTREE_MINIMUM_QUALITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.51"); - pub const SUBTREE_MAXIMUM_QUALITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.52"); - pub const PERSONAL_SIGNATURE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.53"); - pub const DIT_REDIRECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.54"); - pub const AUDIO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.55"); - pub const PHOTO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.7"); - pub const DNS_DOMAIN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.15"); - pub const PILOT_ORGANIZATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.20"); - pub const PILOT_DSA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.21"); - pub const QUALITY_LABELLED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.22"); - pub const PILOT_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.3"); - pub const PILOT_PERSON: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.4"); -} -pub mod rfc2079 { - pub const LABELED_URI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.250.1.57"); - pub const LABELED_URI_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.250.3.15"); -} -pub mod rfc2164 { - pub const RFC_822_TO_X_400_MAPPING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.1"); - pub const X_400_TO_RFC_822_MAPPING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.2"); - pub const OMITTED_OR_ADDRESS_COMPONENT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.3"); - pub const MIXER_GATEWAY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.4"); - pub const ASSOCIATED_X_400_GATEWAY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.2.3"); - pub const ASSOCIATED_OR_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.2.6"); - pub const OR_ADDRESS_COMPONENT_TYPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.2.7"); - pub const ASSOCIATED_INTERNET_GATEWAY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.2.8"); - pub const MCGAM_TABLES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.2.9"); -} -pub mod rfc2247 { - pub const DOMAIN_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.345"); -} -pub mod rfc2252 { - pub const PRESENTATION_ADDRESS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.22"); - pub const PROTOCOL_INFORMATION_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.24"); -} -pub mod rfc2256 { - pub const KNOWLEDGE_INFORMATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.2"); - pub const PRESENTATION_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.29"); - pub const SUPPORTED_APPLICATION_CONTEXT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.30"); - pub const PROTOCOL_INFORMATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.48"); - pub const DMD_NAME: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.54"); - pub const STATE_OR_PROVINCE_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.8"); - pub const STREET_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.9"); - pub const APPLICATION_ENTITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.12"); - pub const DSA: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.13"); - pub const DMD: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.20"); -} -pub mod rfc2293 { - pub const SUBTREE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.1"); - pub const TABLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.2"); - pub const TABLE_ENTRY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.3"); - pub const TEXT_TABLE_ENTRY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.4"); - pub const DISTINGUISHED_NAME_TABLE_ENTRY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.1.5"); - pub const TEXT_TABLE_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.2.1"); - pub const TEXT_TABLE_VALUE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.2.2"); - pub const DISTINGUISHED_NAME_TABLE_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.453.7.2.3"); -} -pub mod rfc2589 { - pub const DYNAMIC_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.119.2"); - pub const ENTRY_TTL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.119.3"); - pub const DYNAMIC_SUBTREES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.119.4"); -} -pub mod rfc2739 { - pub const CAL_CAL_URI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.4.478"); - pub const CAL_FBURL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.4.479"); - pub const CAL_CAPURI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.4.480"); - pub const CAL_CAL_ADR_URI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.4.481"); - pub const CAL_OTHER_CAL_UR_IS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.4.482"); - pub const CAL_OTHER_FBUR_LS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.4.483"); - pub const CAL_OTHER_CAPUR_IS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.4.484"); - pub const CAL_OTHER_CAL_ADR_UR_IS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.4.485"); - pub const CAL_ENTRY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113556.1.5.87"); -} -pub mod rfc2798 { - pub const JPEG_PHOTO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.60"); - pub const CAR_LICENSE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.1"); - pub const DEPARTMENT_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.2"); - pub const USER_PKCS_12: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.216"); - pub const DISPLAY_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.241"); - pub const EMPLOYEE_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.3"); - pub const PREFERRED_LANGUAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.39"); - pub const EMPLOYEE_TYPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.4"); - pub const USER_SMIME_CERTIFICATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.40"); - pub const INET_ORG_PERSON: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.2.2"); -} -pub mod rfc3280 { - pub const EMAIL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.1"); - pub const EMAIL_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.1"); - pub const PSEUDONYM: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.65"); -} -pub mod rfc3296 { - pub const REF: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.1.34"); - pub const REFERRAL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113730.3.2.6"); -} -pub mod rfc3671 { - pub const COLLECTIVE_ATTRIBUTE_SUBENTRIES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.12"); - pub const COLLECTIVE_EXCLUSIONS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.7"); - pub const COLLECTIVE_ATTRIBUTE_SUBENTRY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.20.2"); - pub const C_O: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.10.1"); - pub const C_OU: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.11.1"); - pub const C_POSTAL_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.16.1"); - pub const C_POSTAL_CODE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.17.1"); - pub const C_POST_OFFICE_BOX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.18.1"); - pub const C_PHYSICAL_DELIVERY_OFFICE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.19.1"); - pub const C_TELEPHONE_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.20.1"); - pub const C_TELEX_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.21.1"); - pub const C_FACSIMILE_TELEPHONE_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.23.1"); - pub const C_INTERNATIONAL_ISDN_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.25.1"); - pub const C_L: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.7.1"); - pub const C_ST: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.8.1"); - pub const C_STREET: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.9.1"); -} -pub mod rfc3672 { - pub const SUBENTRY: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.17.0"); - pub const ADMINISTRATIVE_ROLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.5"); - pub const SUBTREE_SPECIFICATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.6"); - pub const AUTONOMOUS_AREA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.23.1"); - pub const ACCESS_CONTROL_SPECIFIC_AREA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.23.2"); - pub const ACCESS_CONTROL_INNER_AREA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.23.3"); - pub const SUBSCHEMA_ADMIN_SPECIFIC_AREA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.23.4"); - pub const COLLECTIVE_ATTRIBUTE_SPECIFIC_AREA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.23.5"); - pub const COLLECTIVE_ATTRIBUTE_INNER_AREA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.23.6"); -} -pub mod rfc3687 { - pub const COMPONENT_FILTER_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.36.79672281.1.13.2"); - pub const RDN_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.36.79672281.1.13.3"); - pub const PRESENT_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.36.79672281.1.13.5"); - pub const ALL_COMPONENTS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.36.79672281.1.13.6"); - pub const DIRECTORY_COMPONENTS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.36.79672281.1.13.7"); -} -pub mod rfc3698 { - pub const STORED_PREFIX_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.41"); -} -pub mod rfc3703 { - pub const PCIM_POLICY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.1"); - pub const PCIM_RULE_ACTION_ASSOCIATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.10"); - pub const PCIM_CONDITION_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.11"); - pub const PCIM_TPC_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.12"); - pub const PCIM_CONDITION_VENDOR_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.13"); - pub const PCIM_ACTION_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.14"); - pub const PCIM_ACTION_VENDOR_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.15"); - pub const PCIM_POLICY_INSTANCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.16"); - pub const PCIM_ELEMENT_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.17"); - pub const PCIM_REPOSITORY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.18"); - pub const PCIM_REPOSITORY_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.19"); - pub const PCIM_GROUP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.2"); - pub const PCIM_REPOSITORY_INSTANCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.20"); - pub const PCIM_SUBTREES_PTR_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.21"); - pub const PCIM_GROUP_CONTAINMENT_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.22"); - pub const PCIM_RULE_CONTAINMENT_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.23"); - pub const PCIM_GROUP_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.3"); - pub const PCIM_GROUP_INSTANCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.4"); - pub const PCIM_RULE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.5"); - pub const PCIM_RULE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.6"); - pub const PCIM_RULE_INSTANCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.7"); - pub const PCIM_RULE_CONDITION_ASSOCIATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.8"); - pub const PCIM_RULE_VALIDITY_ASSOCIATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.1.9"); - pub const PCIM_RULE_VALIDITY_PERIOD_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.10"); - pub const PCIM_RULE_USAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.11"); - pub const PCIM_RULE_PRIORITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.12"); - pub const PCIM_RULE_MANDATORY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.13"); - pub const PCIM_RULE_SEQUENCED_ACTIONS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.14"); - pub const PCIM_ROLES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.15"); - pub const PCIM_CONDITION_GROUP_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.16"); - pub const PCIM_CONDITION_NEGATED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.17"); - pub const PCIM_CONDITION_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.18"); - pub const PCIM_CONDITION_DN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.19"); - pub const PCIM_VALIDITY_CONDITION_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.20"); - pub const PCIM_TIME_PERIOD_CONDITION_DN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.21"); - pub const PCIM_ACTION_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.22"); - pub const PCIM_ACTION_ORDER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.23"); - pub const PCIM_ACTION_DN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.24"); - pub const PCIM_TPC_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.25"); - pub const PCIM_TPC_MONTH_OF_YEAR_MASK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.26"); - pub const PCIM_TPC_DAY_OF_MONTH_MASK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.27"); - pub const PCIM_TPC_DAY_OF_WEEK_MASK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.28"); - pub const PCIM_TPC_TIME_OF_DAY_MASK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.29"); - pub const PCIM_KEYWORDS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.3"); - pub const PCIM_TPC_LOCAL_OR_UTC_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.30"); - pub const PCIM_VENDOR_CONSTRAINT_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.31"); - pub const PCIM_VENDOR_CONSTRAINT_ENCODING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.32"); - pub const PCIM_VENDOR_ACTION_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.33"); - pub const PCIM_VENDOR_ACTION_ENCODING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.34"); - pub const PCIM_POLICY_INSTANCE_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.35"); - pub const PCIM_REPOSITORY_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.36"); - pub const PCIM_SUBTREES_AUX_CONTAINED_SET: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.37"); - pub const PCIM_GROUPS_AUX_CONTAINED_SET: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.38"); - pub const PCIM_RULES_AUX_CONTAINED_SET: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.39"); - pub const PCIM_GROUP_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.4"); - pub const PCIM_RULE_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.5"); - pub const PCIM_RULE_ENABLED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.6"); - pub const PCIM_RULE_CONDITION_LIST_TYPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.7"); - pub const PCIM_RULE_CONDITION_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.8"); - pub const PCIM_RULE_ACTION_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.6.2.9"); -} -pub mod rfc3712 { - pub const PRINTER_XRI_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1107"); - pub const PRINTER_ALIASES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1108"); - pub const PRINTER_CHARSET_CONFIGURED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1109"); - pub const PRINTER_JOB_PRIORITY_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1110"); - pub const PRINTER_JOB_K_OCTETS_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1111"); - pub const PRINTER_CURRENT_OPERATOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1112"); - pub const PRINTER_SERVICE_PERSON: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1113"); - pub const PRINTER_DELIVERY_ORIENTATION_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1114"); - pub const PRINTER_STACKING_ORDER_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1115"); - pub const PRINTER_OUTPUT_FEATURES_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1116"); - pub const PRINTER_MEDIA_LOCAL_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1117"); - pub const PRINTER_COPIES_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1118"); - pub const PRINTER_NATURAL_LANGUAGE_CONFIGURED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1119"); - pub const PRINTER_PRINT_QUALITY_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1120"); - pub const PRINTER_RESOLUTION_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1121"); - pub const PRINTER_MEDIA_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1122"); - pub const PRINTER_SIDES_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1123"); - pub const PRINTER_NUMBER_UP_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1124"); - pub const PRINTER_FINISHINGS_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1125"); - pub const PRINTER_PAGES_PER_MINUTE_COLOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1126"); - pub const PRINTER_PAGES_PER_MINUTE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1127"); - pub const PRINTER_COMPRESSION_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1128"); - pub const PRINTER_COLOR_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1129"); - pub const PRINTER_DOCUMENT_FORMAT_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1130"); - pub const PRINTER_CHARSET_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1131"); - pub const PRINTER_MULTIPLE_DOCUMENT_JOBS_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1132"); - pub const PRINTER_IPP_VERSIONS_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1133"); - pub const PRINTER_MORE_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1134"); - pub const PRINTER_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1135"); - pub const PRINTER_LOCATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1136"); - pub const PRINTER_GENERATED_NATURAL_LANGUAGE_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1137"); - pub const PRINTER_MAKE_AND_MODEL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1138"); - pub const PRINTER_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1139"); - pub const PRINTER_URI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.4.1140"); - pub const PRINTER_LPR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.6.253"); - pub const SLP_SERVICE_PRINTER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.6.254"); - pub const PRINTER_SERVICE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.6.255"); - pub const PRINTER_IPP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.6.256"); - pub const PRINTER_SERVICE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.6.257"); - pub const PRINTER_ABSTRACT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.6.258"); -} -pub mod rfc4104 { - pub const PCELS_POLICY_SET: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.1"); - pub const PCELS_ACTION_ASSOCIATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.10"); - pub const PCELS_SIMPLE_CONDITION_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.11"); - pub const PCELS_COMPOUND_CONDITION_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.12"); - pub const PCELS_COMPOUND_FILTER_CONDITION_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.13"); - pub const PCELS_SIMPLE_ACTION_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.14"); - pub const PCELS_COMPOUND_ACTION_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.15"); - pub const PCELS_VARIABLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.16"); - pub const PCELS_EXPLICIT_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.17"); - pub const PCELS_IMPLICIT_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.18"); - pub const PCELS_SOURCE_I_PV_4_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.19"); - pub const PCELS_POLICY_SET_ASSOCIATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.2"); - pub const PCELS_SOURCE_I_PV_6_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.20"); - pub const PCELS_DESTINATION_I_PV_4_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.21"); - pub const PCELS_DESTINATION_I_PV_6_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.22"); - pub const PCELS_SOURCE_PORT_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.23"); - pub const PCELS_DESTINATION_PORT_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.24"); - pub const PCELS_IP_PROTOCOL_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.25"); - pub const PCELS_IP_VERSION_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.26"); - pub const PCELS_IP_TO_S_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.27"); - pub const PCELS_DSCP_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.28"); - pub const PCELS_FLOW_ID_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.29"); - pub const PCELS_GROUP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.3"); - pub const PCELS_SOURCE_MAC_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.30"); - pub const PCELS_DESTINATION_MAC_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.31"); - pub const PCELS_VLAN_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.32"); - pub const PCELS_CO_S_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.33"); - pub const PCELS_ETHERTYPE_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.34"); - pub const PCELS_SOURCE_SAP_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.35"); - pub const PCELS_DESTINATION_SAP_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.36"); - pub const PCELS_SNAPOUI_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.37"); - pub const PCELS_SNAP_TYPE_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.38"); - pub const PCELS_FLOW_DIRECTION_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.39"); - pub const PCELS_GROUP_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.4"); - pub const PCELS_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.40"); - pub const PCELS_I_PV_4_ADDR_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.41"); - pub const PCELS_I_PV_6_ADDR_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.42"); - pub const PCELS_MAC_ADDR_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.43"); - pub const PCELS_STRING_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.44"); - pub const PCELS_BIT_STRING_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.45"); - pub const PCELS_INTEGER_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.46"); - pub const PCELS_BOOLEAN_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.47"); - pub const PCELS_REUSABLE_CONTAINER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.48"); - pub const PCELS_REUSABLE_CONTAINER_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.49"); - pub const PCELS_GROUP_INSTANCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.5"); - pub const PCELS_REUSABLE_CONTAINER_INSTANCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.50"); - pub const PCELS_ROLE_COLLECTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.51"); - pub const PCELS_FILTER_ENTRY_BASE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.52"); - pub const PCELS_IP_HEADERS_FILTER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.53"); - pub const PCELS_8021_FILTER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.54"); - pub const PCELS_FILTER_LIST_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.55"); - pub const PCELS_VENDOR_VARIABLE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.56"); - pub const PCELS_VENDOR_VALUE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.57"); - pub const PCELS_RULE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.6"); - pub const PCELS_RULE_AUX_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.7"); - pub const PCELS_RULE_INSTANCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.8"); - pub const PCELS_CONDITION_ASSOCIATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.1.9"); - pub const PCELS_POLICY_SET_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.1"); - pub const PCELS_EXECUTION_STRATEGY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.10"); - pub const PCELS_VARIABLE_DN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.11"); - pub const PCELS_VALUE_DN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.12"); - pub const PCELS_IS_MIRRORED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.13"); - pub const PCELS_VARIABLE_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.14"); - pub const PCELS_EXPECTED_VALUE_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.15"); - pub const PCELS_VARIABLE_MODEL_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.16"); - pub const PCELS_VARIABLE_MODEL_PROPERTY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.17"); - pub const PCELS_EXPECTED_VALUE_TYPES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.18"); - pub const PCELS_VALUE_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.19"); - pub const PCELS_DECISION_STRATEGY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.2"); - pub const PCELS_I_PV_4_ADDR_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.20"); - pub const PCELS_I_PV_6_ADDR_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.21"); - pub const PCELS_MAC_ADDR_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.22"); - pub const PCELS_STRING_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.23"); - pub const PCELS_BIT_STRING_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.24"); - pub const PCELS_INTEGER_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.25"); - pub const PCELS_BOOLEAN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.26"); - pub const PCELS_REUSABLE_CONTAINER_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.27"); - pub const PCELS_REUSABLE_CONTAINER_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.28"); - pub const PCELS_ROLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.29"); - pub const PCELS_POLICY_SET_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.3"); - pub const PCELS_ROLE_COLLECTION_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.30"); - pub const PCELS_ELEMENT_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.31"); - pub const PCELS_FILTER_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.32"); - pub const PCELS_FILTER_IS_NEGATED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.33"); - pub const PCELS_IP_HDR_VERSION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.34"); - pub const PCELS_IP_HDR_SOURCE_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.35"); - pub const PCELS_IP_HDR_SOURCE_ADDRESS_END_OF_RANGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.36"); - pub const PCELS_IP_HDR_SOURCE_MASK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.37"); - pub const PCELS_IP_HDR_DEST_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.38"); - pub const PCELS_IP_HDR_DEST_ADDRESS_END_OF_RANGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.39"); - pub const PCELS_PRIORITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.4"); - pub const PCELS_IP_HDR_DEST_MASK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.40"); - pub const PCELS_IP_HDR_PROTOCOL_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.41"); - pub const PCELS_IP_HDR_SOURCE_PORT_START: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.42"); - pub const PCELS_IP_HDR_SOURCE_PORT_END: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.43"); - pub const PCELS_IP_HDR_DEST_PORT_START: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.44"); - pub const PCELS_IP_HDR_DEST_PORT_END: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.45"); - pub const PCELS_IP_HDR_DSCP_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.46"); - pub const PCELS_IP_HDR_FLOW_LABEL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.47"); - pub const PCELS_8021_HDR_SOURCE_MAC_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.48"); - pub const PCELS_8021_HDR_SOURCE_MAC_MASK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.49"); - pub const PCELS_POLICY_SET_DN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.5"); - pub const PCELS_8021_HDR_DEST_MAC_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.50"); - pub const PCELS_8021_HDR_DEST_MAC_MASK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.51"); - pub const PCELS_8021_HDR_PROTOCOL_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.52"); - pub const PCELS_8021_HDR_PRIORITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.53"); - pub const PCELS_8021_HDR_VLANID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.54"); - pub const PCELS_FILTER_LIST_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.55"); - pub const PCELS_FILTER_DIRECTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.56"); - pub const PCELS_FILTER_ENTRY_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.57"); - pub const PCELS_VENDOR_VARIABLE_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.58"); - pub const PCELS_VENDOR_VARIABLE_ENCODING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.59"); - pub const PCELS_CONDITION_LIST_TYPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.6"); - pub const PCELS_VENDOR_VALUE_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.60"); - pub const PCELS_VENDOR_VALUE_ENCODING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.61"); - pub const PCELS_RULE_VALIDITY_PERIOD_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.62"); - pub const PCELS_CONDITION_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.7"); - pub const PCELS_ACTION_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.8"); - pub const PCELS_SEQUENCED_ACTIONS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.9.2.9"); -} -pub mod rfc4237 { - pub const VPIM_USER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.1.1"); - pub const VPIM_TELEPHONE_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.1"); - pub const VPIM_SUB_MAILBOXES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.10"); - pub const VPIM_RFC_822_MAILBOX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.2"); - pub const VPIM_SPOKEN_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.3"); - pub const VPIM_SUPPORTED_UA_BEHAVIORS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.4"); - pub const VPIM_SUPPORTED_AUDIO_MEDIA_TYPES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.5"); - pub const VPIM_SUPPORTED_MESSAGE_CONTEXT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.6"); - pub const VPIM_TEXT_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.7"); - pub const VPIM_EXTENDED_ABSENCE_STATUS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.8"); - pub const VPIM_MAX_MESSAGE_SIZE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.11.2.9"); -} -pub mod rfc4403 { - pub const UDDIV_3_SERVICE_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.32"); - pub const UDDI_BUSINESS_ENTITY_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.1"); - pub const UDDIV_3_ENTITY_OBITUARY_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.10"); - pub const UDDI_CONTACT_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.2"); - pub const UDDI_ADDRESS_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.3"); - pub const UDDI_BUSINESS_SERVICE_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.4"); - pub const UDDI_BINDING_TEMPLATE_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.5"); - pub const UDDI_T_MODEL_INSTANCE_INFO_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.6"); - pub const UDDI_T_MODEL_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.7"); - pub const UDDI_PUBLISHER_ASSERTION_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.8"); - pub const UDDIV_3_SUBSCRIPTION_NAME_FORM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.15.9"); - pub const UDDI_BUSINESS_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.1"); - pub const UDDI_E_MAIL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.10"); - pub const UDDI_SORT_CODE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.11"); - pub const UDDI_T_MODEL_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.12"); - pub const UDDI_ADDRESS_LINE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.13"); - pub const UDDI_IDENTIFIER_BAG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.14"); - pub const UDDI_CATEGORY_BAG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.15"); - pub const UDDI_KEYED_REFERENCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.16"); - pub const UDDI_SERVICE_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.17"); - pub const UDDI_BINDING_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.18"); - pub const UDDI_ACCESS_POINT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.19"); - pub const UDDI_AUTHORIZED_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.2"); - pub const UDDI_HOSTING_REDIRECTOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.20"); - pub const UDDI_INSTANCE_DESCRIPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.21"); - pub const UDDI_INSTANCE_PARMS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.22"); - pub const UDDI_OVERVIEW_DESCRIPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.23"); - pub const UDDI_OVERVIEW_URL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.24"); - pub const UDDI_FROM_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.25"); - pub const UDDI_TO_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.26"); - pub const UDDI_UUID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.27"); - pub const UDDI_IS_HIDDEN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.28"); - pub const UDDI_IS_PROJECTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.29"); - pub const UDDI_OPERATOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.3"); - pub const UDDI_LANG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.30"); - pub const UDDIV_3_BUSINESS_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.31"); - pub const UDDIV_3_BINDING_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.33"); - pub const UDDIV_3_TMODEL_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.34"); - pub const UDDIV_3_DIGITAL_SIGNATURE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.35"); - pub const UDDIV_3_NODE_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.36"); - pub const UDDIV_3_ENTITY_MODIFICATION_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.37"); - pub const UDDIV_3_SUBSCRIPTION_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.38"); - pub const UDDIV_3_SUBSCRIPTION_FILTER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.39"); - pub const UDDI_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.4"); - pub const UDDIV_3_NOTIFICATION_INTERVAL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.40"); - pub const UDDIV_3_MAX_ENTITIES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.41"); - pub const UDDIV_3_EXPIRES_AFTER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.42"); - pub const UDDIV_3_BRIEF_RESPONSE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.43"); - pub const UDDIV_3_ENTITY_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.44"); - pub const UDDIV_3_ENTITY_CREATION_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.45"); - pub const UDDIV_3_ENTITY_DELETION_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.46"); - pub const UDDI_DESCRIPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.5"); - pub const UDDI_DISCOVERY_UR_LS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.6"); - pub const UDDI_USE_TYPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.7"); - pub const UDDI_PERSON_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.8"); - pub const UDDI_PHONE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.4.9"); - pub const UDDI_BUSINESS_ENTITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.1"); - pub const UDDIV_3_ENTITY_OBITUARY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.10"); - pub const UDDI_CONTACT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.2"); - pub const UDDI_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.3"); - pub const UDDI_BUSINESS_SERVICE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.4"); - pub const UDDI_BINDING_TEMPLATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.5"); - pub const UDDI_T_MODEL_INSTANCE_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.6"); - pub const UDDI_T_MODEL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.7"); - pub const UDDI_PUBLISHER_ASSERTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.8"); - pub const UDDIV_3_SUBSCRIPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.10.6.9"); -} -pub mod rfc4512 { - pub const EXTENSIBLE_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.120.111"); - pub const SUPPORTED_CONTROL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.120.13"); - pub const SUPPORTED_SASL_MECHANISMS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.120.14"); - pub const SUPPORTED_LDAP_VERSION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.120.15"); - pub const LDAP_SYNTAXES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.120.16"); - pub const NAMING_CONTEXTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.120.5"); - pub const ALT_SERVER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.120.6"); - pub const SUPPORTED_EXTENSION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.101.120.7"); - pub const SUPPORTED_FEATURES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.4203.1.3.5"); - pub const CREATE_TIMESTAMP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.1"); - pub const SUBSCHEMA_SUBENTRY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.10"); - pub const MODIFY_TIMESTAMP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.2"); - pub const CREATORS_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.3"); - pub const MODIFIERS_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.18.4"); - pub const SUBSCHEMA: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.20.1"); - pub const DIT_STRUCTURE_RULES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.21.1"); - pub const GOVERNING_STRUCTURE_RULE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.21.10"); - pub const DIT_CONTENT_RULES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.21.2"); - pub const MATCHING_RULES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.21.4"); - pub const ATTRIBUTE_TYPES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.21.5"); - pub const OBJECT_CLASSES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.21.6"); - pub const NAME_FORMS: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.21.7"); - pub const MATCHING_RULE_USE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.21.8"); - pub const STRUCTURAL_OBJECT_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.21.9"); - pub const OBJECT_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.0"); - pub const ALIASED_OBJECT_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.1"); - pub const TOP: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.0"); - pub const ALIAS: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.1"); -} -pub mod rfc4517 { - pub const CASE_EXACT_IA_5_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.109.114.1"); - pub const CASE_IGNORE_IA_5_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.109.114.2"); - pub const CASE_IGNORE_IA_5_SUBSTRINGS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.109.114.3"); - pub const OBJECT_IDENTIFIER_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.0"); - pub const DISTINGUISHED_NAME_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.1"); - pub const NUMERIC_STRING_SUBSTRINGS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.10"); - pub const CASE_IGNORE_LIST_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.11"); - pub const CASE_IGNORE_LIST_SUBSTRINGS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.12"); - pub const BOOLEAN_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.13"); - pub const INTEGER_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.14"); - pub const INTEGER_ORDERING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.15"); - pub const BIT_STRING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.16"); - pub const OCTET_STRING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.17"); - pub const OCTET_STRING_ORDERING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.18"); - pub const CASE_IGNORE_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.2"); - pub const TELEPHONE_NUMBER_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.20"); - pub const TELEPHONE_NUMBER_SUBSTRINGS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.21"); - pub const UNIQUE_MEMBER_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.23"); - pub const GENERALIZED_TIME_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.27"); - pub const GENERALIZED_TIME_ORDERING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.28"); - pub const INTEGER_FIRST_COMPONENT_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.29"); - pub const CASE_IGNORE_ORDERING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.3"); - pub const OBJECT_IDENTIFIER_FIRST_COMPONENT_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.30"); - pub const DIRECTORY_STRING_FIRST_COMPONENT_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.31"); - pub const WORD_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.32"); - pub const KEYWORD_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.33"); - pub const CASE_IGNORE_SUBSTRINGS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.4"); - pub const CASE_EXACT_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.5"); - pub const CASE_EXACT_ORDERING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.6"); - pub const CASE_EXACT_SUBSTRINGS_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.7"); - pub const NUMERIC_STRING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.8"); - pub const NUMERIC_STRING_ORDERING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.9"); -} -pub mod rfc4519 { - pub const UID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.1"); - pub const USER_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.1"); - pub const DC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.25"); - pub const DOMAIN_COMPONENT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.25"); - pub const UID_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.3.1"); - pub const DC_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.1466.344"); - pub const O: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.10"); - pub const ORGANIZATION_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.10"); - pub const OU: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.11"); - pub const ORGANIZATIONAL_UNIT_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.11"); - pub const TITLE: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.12"); - pub const DESCRIPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.13"); - pub const SEARCH_GUIDE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.14"); - pub const BUSINESS_CATEGORY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.15"); - pub const POSTAL_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.16"); - pub const POSTAL_CODE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.17"); - pub const POST_OFFICE_BOX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.18"); - pub const PHYSICAL_DELIVERY_OFFICE_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.19"); - pub const TELEPHONE_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.20"); - pub const TELEX_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.21"); - pub const TELETEX_TERMINAL_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.22"); - pub const FACSIMILE_TELEPHONE_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.23"); - pub const X_121_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.24"); - pub const INTERNATIONALI_SDN_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.25"); - pub const REGISTERED_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.26"); - pub const DESTINATION_INDICATOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.27"); - pub const PREFERRED_DELIVERY_METHOD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.28"); - pub const CN: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.3"); - pub const COMMON_NAME: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.3"); - pub const MEMBER: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.31"); - pub const OWNER: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.32"); - pub const ROLE_OCCUPANT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.33"); - pub const SEE_ALSO: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.34"); - pub const USER_PASSWORD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.35"); - pub const SN: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.4"); - pub const SURNAME: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.4"); - pub const NAME: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.41"); - pub const GIVEN_NAME: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.42"); - pub const INITIALS: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.43"); - pub const GENERATION_QUALIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.44"); - pub const X_500_UNIQUE_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.45"); - pub const DN_QUALIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.46"); - pub const ENHANCED_SEARCH_GUIDE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.47"); - pub const DISTINGUISHED_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.49"); - pub const SERIAL_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.5"); - pub const UNIQUE_MEMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.50"); - pub const HOUSE_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.51"); - pub const C: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.6"); - pub const COUNTRY_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.6"); - pub const L: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.7"); - pub const LOCALITY_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.7"); - pub const ST: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.8"); - pub const STREET: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.9"); - pub const RESIDENTIAL_PERSON: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.10"); - pub const APPLICATION_PROCESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.11"); - pub const DEVICE: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.14"); - pub const GROUP_OF_UNIQUE_NAMES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.17"); - pub const COUNTRY: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.2"); - pub const LOCALITY: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.3"); - pub const ORGANIZATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.4"); - pub const ORGANIZATIONAL_UNIT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.5"); - pub const PERSON: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.6"); - pub const ORGANIZATIONAL_PERSON: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.7"); - pub const ORGANIZATIONAL_ROLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.8"); - pub const GROUP_OF_NAMES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.9"); -} -pub mod rfc4523 { - pub const CERTIFICATE_EXACT_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.34"); - pub const CERTIFICATE_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.35"); - pub const CERTIFICATE_PAIR_EXACT_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.36"); - pub const CERTIFICATE_PAIR_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.37"); - pub const CERTIFICATE_LIST_EXACT_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.38"); - pub const CERTIFICATE_LIST_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.39"); - pub const ALGORITHM_IDENTIFIER_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.13.40"); - pub const USER_CERTIFICATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.36"); - pub const CA_CERTIFICATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.37"); - pub const AUTHORITY_REVOCATION_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.38"); - pub const CERTIFICATE_REVOCATION_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.39"); - pub const CROSS_CERTIFICATE_PAIR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.40"); - pub const SUPPORTED_ALGORITHMS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.52"); - pub const DELTA_REVOCATION_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.4.53"); - pub const STRONG_AUTHENTICATION_USER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.15"); - pub const CERTIFICATION_AUTHORITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.16"); - pub const CERTIFICATION_AUTHORITY_V_2: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.16.2"); - pub const USER_SECURITY_INFORMATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.18"); - pub const CRL_DISTRIBUTION_POINT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.6.19"); - pub const PKI_USER: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.21"); - pub const PKI_CA: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.22"); - pub const DELTA_CRL: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.6.23"); -} -pub mod rfc4524 { - pub const MANAGER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.10"); - pub const DOCUMENT_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.11"); - pub const DOCUMENT_TITLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.12"); - pub const DOCUMENT_VERSION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.13"); - pub const DOCUMENT_AUTHOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.14"); - pub const DOCUMENT_LOCATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.15"); - pub const HOME_PHONE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.20"); - pub const HOME_TELEPHONE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.20"); - pub const SECRETARY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.21"); - pub const MAIL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.3"); - pub const RFC_822_MAILBOX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.3"); - pub const ASSOCIATED_DOMAIN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.37"); - pub const ASSOCIATED_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.38"); - pub const HOME_POSTAL_ADDRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.39"); - pub const INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.4"); - pub const PERSONAL_TITLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.40"); - pub const MOBILE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.41"); - pub const MOBILE_TELEPHONE_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.41"); - pub const PAGER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.42"); - pub const PAGER_TELEPHONE_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.42"); - pub const CO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.43"); - pub const FRIENDLY_COUNTRY_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.43"); - pub const UNIQUE_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.44"); - pub const ORGANIZATIONAL_STATUS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.45"); - pub const BUILDING_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.48"); - pub const DRINK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.5"); - pub const FAVOURITE_DRINK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.5"); - pub const SINGLE_LEVEL_QUALITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.50"); - pub const DOCUMENT_PUBLISHER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.56"); - pub const ROOM_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.6"); - pub const USER_CLASS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.8"); - pub const HOST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.9"); - pub const DOMAIN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.13"); - pub const RFC_822_LOCAL_PART: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.14"); - pub const DOMAIN_RELATED_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.17"); - pub const FRIENDLY_COUNTRY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.18"); - pub const SIMPLE_SECURITY_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.19"); - pub const ACCOUNT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.5"); - pub const DOCUMENT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.6"); - pub const ROOM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.7"); - pub const DOCUMENT_SERIES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.4.8"); -} -pub mod rfc4530 { - pub const UUID_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.16.2"); - pub const UUID_ORDERING_MATCH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.16.3"); - pub const ENTRY_UUID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.16.4"); -} -pub mod rfc4876 { - pub const DEFAULT_SERVER_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.0"); - pub const DEFAULT_SEARCH_BASE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.1"); - pub const CREDENTIAL_LEVEL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.10"); - pub const OBJECTCLASS_MAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.11"); - pub const DEFAULT_SEARCH_SCOPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.12"); - pub const SERVICE_CREDENTIAL_LEVEL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.13"); - pub const SERVICE_SEARCH_DESCRIPTOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.14"); - pub const SERVICE_AUTHENTICATION_METHOD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.15"); - pub const DEREFERENCE_ALIASES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.16"); - pub const PREFERRED_SERVER_LIST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.2"); - pub const SEARCH_TIME_LIMIT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.3"); - pub const BIND_TIME_LIMIT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.4"); - pub const FOLLOW_REFERRALS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.5"); - pub const AUTHENTICATION_METHOD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.6"); - pub const PROFILE_TTL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.7"); - pub const ATTRIBUTE_MAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.1.9"); - pub const DUA_CONFIG_PROFILE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11.1.3.1.2.5"); -} -pub mod rfc5020 { - pub const ENTRY_DN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.20"); -} -pub mod rfc5280 { - pub const PKCS_9: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9"); - pub const ID_PKIX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7"); - pub const ID_PE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1"); - pub const ID_PE_AUTHORITY_INFO_ACCESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1.1"); - pub const ID_PE_SUBJECT_INFO_ACCESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1.11"); - pub const ID_QT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.2"); - pub const ID_QT_CPS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.2.1"); - pub const ID_QT_UNOTICE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.2.2"); - pub const ID_KP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3"); - pub const ID_KP_SERVER_AUTH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.1"); - pub const ID_KP_CLIENT_AUTH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.2"); - pub const ID_KP_CODE_SIGNING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.3"); - pub const ID_KP_EMAIL_PROTECTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.4"); - pub const ID_KP_TIME_STAMPING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.8"); - pub const ID_KP_OCSP_SIGNING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.9"); - pub const ID_AD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48"); - pub const ID_AD_OCSP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1"); - pub const ID_AD_CA_ISSUERS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.2"); - pub const ID_AD_TIME_STAMPING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.3"); - pub const ID_AD_CA_REPOSITORY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.5"); - pub const HOLD_INSTRUCTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.2.840.10040.2"); - pub const ID_HOLDINSTRUCTION_NONE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.2.840.10040.2.1"); - pub const ID_HOLDINSTRUCTION_CALLISSUER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.2.840.10040.2.2"); - pub const ID_HOLDINSTRUCTION_REJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.2.840.10040.2.3"); - pub const ID_CE: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.29"); - pub const ID_CE_SUBJECT_KEY_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.14"); - pub const ID_CE_KEY_USAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.15"); - pub const ID_CE_PRIVATE_KEY_USAGE_PERIOD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.16"); - pub const ID_CE_SUBJECT_ALT_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.17"); - pub const ID_CE_ISSUER_ALT_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.18"); - pub const ID_CE_BASIC_CONSTRAINTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.19"); - pub const ID_CE_CRL_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.20"); - pub const ID_CE_CRL_REASONS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.21"); - pub const ID_CE_HOLD_INSTRUCTION_CODE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.23"); - pub const ID_CE_INVALIDITY_DATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.24"); - pub const ID_CE_DELTA_CRL_INDICATOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.27"); - pub const ID_CE_ISSUING_DISTRIBUTION_POINT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.28"); - pub const ID_CE_CERTIFICATE_ISSUER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.29"); - pub const ID_CE_NAME_CONSTRAINTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.30"); - pub const ID_CE_CRL_DISTRIBUTION_POINTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.31"); - pub const ID_CE_CERTIFICATE_POLICIES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.32"); - pub const ANY_POLICY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.32.0"); - pub const ID_CE_POLICY_MAPPINGS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.33"); - pub const ID_CE_AUTHORITY_KEY_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.35"); - pub const ID_CE_POLICY_CONSTRAINTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.36"); - pub const ID_CE_EXT_KEY_USAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.37"); - pub const ANY_EXTENDED_KEY_USAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.37.0"); - pub const ID_CE_FRESHEST_CRL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.46"); - pub const ID_CE_INHIBIT_ANY_POLICY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.54"); - pub const ID_CE_SUBJECT_DIRECTORY_ATTRIBUTES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.9"); - pub const ID_AT: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4"); -} -pub mod rfc5911 { - pub const ID_PBKDF_2: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.5.12"); - pub const ID_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.1"); - pub const ID_SIGNED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.2"); - pub const ID_ENVELOPED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.3"); - pub const ID_DIGESTED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.5"); - pub const ID_ENCRYPTED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.6"); - pub const SMIME_CAPABILITIES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.15"); - pub const ID_SMIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16"); - pub const ID_CT_RECEIPT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.1"); - pub const ID_CT_FIRMWARE_PACKAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.16"); - pub const ID_CT_FIRMWARE_LOAD_RECEIPT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.17"); - pub const ID_CT_FIRMWARE_LOAD_ERROR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.18"); - pub const ID_CT_AUTH_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.2"); - pub const ID_CT_AUTH_ENVELOPED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.23"); - pub const ID_CT_CONTENT_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.6"); - pub const ID_CAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.11"); - pub const ID_CAP_PREFER_BINARY_INSIDE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.11.1"); - pub const ID_AA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2"); - pub const ID_AA_RECEIPT_REQUEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.1"); - pub const ID_AA_CONTENT_REFERENCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.10"); - pub const ID_AA_ENCRYP_KEY_PREF: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.11"); - pub const ID_AA_SIGNING_CERTIFICATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.12"); - pub const ID_AA_SECURITY_LABEL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.2"); - pub const ID_AA_ML_EXPAND_HISTORY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.3"); - pub const ID_AA_FIRMWARE_PACKAGE_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.35"); - pub const ID_AA_TARGET_HARDWARE_I_DS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.36"); - pub const ID_AA_DECRYPT_KEY_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.37"); - pub const ID_AA_IMPL_CRYPTO_ALGS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.38"); - pub const ID_AA_WRAPPED_FIRMWARE_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.39"); - pub const ID_AA_CONTENT_HINT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.4"); - pub const ID_AA_COMMUNITY_IDENTIFIERS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.40"); - pub const ID_AA_FIRMWARE_PACKAGE_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.42"); - pub const ID_AA_IMPL_COMPRESS_ALGS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.43"); - pub const ID_AA_SIGNING_CERTIFICATE_V_2: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.47"); - pub const ID_AA_ER_INTERNAL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.49"); - pub const ID_AA_MSG_SIG_DIGEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.5"); - pub const ID_AA_ER_EXTERNAL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.50"); - pub const ID_AA_CONTENT_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.7"); - pub const ID_AA_EQUIVALENT_LABELS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.9"); - pub const ID_ALG_SSDH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.3.10"); - pub const ID_ALG_ESDH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.3.5"); - pub const ID_ALG_CMS_3_DE_SWRAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.3.6"); - pub const ID_ALG_CMSRC_2_WRAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.3.7"); - pub const ID_SKD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8"); - pub const ID_SKD_GL_USE_KEK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.1"); - pub const ID_SKD_GLA_QUERY_REQUEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.11"); - pub const ID_SKD_GLA_QUERY_RESPONSE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.12"); - pub const ID_SKD_GL_PROVIDE_CERT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.13"); - pub const ID_SKD_GL_MANAGE_CERT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.14"); - pub const ID_SKD_GL_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.15"); - pub const ID_SKD_GL_DELETE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.2"); - pub const ID_SKD_GL_ADD_MEMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.3"); - pub const ID_SKD_GL_DELETE_MEMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.4"); - pub const ID_SKD_GL_REKEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.5"); - pub const ID_SKD_GL_ADD_OWNER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.6"); - pub const ID_SKD_GL_REMOVE_OWNER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.7"); - pub const ID_SKD_GL_KEY_COMPROMISE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.8"); - pub const ID_SKD_GLK_REFRESH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8.9"); - pub const ID_CONTENT_TYPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.3"); - pub const ID_MESSAGE_DIGEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.4"); - pub const ID_SIGNING_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.5"); - pub const ID_COUNTERSIGNATURE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.6"); - pub const RC_2_CBC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.3.2"); - pub const DES_EDE_3_CBC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.3.7"); - pub const LTANS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.11"); - pub const ID_CET_SKD_FAIL_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.15.1"); - pub const ID_CMC_GLA_RR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.99"); - pub const ID_CMC_GLA_SKD_ALG_REQUEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.99.1"); - pub const ID_CMC_GLA_SKD_ALG_RESPONSE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.99.2"); - pub const ID_ON_HARDWARE_MODULE_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.8.4"); - pub const HMAC_SHA_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.8.1.2"); - pub const AES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1"); - pub const ID_AES_128_CBC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.2"); - pub const ID_AES_192_CBC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.22"); - pub const ID_AES_192_WRAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.25"); - pub const ID_AES_192_GCM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.26"); - pub const ID_AES_192_CCM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.27"); - pub const ID_AES_256_CBC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.42"); - pub const ID_AES_256_WRAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.45"); - pub const ID_AES_256_GCM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.46"); - pub const ID_AES_256_CCM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.47"); - pub const ID_AES_128_WRAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.5"); - pub const ID_AES_128_GCM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.6"); - pub const ID_AES_128_CCM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.1.7"); -} -pub mod rfc5912 { - pub const ID_DSA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10040.4.1"); - pub const DSA_WITH_SHA_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10040.4.3"); - pub const ID_EC_PUBLIC_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10045.2.1"); - pub const SECP_256_R_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10045.3.1.7"); - pub const ECDSA_WITH_SHA_224: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10045.4.3.1"); - pub const ECDSA_WITH_SHA_256: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10045.4.3.2"); - pub const ECDSA_WITH_SHA_384: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10045.4.3.3"); - pub const ECDSA_WITH_SHA_512: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10045.4.3.4"); - pub const DHPUBLICNUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.10046.2.1"); - pub const ID_PASSWORD_BASED_MAC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113533.7.66.13"); - pub const ID_DH_BASED_MAC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113533.7.66.30"); - pub const PKCS_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1"); - pub const RSA_ENCRYPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.1"); - pub const ID_RSASSA_PSS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.10"); - pub const SHA_256_WITH_RSA_ENCRYPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.11"); - pub const SHA_384_WITH_RSA_ENCRYPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.12"); - pub const SHA_512_WITH_RSA_ENCRYPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.13"); - pub const SHA_224_WITH_RSA_ENCRYPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.14"); - pub const MD_2_WITH_RSA_ENCRYPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.2"); - pub const MD_5_WITH_RSA_ENCRYPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.4"); - pub const SHA_1_WITH_RSA_ENCRYPTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.5"); - pub const ID_RSAES_OAEP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.7"); - pub const ID_MGF_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.8"); - pub const ID_P_SPECIFIED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.9"); - pub const PKCS_9: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9"); - pub const ID_EXTENSION_REQ: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.14"); - pub const ID_SMIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16"); - pub const ID_CT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1"); - pub const ID_CT_SCVP_CERT_VAL_REQUEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.10"); - pub const ID_CT_SCVP_CERT_VAL_RESPONSE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.11"); - pub const ID_CT_SCVP_VAL_POL_REQUEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.12"); - pub const ID_CT_SCVP_VAL_POL_RESPONSE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.13"); - pub const ID_CT_ENC_KEY_WITH_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.21"); - pub const ID_AA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2"); - pub const ID_AA_CMC_UNSIGNED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.34"); - pub const ID_MD_2: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.2.2"); - pub const ID_MD_5: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.2.5"); - pub const SECT_163_K_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.1"); - pub const SECT_163_R_2: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.15"); - pub const SECT_283_K_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.16"); - pub const SECT_283_R_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.17"); - pub const SECT_233_K_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.26"); - pub const SECT_233_R_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.27"); - pub const SECP_224_R_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.33"); - pub const SECP_384_R_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.34"); - pub const SECP_521_R_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.35"); - pub const SECT_409_K_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.36"); - pub const SECT_409_R_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.37"); - pub const SECT_571_K_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.38"); - pub const SECT_571_R_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.0.39"); - pub const ID_EC_DH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.1.12"); - pub const ID_EC_MQV: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.132.1.13"); - pub const ID_SHA_1: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.14.3.2.26"); - pub const ID_PKIX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7"); - pub const ID_PE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1"); - pub const ID_PE_AUTHORITY_INFO_ACCESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1.1"); - pub const ID_PE_AC_PROXYING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1.10"); - pub const ID_PE_SUBJECT_INFO_ACCESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1.11"); - pub const ID_PE_AC_AUDIT_IDENTITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1.4"); - pub const ID_PE_AA_CONTROLS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1.6"); - pub const ID_ACA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.10"); - pub const ID_ACA_AUTHENTICATION_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.10.1"); - pub const ID_ACA_ACCESS_IDENTITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.10.2"); - pub const ID_ACA_CHARGING_IDENTITY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.10.3"); - pub const ID_ACA_GROUP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.10.4"); - pub const ID_ACA_ENC_ATTRS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.10.6"); - pub const ID_CCT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.12"); - pub const ID_CCT_PKI_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.12.2"); - pub const ID_CCT_PKI_RESPONSE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.12.3"); - pub const ID_STC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17"); - pub const ID_STC_BUILD_PKC_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17.1"); - pub const ID_STC_BUILD_VALID_PKC_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17.2"); - pub const ID_STC_BUILD_STATUS_CHECKED_PKC_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17.3"); - pub const ID_STC_BUILD_AA_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17.4"); - pub const ID_STC_BUILD_VALID_AA_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17.5"); - pub const ID_STC_BUILD_STATUS_CHECKED_AA_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17.6"); - pub const ID_STC_STATUS_CHECK_AC_AND_BUILD_STATUS_CHECKED_AA_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17.7"); - pub const ID_SWB: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18"); - pub const ID_SWB_PKC_BEST_CERT_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.1"); - pub const ID_SWB_PKC_CERT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.10"); - pub const ID_SWB_AC_CERT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.11"); - pub const ID_SWB_PKC_ALL_CERT_PATHS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.12"); - pub const ID_SWB_PKC_EE_REVOCATION_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.13"); - pub const ID_SWB_PKC_C_AS_REVOCATION_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.14"); - pub const ID_SWB_PKC_REVOCATION_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.2"); - pub const ID_SWB_PKC_PUBLIC_KEY_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.4"); - pub const ID_SWB_AA_CERT_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.5"); - pub const ID_SWB_AA_REVOCATION_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.6"); - pub const ID_SWB_AC_REVOCATION_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.7"); - pub const ID_SWB_RELAYED_RESPONSES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18.9"); - pub const ID_SVP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19"); - pub const ID_SVP_DEFAULT_VAL_POLICY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19.1"); - pub const ID_SVP_NAME_VAL_ALG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19.2"); - pub const ID_SVP_BASIC_VAL_ALG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19.3"); - pub const NAME_COMP_ALG_SET: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19.4"); - pub const ID_NVA_DN_COMP_ALG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19.4"); - pub const ID_QT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.2"); - pub const ID_QT_CPS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.2.1"); - pub const ID_QT_UNOTICE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.2.2"); - pub const ID_KP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3"); - pub const ID_KP_SERVER_AUTH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.1"); - pub const ID_KP_SCVP_SERVER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.15"); - pub const ID_KP_SCVP_CLIENT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.16"); - pub const ID_KP_CLIENT_AUTH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.2"); - pub const ID_KP_CODE_SIGNING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.3"); - pub const ID_KP_EMAIL_PROTECTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.4"); - pub const ID_KP_TIME_STAMPING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.8"); - pub const ID_KP_OCSP_SIGNING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3.9"); - pub const ID_IT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4"); - pub const ID_IT_CA_PROT_ENC_CERT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.1"); - pub const ID_IT_KEY_PAIR_PARAM_REQ: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.10"); - pub const ID_IT_KEY_PAIR_PARAM_REP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.11"); - pub const ID_IT_REV_PASSPHRASE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.12"); - pub const ID_IT_IMPLICIT_CONFIRM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.13"); - pub const ID_IT_CONFIRM_WAIT_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.14"); - pub const ID_IT_ORIG_PKI_MESSAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.15"); - pub const ID_IT_SUPP_LANG_TAGS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.16"); - pub const ID_IT_SIGN_KEY_PAIR_TYPES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.2"); - pub const ID_IT_ENC_KEY_PAIR_TYPES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.3"); - pub const ID_IT_PREFERRED_SYMM_ALG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.4"); - pub const ID_IT_CA_KEY_UPDATE_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.5"); - pub const ID_IT_CURRENT_CRL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.6"); - pub const ID_IT_UNSUPPORTED_OI_DS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4.7"); - pub const ID_AD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48"); - pub const ID_AD_OCSP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1"); - pub const ID_AD_CA_ISSUERS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.2"); - pub const ID_AD_TIME_STAMPING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.3"); - pub const ID_AD_CA_REPOSITORY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.5"); - pub const ID_PKIP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5"); - pub const ID_REG_CTRL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.1"); - pub const ID_REG_CTRL_REG_TOKEN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.1.1"); - pub const ID_REG_CTRL_AUTHENTICATOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.1.2"); - pub const ID_REG_CTRL_PKI_PUBLICATION_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.1.3"); - pub const ID_REG_CTRL_PKI_ARCHIVE_OPTIONS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.1.4"); - pub const ID_REG_CTRL_OLD_CERT_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.1.5"); - pub const ID_REG_CTRL_PROTOCOL_ENCR_KEY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.1.6"); - pub const ID_REG_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.2"); - pub const ID_REG_INFO_UTF_8_PAIRS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.2.1"); - pub const ID_REG_INFO_CERT_REQ: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.2.2"); - pub const ID_ALG_NO_SIGNATURE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.6.2"); - pub const ID_CMC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7"); - pub const ID_CMC_STATUS_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.1"); - pub const ID_CMC_DECRYPTED_POP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.10"); - pub const ID_CMC_LRA_POP_WITNESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.11"); - pub const ID_CMC_GET_CERT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.15"); - pub const ID_CMC_GET_CRL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.16"); - pub const ID_CMC_REVOKE_REQUEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.17"); - pub const ID_CMC_REG_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.18"); - pub const ID_CMC_RESPONSE_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.19"); - pub const ID_CMC_IDENTIFICATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.2"); - pub const ID_CMC_QUERY_PENDING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.21"); - pub const ID_CMC_POP_LINK_RANDOM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.22"); - pub const ID_CMC_POP_LINK_WITNESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.23"); - pub const ID_CMC_CONFIRM_CERT_ACCEPTANCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.24"); - pub const ID_CMC_STATUS_INFO_V_2: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.25"); - pub const ID_CMC_TRUSTED_ANCHORS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.26"); - pub const ID_CMC_AUTH_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.27"); - pub const ID_CMC_BATCH_REQUESTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.28"); - pub const ID_CMC_BATCH_RESPONSES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.29"); - pub const ID_CMC_IDENTITY_PROOF: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.3"); - pub const ID_CMC_PUBLISH_CERT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.30"); - pub const ID_CMC_MOD_CERT_TEMPLATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.31"); - pub const ID_CMC_CONTROL_PROCESSED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.32"); - pub const ID_CMC_IDENTITY_PROOF_V_2: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.33"); - pub const ID_CMC_POP_LINK_WITNESS_V_2: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.34"); - pub const ID_CMC_DATA_RETURN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.4"); - pub const ID_CMC_TRANSACTION_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.5"); - pub const ID_CMC_SENDER_NONCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.6"); - pub const ID_CMC_RECIPIENT_NONCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.7"); - pub const ID_CMC_ADD_EXTENSIONS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.8"); - pub const ID_CMC_ENCRYPTED_POP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.9"); - pub const ID_KEY_EXCHANGE_ALGORITHM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.2.1.1.22"); - pub const ID_SHA_256: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.2.1"); - pub const ID_SHA_384: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.2.2"); - pub const ID_SHA_512: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.2.3"); - pub const ID_SHA_224: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.2.4"); - pub const DSA_WITH_SHA_224: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.3.1"); - pub const DSA_WITH_SHA_256: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.3.2"); - pub const HOLD_INSTRUCTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.2.840.10040.2"); - pub const ID_HOLDINSTRUCTION_NONE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.2.840.10040.2.1"); - pub const ID_HOLDINSTRUCTION_CALLISSUER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.2.840.10040.2.2"); - pub const ID_HOLDINSTRUCTION_REJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.2.840.10040.2.3"); - pub const ID_CE: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.29"); - pub const ID_CE_SUBJECT_KEY_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.14"); - pub const ID_CE_KEY_USAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.15"); - pub const ID_CE_PRIVATE_KEY_USAGE_PERIOD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.16"); - pub const ID_CE_SUBJECT_ALT_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.17"); - pub const ID_CE_ISSUER_ALT_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.18"); - pub const ID_CE_BASIC_CONSTRAINTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.19"); - pub const ID_CE_CRL_NUMBER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.20"); - pub const ID_CE_CRL_REASONS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.21"); - pub const ID_CE_HOLD_INSTRUCTION_CODE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.23"); - pub const ID_CE_INVALIDITY_DATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.24"); - pub const ID_CE_DELTA_CRL_INDICATOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.27"); - pub const ID_CE_ISSUING_DISTRIBUTION_POINT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.28"); - pub const ID_CE_CERTIFICATE_ISSUER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.29"); - pub const ID_CE_NAME_CONSTRAINTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.30"); - pub const ID_CE_CRL_DISTRIBUTION_POINTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.31"); - pub const ID_CE_CERTIFICATE_POLICIES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.32"); - pub const ID_CE_POLICY_MAPPINGS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.33"); - pub const ID_CE_AUTHORITY_KEY_IDENTIFIER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.35"); - pub const ID_CE_POLICY_CONSTRAINTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.36"); - pub const ID_CE_EXT_KEY_USAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.37"); - pub const ANY_EXTENDED_KEY_USAGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.37.0"); - pub const ID_CE_FRESHEST_CRL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.46"); - pub const ID_CE_INHIBIT_ANY_POLICY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.54"); - pub const ID_CE_TARGET_INFORMATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.55"); - pub const ID_CE_NO_REV_AVAIL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.56"); - pub const ID_CE_SUBJECT_DIRECTORY_ATTRIBUTES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.5.29.9"); - pub const ID_AT: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4"); - pub const ID_AT_ROLE: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.72"); -} -pub mod rfc6109 { - pub const LDIF_LOCATION_URL_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.1.1"); - pub const PROVIDER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.1.2"); - pub const PROVIDER_CERTIFICATE_HASH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.2.1"); - pub const PROVIDER_CERTIFICATE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.2.2"); - pub const PROVIDER_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.2.3"); - pub const MAIL_RECEIPT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.2.4"); - pub const MANAGED_DOMAINS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.2.5"); - pub const LDIF_LOCATION_URL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.2.6"); - pub const PROVIDER_UNIT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.16572.2.2.7"); -} -pub mod rfc6268 { - pub const RSADSI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549"); - pub const ID_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.1"); - pub const ID_SIGNED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.2"); - pub const ID_ENVELOPED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.3"); - pub const ID_DIGESTED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.5"); - pub const ID_ENCRYPTED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.7.6"); - pub const ID_CT_CONTENT_COLLECTION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.19"); - pub const ID_CT_AUTH_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.2"); - pub const ID_CT_CONTENT_WITH_ATTRS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.20"); - pub const ID_CT_AUTH_ENVELOPED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.23"); - pub const ID_CT_CONTENT_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.6"); - pub const ID_CT_COMPRESSED_DATA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1.9"); - pub const ID_AA_BINARY_SIGNING_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2.46"); - pub const ID_ALG_ZLIB_COMPRESS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.3.8"); - pub const ID_AA_MULTIPLE_SIGNATURES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.2.51"); - pub const ID_CONTENT_TYPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.3"); - pub const ID_MESSAGE_DIGEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.4"); - pub const ID_SIGNING_TIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.5"); - pub const ID_COUNTERSIGNATURE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.6"); - pub const DIGEST_ALGORITHM: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.2"); - pub const ID_HMAC_WITH_SHA_384: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.2.10"); - pub const ID_HMAC_WITH_SHA_512: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.2.11"); - pub const ID_HMAC_WITH_SHA_224: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.2.8"); - pub const ID_HMAC_WITH_SHA_256: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.2.9"); -} -pub mod rfc6960 { - pub const ID_PKIX_OCSP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1"); - pub const ID_PKIX_OCSP_BASIC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.1"); - pub const ID_PKIX_OCSP_NONCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.2"); - pub const ID_PKIX_OCSP_CRL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.3"); - pub const ID_PKIX_OCSP_RESPONSE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.4"); - pub const ID_PKIX_OCSP_NOCHECK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.5"); - pub const ID_PKIX_OCSP_ARCHIVE_CUTOFF: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.6"); - pub const ID_PKIX_OCSP_SERVICE_LOCATOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.7"); - pub const ID_PKIX_OCSP_PREF_SIG_ALGS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.8"); - pub const ID_PKIX_OCSP_EXTENDED_REVOKE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1.9"); -} -pub mod rfc6962 { - pub const GOOGLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11129"); - pub const CT_PRECERT_SCTS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11129.2.4.2"); - pub const CT_PRECERT_POISON: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11129.2.4.3"); - pub const CT_PRECERT_SIGNING_CERT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.11129.2.4.4"); -} -pub mod rfc7107 { - pub const ID_SMIME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16"); - pub const ID_MOD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.0"); - pub const ID_CT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.1"); - pub const ID_EIT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.10"); - pub const ID_CAP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.11"); - pub const ID_PSKC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.12"); - pub const ID_AA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.2"); - pub const ID_ALG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.3"); - pub const ID_CD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.4"); - pub const ID_SPQ: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.5"); - pub const ID_CTI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.6"); - pub const ID_TSP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.7"); - pub const ID_SKD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.8"); - pub const ID_STI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.2.840.113549.1.9.16.9"); -} -pub mod rfc7299 { - pub const ID_PKIX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7"); - pub const ID_MOD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.0"); - pub const ID_PE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.1"); - pub const ID_ACA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.10"); - pub const ID_QCS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.11"); - pub const ID_CCT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.12"); - pub const ID_TEST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.13"); - pub const ID_CP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.14"); - pub const ID_CET: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.15"); - pub const ID_RI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.16"); - pub const ID_SCT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.17"); - pub const ID_SWB: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.18"); - pub const ID_SVP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19"); - pub const ID_NVAE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19.2"); - pub const ID_BVAE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19.3"); - pub const ID_DNVAE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.19.4"); - pub const ID_QT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.2"); - pub const ID_LOGO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.20"); - pub const ID_PPL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.21"); - pub const ID_MR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.22"); - pub const ID_SKIS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.23"); - pub const ID_KP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.3"); - pub const ID_IT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.4"); - pub const ID_AD: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48"); - pub const ID_PKIX_OCSP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.48.1"); - pub const ID_PKIP: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5"); - pub const ID_REG_CTRL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.1"); - pub const ID_REG_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.5.2"); - pub const ID_ALG: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.6"); - pub const ID_CMC: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7"); - pub const ID_CMC_GLA_RR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.7.99"); - pub const ID_ON: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.8"); - pub const ID_PDA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.5.5.7.9"); -} -pub mod rfc7532 { - pub const FEDFS_UUID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.1"); - pub const FEDFS_FSL_PORT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.10"); - pub const FEDFS_NFS_PATH: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.100"); - pub const FEDFS_NSDB_CONTAINER_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.1001"); - pub const FEDFS_FSN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.1002"); - pub const FEDFS_FSL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.1003"); - pub const FEDFS_NFS_FSL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.1004"); - pub const FEDFS_NFS_MAJOR_VER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.101"); - pub const FEDFS_NFS_MINOR_VER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.102"); - pub const FEDFS_NFS_CURRENCY: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.103"); - pub const FEDFS_NFS_GEN_FLAG_WRITABLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.104"); - pub const FEDFS_NFS_GEN_FLAG_GOING: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.105"); - pub const FEDFS_NFS_GEN_FLAG_SPLIT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.106"); - pub const FEDFS_NFS_TRANS_FLAG_RDMA: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.107"); - pub const FEDFS_NFS_CLASS_SIMUL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.108"); - pub const FEDFS_NFS_CLASS_HANDLE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.109"); - pub const FEDFS_FSL_TTL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.11"); - pub const FEDFS_NFS_CLASS_FILEID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.110"); - pub const FEDFS_NFS_CLASS_WRITEVER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.111"); - pub const FEDFS_NFS_CLASS_CHANGE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.112"); - pub const FEDFS_NFS_CLASS_READDIR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.113"); - pub const FEDFS_NFS_READ_RANK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.114"); - pub const FEDFS_NFS_READ_ORDER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.115"); - pub const FEDFS_NFS_WRITE_RANK: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.116"); - pub const FEDFS_NFS_WRITE_ORDER: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.117"); - pub const FEDFS_NFS_VAR_SUB: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.118"); - pub const FEDFS_NFS_VALID_FOR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.119"); - pub const FEDFS_ANNOTATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.12"); - pub const FEDFS_NFS_URI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.120"); - pub const FEDFS_DESCR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.13"); - pub const FEDFS_NCE_DN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.14"); - pub const FEDFS_FSN_TTL: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.15"); - pub const FEDFS_NET_ADDR: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.2"); - pub const FEDFS_NET_PORT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.3"); - pub const FEDFS_FSN_UUID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.4"); - pub const FEDFS_NSDB_NAME: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.5"); - pub const FEDFS_NSDB_PORT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.6"); - pub const FEDFS_NCE_PREFIX: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.7"); - pub const FEDFS_FSL_UUID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.8"); - pub const FEDFS_FSL_HOST: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.4.1.31103.1.9"); -} -pub mod rfc7612 { - pub const PRINTER_DEVICE_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.24.46.1.101"); - pub const PRINTER_DEVICE_SERVICE_COUNT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.24.46.1.102"); - pub const PRINTER_UUID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.24.46.1.104"); - pub const PRINTER_CHARGE_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.24.46.1.105"); - pub const PRINTER_CHARGE_INFO_URI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.24.46.1.106"); - pub const PRINTER_GEO_LOCATION: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.24.46.1.107"); - pub const PRINTER_IPP_FEATURES_SUPPORTED: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.18.0.2.24.46.1.108"); -} -pub mod rfc8284 { - pub const JID_OBJECT: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.23.1"); - pub const JID: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("1.3.6.1.1.23.2"); -} -pub mod rfc8410 { - pub const ID_EDWARDS_CURVE_ALGS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.101"); - pub const ID_X_25519: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.101.110"); - pub const ID_X_448: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.101.111"); - pub const ID_ED_25519: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.101.112"); - pub const ID_ED_448: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("1.3.101.113"); -} -pub mod rfc8894 { - pub const ID_VERI_SIGN: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733"); - pub const ID_PKI: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733.1"); - pub const ID_ATTRIBUTES: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733.1.9"); - pub const ID_MESSAGE_TYPE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733.1.9.2"); - pub const ID_PKI_STATUS: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733.1.9.3"); - pub const ID_FAIL_INFO: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733.1.9.4"); - pub const ID_SENDER_NONCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733.1.9.5"); - pub const ID_RECIPIENT_NONCE: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733.1.9.6"); - pub const ID_TRANSACTION_ID: crate::ObjectIdentifier = - crate::ObjectIdentifier::new_unwrap("2.16.840.1.113733.1.9.7"); -} -pub const DB: super::Database<'static> = super::Database(&[ - (&rfc1274::TEXT_ENCODED_OR_ADDRESS, "textEncodedORAddress"), - (&rfc1274::OTHER_MAILBOX, "otherMailbox"), - (&rfc1274::LAST_MODIFIED_TIME, "lastModifiedTime"), - (&rfc1274::LAST_MODIFIED_BY, "lastModifiedBy"), - (&rfc1274::A_RECORD, "aRecord"), - (&rfc1274::MD_RECORD, "mDRecord"), - (&rfc1274::MX_RECORD, "mXRecord"), - (&rfc1274::NS_RECORD, "nSRecord"), - (&rfc1274::SOA_RECORD, "sOARecord"), - (&rfc1274::CNAME_RECORD, "cNAMERecord"), - (&rfc1274::JANET_MAILBOX, "janetMailbox"), - (&rfc1274::MAIL_PREFERENCE_OPTION, "mailPreferenceOption"), - (&rfc1274::DSA_QUALITY, "dSAQuality"), - (&rfc1274::SUBTREE_MINIMUM_QUALITY, "subtreeMinimumQuality"), - (&rfc1274::SUBTREE_MAXIMUM_QUALITY, "subtreeMaximumQuality"), - (&rfc1274::PERSONAL_SIGNATURE, "personalSignature"), - (&rfc1274::DIT_REDIRECT, "dITRedirect"), - (&rfc1274::AUDIO, "audio"), - (&rfc1274::PHOTO, "photo"), - (&rfc1274::DNS_DOMAIN, "dNSDomain"), - (&rfc1274::PILOT_ORGANIZATION, "pilotOrganization"), - (&rfc1274::PILOT_DSA, "pilotDSA"), - (&rfc1274::QUALITY_LABELLED_DATA, "qualityLabelledData"), - (&rfc1274::PILOT_OBJECT, "pilotObject"), - (&rfc1274::PILOT_PERSON, "pilotPerson"), - (&rfc2079::LABELED_URI, "labeledURI"), - (&rfc2079::LABELED_URI_OBJECT, "labeledURIObject"), - (&rfc2164::RFC_822_TO_X_400_MAPPING, "rFC822ToX400Mapping"), - (&rfc2164::X_400_TO_RFC_822_MAPPING, "x400ToRFC822Mapping"), - ( - &rfc2164::OMITTED_OR_ADDRESS_COMPONENT, - "omittedORAddressComponent", - ), - (&rfc2164::MIXER_GATEWAY, "mixerGateway"), - (&rfc2164::ASSOCIATED_X_400_GATEWAY, "associatedX400Gateway"), - (&rfc2164::ASSOCIATED_OR_ADDRESS, "associatedORAddress"), - ( - &rfc2164::OR_ADDRESS_COMPONENT_TYPE, - "oRAddressComponentType", - ), - ( - &rfc2164::ASSOCIATED_INTERNET_GATEWAY, - "associatedInternetGateway", - ), - (&rfc2164::MCGAM_TABLES, "mcgamTables"), - (&rfc2247::DOMAIN_NAME_FORM, "domainNameForm"), - ( - &rfc2252::PRESENTATION_ADDRESS_MATCH, - "presentationAddressMatch", - ), - ( - &rfc2252::PROTOCOL_INFORMATION_MATCH, - "protocolInformationMatch", - ), - (&rfc2256::KNOWLEDGE_INFORMATION, "knowledgeInformation"), - (&rfc2256::PRESENTATION_ADDRESS, "presentationAddress"), - ( - &rfc2256::SUPPORTED_APPLICATION_CONTEXT, - "supportedApplicationContext", - ), - (&rfc2256::PROTOCOL_INFORMATION, "protocolInformation"), - (&rfc2256::DMD_NAME, "dmdName"), - (&rfc2256::STATE_OR_PROVINCE_NAME, "stateOrProvinceName"), - (&rfc2256::STREET_ADDRESS, "streetAddress"), - (&rfc2256::APPLICATION_ENTITY, "applicationEntity"), - (&rfc2256::DSA, "dSA"), - (&rfc2256::DMD, "dmd"), - (&rfc2293::SUBTREE, "subtree"), - (&rfc2293::TABLE, "table"), - (&rfc2293::TABLE_ENTRY, "tableEntry"), - (&rfc2293::TEXT_TABLE_ENTRY, "textTableEntry"), - ( - &rfc2293::DISTINGUISHED_NAME_TABLE_ENTRY, - "distinguishedNameTableEntry", - ), - (&rfc2293::TEXT_TABLE_KEY, "textTableKey"), - (&rfc2293::TEXT_TABLE_VALUE, "textTableValue"), - ( - &rfc2293::DISTINGUISHED_NAME_TABLE_KEY, - "distinguishedNameTableKey", - ), - (&rfc2589::DYNAMIC_OBJECT, "dynamicObject"), - (&rfc2589::ENTRY_TTL, "entryTtl"), - (&rfc2589::DYNAMIC_SUBTREES, "dynamicSubtrees"), - (&rfc2739::CAL_CAL_URI, "calCalURI"), - (&rfc2739::CAL_FBURL, "calFBURL"), - (&rfc2739::CAL_CAPURI, "calCAPURI"), - (&rfc2739::CAL_CAL_ADR_URI, "calCalAdrURI"), - (&rfc2739::CAL_OTHER_CAL_UR_IS, "calOtherCalURIs"), - (&rfc2739::CAL_OTHER_FBUR_LS, "calOtherFBURLs"), - (&rfc2739::CAL_OTHER_CAPUR_IS, "calOtherCAPURIs"), - (&rfc2739::CAL_OTHER_CAL_ADR_UR_IS, "calOtherCalAdrURIs"), - (&rfc2739::CAL_ENTRY, "calEntry"), - (&rfc2798::JPEG_PHOTO, "jpegPhoto"), - (&rfc2798::CAR_LICENSE, "carLicense"), - (&rfc2798::DEPARTMENT_NUMBER, "departmentNumber"), - (&rfc2798::USER_PKCS_12, "userPKCS12"), - (&rfc2798::DISPLAY_NAME, "displayName"), - (&rfc2798::EMPLOYEE_NUMBER, "employeeNumber"), - (&rfc2798::PREFERRED_LANGUAGE, "preferredLanguage"), - (&rfc2798::EMPLOYEE_TYPE, "employeeType"), - (&rfc2798::USER_SMIME_CERTIFICATE, "userSMIMECertificate"), - (&rfc2798::INET_ORG_PERSON, "inetOrgPerson"), - (&rfc3280::EMAIL, "email"), - (&rfc3280::EMAIL_ADDRESS, "emailAddress"), - (&rfc3280::PSEUDONYM, "pseudonym"), - (&rfc3296::REF, "ref"), - (&rfc3296::REFERRAL, "referral"), - ( - &rfc3671::COLLECTIVE_ATTRIBUTE_SUBENTRIES, - "collectiveAttributeSubentries", - ), - (&rfc3671::COLLECTIVE_EXCLUSIONS, "collectiveExclusions"), - ( - &rfc3671::COLLECTIVE_ATTRIBUTE_SUBENTRY, - "collectiveAttributeSubentry", - ), - (&rfc3671::C_O, "c-o"), - (&rfc3671::C_OU, "c-ou"), - (&rfc3671::C_POSTAL_ADDRESS, "c-PostalAddress"), - (&rfc3671::C_POSTAL_CODE, "c-PostalCode"), - (&rfc3671::C_POST_OFFICE_BOX, "c-PostOfficeBox"), - ( - &rfc3671::C_PHYSICAL_DELIVERY_OFFICE, - "c-PhysicalDeliveryOffice", - ), - (&rfc3671::C_TELEPHONE_NUMBER, "c-TelephoneNumber"), - (&rfc3671::C_TELEX_NUMBER, "c-TelexNumber"), - ( - &rfc3671::C_FACSIMILE_TELEPHONE_NUMBER, - "c-FacsimileTelephoneNumber", - ), - ( - &rfc3671::C_INTERNATIONAL_ISDN_NUMBER, - "c-InternationalISDNNumber", - ), - (&rfc3671::C_L, "c-l"), - (&rfc3671::C_ST, "c-st"), - (&rfc3671::C_STREET, "c-street"), - (&rfc3672::SUBENTRY, "subentry"), - (&rfc3672::ADMINISTRATIVE_ROLE, "administrativeRole"), - (&rfc3672::SUBTREE_SPECIFICATION, "subtreeSpecification"), - (&rfc3672::AUTONOMOUS_AREA, "autonomousArea"), - ( - &rfc3672::ACCESS_CONTROL_SPECIFIC_AREA, - "accessControlSpecificArea", - ), - ( - &rfc3672::ACCESS_CONTROL_INNER_AREA, - "accessControlInnerArea", - ), - ( - &rfc3672::SUBSCHEMA_ADMIN_SPECIFIC_AREA, - "subschemaAdminSpecificArea", - ), - ( - &rfc3672::COLLECTIVE_ATTRIBUTE_SPECIFIC_AREA, - "collectiveAttributeSpecificArea", - ), - ( - &rfc3672::COLLECTIVE_ATTRIBUTE_INNER_AREA, - "collectiveAttributeInnerArea", - ), - (&rfc3687::COMPONENT_FILTER_MATCH, "componentFilterMatch"), - (&rfc3687::RDN_MATCH, "rdnMatch"), - (&rfc3687::PRESENT_MATCH, "presentMatch"), - (&rfc3687::ALL_COMPONENTS_MATCH, "allComponentsMatch"), - ( - &rfc3687::DIRECTORY_COMPONENTS_MATCH, - "directoryComponentsMatch", - ), - (&rfc3698::STORED_PREFIX_MATCH, "storedPrefixMatch"), - (&rfc3703::PCIM_POLICY, "pcimPolicy"), - ( - &rfc3703::PCIM_RULE_ACTION_ASSOCIATION, - "pcimRuleActionAssociation", - ), - (&rfc3703::PCIM_CONDITION_AUX_CLASS, "pcimConditionAuxClass"), - (&rfc3703::PCIM_TPC_AUX_CLASS, "pcimTPCAuxClass"), - ( - &rfc3703::PCIM_CONDITION_VENDOR_AUX_CLASS, - "pcimConditionVendorAuxClass", - ), - (&rfc3703::PCIM_ACTION_AUX_CLASS, "pcimActionAuxClass"), - ( - &rfc3703::PCIM_ACTION_VENDOR_AUX_CLASS, - "pcimActionVendorAuxClass", - ), - (&rfc3703::PCIM_POLICY_INSTANCE, "pcimPolicyInstance"), - (&rfc3703::PCIM_ELEMENT_AUX_CLASS, "pcimElementAuxClass"), - (&rfc3703::PCIM_REPOSITORY, "pcimRepository"), - ( - &rfc3703::PCIM_REPOSITORY_AUX_CLASS, - "pcimRepositoryAuxClass", - ), - (&rfc3703::PCIM_GROUP, "pcimGroup"), - (&rfc3703::PCIM_REPOSITORY_INSTANCE, "pcimRepositoryInstance"), - ( - &rfc3703::PCIM_SUBTREES_PTR_AUX_CLASS, - "pcimSubtreesPtrAuxClass", - ), - ( - &rfc3703::PCIM_GROUP_CONTAINMENT_AUX_CLASS, - "pcimGroupContainmentAuxClass", - ), - ( - &rfc3703::PCIM_RULE_CONTAINMENT_AUX_CLASS, - "pcimRuleContainmentAuxClass", - ), - (&rfc3703::PCIM_GROUP_AUX_CLASS, "pcimGroupAuxClass"), - (&rfc3703::PCIM_GROUP_INSTANCE, "pcimGroupInstance"), - (&rfc3703::PCIM_RULE, "pcimRule"), - (&rfc3703::PCIM_RULE_AUX_CLASS, "pcimRuleAuxClass"), - (&rfc3703::PCIM_RULE_INSTANCE, "pcimRuleInstance"), - ( - &rfc3703::PCIM_RULE_CONDITION_ASSOCIATION, - "pcimRuleConditionAssociation", - ), - ( - &rfc3703::PCIM_RULE_VALIDITY_ASSOCIATION, - "pcimRuleValidityAssociation", - ), - ( - &rfc3703::PCIM_RULE_VALIDITY_PERIOD_LIST, - "pcimRuleValidityPeriodList", - ), - (&rfc3703::PCIM_RULE_USAGE, "pcimRuleUsage"), - (&rfc3703::PCIM_RULE_PRIORITY, "pcimRulePriority"), - (&rfc3703::PCIM_RULE_MANDATORY, "pcimRuleMandatory"), - ( - &rfc3703::PCIM_RULE_SEQUENCED_ACTIONS, - "pcimRuleSequencedActions", - ), - (&rfc3703::PCIM_ROLES, "pcimRoles"), - ( - &rfc3703::PCIM_CONDITION_GROUP_NUMBER, - "pcimConditionGroupNumber", - ), - (&rfc3703::PCIM_CONDITION_NEGATED, "pcimConditionNegated"), - (&rfc3703::PCIM_CONDITION_NAME, "pcimConditionName"), - (&rfc3703::PCIM_CONDITION_DN, "pcimConditionDN"), - ( - &rfc3703::PCIM_VALIDITY_CONDITION_NAME, - "pcimValidityConditionName", - ), - ( - &rfc3703::PCIM_TIME_PERIOD_CONDITION_DN, - "pcimTimePeriodConditionDN", - ), - (&rfc3703::PCIM_ACTION_NAME, "pcimActionName"), - (&rfc3703::PCIM_ACTION_ORDER, "pcimActionOrder"), - (&rfc3703::PCIM_ACTION_DN, "pcimActionDN"), - (&rfc3703::PCIM_TPC_TIME, "pcimTPCTime"), - ( - &rfc3703::PCIM_TPC_MONTH_OF_YEAR_MASK, - "pcimTPCMonthOfYearMask", - ), - ( - &rfc3703::PCIM_TPC_DAY_OF_MONTH_MASK, - "pcimTPCDayOfMonthMask", - ), - (&rfc3703::PCIM_TPC_DAY_OF_WEEK_MASK, "pcimTPCDayOfWeekMask"), - (&rfc3703::PCIM_TPC_TIME_OF_DAY_MASK, "pcimTPCTimeOfDayMask"), - (&rfc3703::PCIM_KEYWORDS, "pcimKeywords"), - ( - &rfc3703::PCIM_TPC_LOCAL_OR_UTC_TIME, - "pcimTPCLocalOrUtcTime", - ), - ( - &rfc3703::PCIM_VENDOR_CONSTRAINT_DATA, - "pcimVendorConstraintData", - ), - ( - &rfc3703::PCIM_VENDOR_CONSTRAINT_ENCODING, - "pcimVendorConstraintEncoding", - ), - (&rfc3703::PCIM_VENDOR_ACTION_DATA, "pcimVendorActionData"), - ( - &rfc3703::PCIM_VENDOR_ACTION_ENCODING, - "pcimVendorActionEncoding", - ), - ( - &rfc3703::PCIM_POLICY_INSTANCE_NAME, - "pcimPolicyInstanceName", - ), - (&rfc3703::PCIM_REPOSITORY_NAME, "pcimRepositoryName"), - ( - &rfc3703::PCIM_SUBTREES_AUX_CONTAINED_SET, - "pcimSubtreesAuxContainedSet", - ), - ( - &rfc3703::PCIM_GROUPS_AUX_CONTAINED_SET, - "pcimGroupsAuxContainedSet", - ), - ( - &rfc3703::PCIM_RULES_AUX_CONTAINED_SET, - "pcimRulesAuxContainedSet", - ), - (&rfc3703::PCIM_GROUP_NAME, "pcimGroupName"), - (&rfc3703::PCIM_RULE_NAME, "pcimRuleName"), - (&rfc3703::PCIM_RULE_ENABLED, "pcimRuleEnabled"), - ( - &rfc3703::PCIM_RULE_CONDITION_LIST_TYPE, - "pcimRuleConditionListType", - ), - (&rfc3703::PCIM_RULE_CONDITION_LIST, "pcimRuleConditionList"), - (&rfc3703::PCIM_RULE_ACTION_LIST, "pcimRuleActionList"), - (&rfc3712::PRINTER_XRI_SUPPORTED, "printer-xri-supported"), - (&rfc3712::PRINTER_ALIASES, "printer-aliases"), - ( - &rfc3712::PRINTER_CHARSET_CONFIGURED, - "printer-charset-configured", - ), - ( - &rfc3712::PRINTER_JOB_PRIORITY_SUPPORTED, - "printer-job-priority-supported", - ), - ( - &rfc3712::PRINTER_JOB_K_OCTETS_SUPPORTED, - "printer-job-k-octets-supported", - ), - ( - &rfc3712::PRINTER_CURRENT_OPERATOR, - "printer-current-operator", - ), - (&rfc3712::PRINTER_SERVICE_PERSON, "printer-service-person"), - ( - &rfc3712::PRINTER_DELIVERY_ORIENTATION_SUPPORTED, - "printer-delivery-orientation-supported", - ), - ( - &rfc3712::PRINTER_STACKING_ORDER_SUPPORTED, - "printer-stacking-order-supported", - ), - ( - &rfc3712::PRINTER_OUTPUT_FEATURES_SUPPORTED, - "printer-output-features-supported", - ), - ( - &rfc3712::PRINTER_MEDIA_LOCAL_SUPPORTED, - "printer-media-local-supported", - ), - ( - &rfc3712::PRINTER_COPIES_SUPPORTED, - "printer-copies-supported", - ), - ( - &rfc3712::PRINTER_NATURAL_LANGUAGE_CONFIGURED, - "printer-natural-language-configured", - ), - ( - &rfc3712::PRINTER_PRINT_QUALITY_SUPPORTED, - "printer-print-quality-supported", - ), - ( - &rfc3712::PRINTER_RESOLUTION_SUPPORTED, - "printer-resolution-supported", - ), - (&rfc3712::PRINTER_MEDIA_SUPPORTED, "printer-media-supported"), - (&rfc3712::PRINTER_SIDES_SUPPORTED, "printer-sides-supported"), - ( - &rfc3712::PRINTER_NUMBER_UP_SUPPORTED, - "printer-number-up-supported", - ), - ( - &rfc3712::PRINTER_FINISHINGS_SUPPORTED, - "printer-finishings-supported", - ), - ( - &rfc3712::PRINTER_PAGES_PER_MINUTE_COLOR, - "printer-pages-per-minute-color", - ), - ( - &rfc3712::PRINTER_PAGES_PER_MINUTE, - "printer-pages-per-minute", - ), - ( - &rfc3712::PRINTER_COMPRESSION_SUPPORTED, - "printer-compression-supported", - ), - (&rfc3712::PRINTER_COLOR_SUPPORTED, "printer-color-supported"), - ( - &rfc3712::PRINTER_DOCUMENT_FORMAT_SUPPORTED, - "printer-document-format-supported", - ), - ( - &rfc3712::PRINTER_CHARSET_SUPPORTED, - "printer-charset-supported", - ), - ( - &rfc3712::PRINTER_MULTIPLE_DOCUMENT_JOBS_SUPPORTED, - "printer-multiple-document-jobs-supported", - ), - ( - &rfc3712::PRINTER_IPP_VERSIONS_SUPPORTED, - "printer-ipp-versions-supported", - ), - (&rfc3712::PRINTER_MORE_INFO, "printer-more-info"), - (&rfc3712::PRINTER_NAME, "printer-name"), - (&rfc3712::PRINTER_LOCATION, "printer-location"), - ( - &rfc3712::PRINTER_GENERATED_NATURAL_LANGUAGE_SUPPORTED, - "printer-generated-natural-language-supported", - ), - (&rfc3712::PRINTER_MAKE_AND_MODEL, "printer-make-and-model"), - (&rfc3712::PRINTER_INFO, "printer-info"), - (&rfc3712::PRINTER_URI, "printer-uri"), - (&rfc3712::PRINTER_LPR, "printerLPR"), - (&rfc3712::SLP_SERVICE_PRINTER, "slpServicePrinter"), - (&rfc3712::PRINTER_SERVICE, "printerService"), - (&rfc3712::PRINTER_IPP, "printerIPP"), - ( - &rfc3712::PRINTER_SERVICE_AUX_CLASS, - "printerServiceAuxClass", - ), - (&rfc3712::PRINTER_ABSTRACT, "printerAbstract"), - (&rfc4104::PCELS_POLICY_SET, "pcelsPolicySet"), - (&rfc4104::PCELS_ACTION_ASSOCIATION, "pcelsActionAssociation"), - ( - &rfc4104::PCELS_SIMPLE_CONDITION_AUX_CLASS, - "pcelsSimpleConditionAuxClass", - ), - ( - &rfc4104::PCELS_COMPOUND_CONDITION_AUX_CLASS, - "pcelsCompoundConditionAuxClass", - ), - ( - &rfc4104::PCELS_COMPOUND_FILTER_CONDITION_AUX_CLASS, - "pcelsCompoundFilterConditionAuxClass", - ), - ( - &rfc4104::PCELS_SIMPLE_ACTION_AUX_CLASS, - "pcelsSimpleActionAuxClass", - ), - ( - &rfc4104::PCELS_COMPOUND_ACTION_AUX_CLASS, - "pcelsCompoundActionAuxClass", - ), - (&rfc4104::PCELS_VARIABLE, "pcelsVariable"), - ( - &rfc4104::PCELS_EXPLICIT_VARIABLE_AUX_CLASS, - "pcelsExplicitVariableAuxClass", - ), - ( - &rfc4104::PCELS_IMPLICIT_VARIABLE_AUX_CLASS, - "pcelsImplicitVariableAuxClass", - ), - ( - &rfc4104::PCELS_SOURCE_I_PV_4_VARIABLE_AUX_CLASS, - "pcelsSourceIPv4VariableAuxClass", - ), - ( - &rfc4104::PCELS_POLICY_SET_ASSOCIATION, - "pcelsPolicySetAssociation", - ), - ( - &rfc4104::PCELS_SOURCE_I_PV_6_VARIABLE_AUX_CLASS, - "pcelsSourceIPv6VariableAuxClass", - ), - ( - &rfc4104::PCELS_DESTINATION_I_PV_4_VARIABLE_AUX_CLASS, - "pcelsDestinationIPv4VariableAuxClass", - ), - ( - &rfc4104::PCELS_DESTINATION_I_PV_6_VARIABLE_AUX_CLASS, - "pcelsDestinationIPv6VariableAuxClass", - ), - ( - &rfc4104::PCELS_SOURCE_PORT_VARIABLE_AUX_CLASS, - "pcelsSourcePortVariableAuxClass", - ), - ( - &rfc4104::PCELS_DESTINATION_PORT_VARIABLE_AUX_CLASS, - "pcelsDestinationPortVariableAuxClass", - ), - ( - &rfc4104::PCELS_IP_PROTOCOL_VARIABLE_AUX_CLASS, - "pcelsIPProtocolVariableAuxClass", - ), - ( - &rfc4104::PCELS_IP_VERSION_VARIABLE_AUX_CLASS, - "pcelsIPVersionVariableAuxClass", - ), - ( - &rfc4104::PCELS_IP_TO_S_VARIABLE_AUX_CLASS, - "pcelsIPToSVariableAuxClass", - ), - ( - &rfc4104::PCELS_DSCP_VARIABLE_AUX_CLASS, - "pcelsDSCPVariableAuxClass", - ), - ( - &rfc4104::PCELS_FLOW_ID_VARIABLE_AUX_CLASS, - "pcelsFlowIdVariableAuxClass", - ), - (&rfc4104::PCELS_GROUP, "pcelsGroup"), - ( - &rfc4104::PCELS_SOURCE_MAC_VARIABLE_AUX_CLASS, - "pcelsSourceMACVariableAuxClass", - ), - ( - &rfc4104::PCELS_DESTINATION_MAC_VARIABLE_AUX_CLASS, - "pcelsDestinationMACVariableAuxClass", - ), - ( - &rfc4104::PCELS_VLAN_VARIABLE_AUX_CLASS, - "pcelsVLANVariableAuxClass", - ), - ( - &rfc4104::PCELS_CO_S_VARIABLE_AUX_CLASS, - "pcelsCoSVariableAuxClass", - ), - ( - &rfc4104::PCELS_ETHERTYPE_VARIABLE_AUX_CLASS, - "pcelsEthertypeVariableAuxClass", - ), - ( - &rfc4104::PCELS_SOURCE_SAP_VARIABLE_AUX_CLASS, - "pcelsSourceSAPVariableAuxClass", - ), - ( - &rfc4104::PCELS_DESTINATION_SAP_VARIABLE_AUX_CLASS, - "pcelsDestinationSAPVariableAuxClass", - ), - ( - &rfc4104::PCELS_SNAPOUI_VARIABLE_AUX_CLASS, - "pcelsSNAPOUIVariableAuxClass", - ), - ( - &rfc4104::PCELS_SNAP_TYPE_VARIABLE_AUX_CLASS, - "pcelsSNAPTypeVariableAuxClass", - ), - ( - &rfc4104::PCELS_FLOW_DIRECTION_VARIABLE_AUX_CLASS, - "pcelsFlowDirectionVariableAuxClass", - ), - (&rfc4104::PCELS_GROUP_AUX_CLASS, "pcelsGroupAuxClass"), - (&rfc4104::PCELS_VALUE_AUX_CLASS, "pcelsValueAuxClass"), - ( - &rfc4104::PCELS_I_PV_4_ADDR_VALUE_AUX_CLASS, - "pcelsIPv4AddrValueAuxClass", - ), - ( - &rfc4104::PCELS_I_PV_6_ADDR_VALUE_AUX_CLASS, - "pcelsIPv6AddrValueAuxClass", - ), - ( - &rfc4104::PCELS_MAC_ADDR_VALUE_AUX_CLASS, - "pcelsMACAddrValueAuxClass", - ), - ( - &rfc4104::PCELS_STRING_VALUE_AUX_CLASS, - "pcelsStringValueAuxClass", - ), - ( - &rfc4104::PCELS_BIT_STRING_VALUE_AUX_CLASS, - "pcelsBitStringValueAuxClass", - ), - ( - &rfc4104::PCELS_INTEGER_VALUE_AUX_CLASS, - "pcelsIntegerValueAuxClass", - ), - ( - &rfc4104::PCELS_BOOLEAN_VALUE_AUX_CLASS, - "pcelsBooleanValueAuxClass", - ), - (&rfc4104::PCELS_REUSABLE_CONTAINER, "pcelsReusableContainer"), - ( - &rfc4104::PCELS_REUSABLE_CONTAINER_AUX_CLASS, - "pcelsReusableContainerAuxClass", - ), - (&rfc4104::PCELS_GROUP_INSTANCE, "pcelsGroupInstance"), - ( - &rfc4104::PCELS_REUSABLE_CONTAINER_INSTANCE, - "pcelsReusableContainerInstance", - ), - (&rfc4104::PCELS_ROLE_COLLECTION, "pcelsRoleCollection"), - (&rfc4104::PCELS_FILTER_ENTRY_BASE, "pcelsFilterEntryBase"), - (&rfc4104::PCELS_IP_HEADERS_FILTER, "pcelsIPHeadersFilter"), - (&rfc4104::PCELS_8021_FILTER, "pcels8021Filter"), - ( - &rfc4104::PCELS_FILTER_LIST_AUX_CLASS, - "pcelsFilterListAuxClass", - ), - ( - &rfc4104::PCELS_VENDOR_VARIABLE_AUX_CLASS, - "pcelsVendorVariableAuxClass", - ), - ( - &rfc4104::PCELS_VENDOR_VALUE_AUX_CLASS, - "pcelsVendorValueAuxClass", - ), - (&rfc4104::PCELS_RULE, "pcelsRule"), - (&rfc4104::PCELS_RULE_AUX_CLASS, "pcelsRuleAuxClass"), - (&rfc4104::PCELS_RULE_INSTANCE, "pcelsRuleInstance"), - ( - &rfc4104::PCELS_CONDITION_ASSOCIATION, - "pcelsConditionAssociation", - ), - (&rfc4104::PCELS_POLICY_SET_NAME, "pcelsPolicySetName"), - (&rfc4104::PCELS_EXECUTION_STRATEGY, "pcelsExecutionStrategy"), - (&rfc4104::PCELS_VARIABLE_DN, "pcelsVariableDN"), - (&rfc4104::PCELS_VALUE_DN, "pcelsValueDN"), - (&rfc4104::PCELS_IS_MIRRORED, "pcelsIsMirrored"), - (&rfc4104::PCELS_VARIABLE_NAME, "pcelsVariableName"), - ( - &rfc4104::PCELS_EXPECTED_VALUE_LIST, - "pcelsExpectedValueList", - ), - ( - &rfc4104::PCELS_VARIABLE_MODEL_CLASS, - "pcelsVariableModelClass", - ), - ( - &rfc4104::PCELS_VARIABLE_MODEL_PROPERTY, - "pcelsVariableModelProperty", - ), - ( - &rfc4104::PCELS_EXPECTED_VALUE_TYPES, - "pcelsExpectedValueTypes", - ), - (&rfc4104::PCELS_VALUE_NAME, "pcelsValueName"), - (&rfc4104::PCELS_DECISION_STRATEGY, "pcelsDecisionStrategy"), - (&rfc4104::PCELS_I_PV_4_ADDR_LIST, "pcelsIPv4AddrList"), - (&rfc4104::PCELS_I_PV_6_ADDR_LIST, "pcelsIPv6AddrList"), - (&rfc4104::PCELS_MAC_ADDR_LIST, "pcelsMACAddrList"), - (&rfc4104::PCELS_STRING_LIST, "pcelsStringList"), - (&rfc4104::PCELS_BIT_STRING_LIST, "pcelsBitStringList"), - (&rfc4104::PCELS_INTEGER_LIST, "pcelsIntegerList"), - (&rfc4104::PCELS_BOOLEAN, "pcelsBoolean"), - ( - &rfc4104::PCELS_REUSABLE_CONTAINER_NAME, - "pcelsReusableContainerName", - ), - ( - &rfc4104::PCELS_REUSABLE_CONTAINER_LIST, - "pcelsReusableContainerList", - ), - (&rfc4104::PCELS_ROLE, "pcelsRole"), - (&rfc4104::PCELS_POLICY_SET_LIST, "pcelsPolicySetList"), - ( - &rfc4104::PCELS_ROLE_COLLECTION_NAME, - "pcelsRoleCollectionName", - ), - (&rfc4104::PCELS_ELEMENT_LIST, "pcelsElementList"), - (&rfc4104::PCELS_FILTER_NAME, "pcelsFilterName"), - (&rfc4104::PCELS_FILTER_IS_NEGATED, "pcelsFilterIsNegated"), - (&rfc4104::PCELS_IP_HDR_VERSION, "pcelsIPHdrVersion"), - ( - &rfc4104::PCELS_IP_HDR_SOURCE_ADDRESS, - "pcelsIPHdrSourceAddress", - ), - ( - &rfc4104::PCELS_IP_HDR_SOURCE_ADDRESS_END_OF_RANGE, - "pcelsIPHdrSourceAddressEndOfRange", - ), - (&rfc4104::PCELS_IP_HDR_SOURCE_MASK, "pcelsIPHdrSourceMask"), - (&rfc4104::PCELS_IP_HDR_DEST_ADDRESS, "pcelsIPHdrDestAddress"), - ( - &rfc4104::PCELS_IP_HDR_DEST_ADDRESS_END_OF_RANGE, - "pcelsIPHdrDestAddressEndOfRange", - ), - (&rfc4104::PCELS_PRIORITY, "pcelsPriority"), - (&rfc4104::PCELS_IP_HDR_DEST_MASK, "pcelsIPHdrDestMask"), - (&rfc4104::PCELS_IP_HDR_PROTOCOL_ID, "pcelsIPHdrProtocolID"), - ( - &rfc4104::PCELS_IP_HDR_SOURCE_PORT_START, - "pcelsIPHdrSourcePortStart", - ), - ( - &rfc4104::PCELS_IP_HDR_SOURCE_PORT_END, - "pcelsIPHdrSourcePortEnd", - ), - ( - &rfc4104::PCELS_IP_HDR_DEST_PORT_START, - "pcelsIPHdrDestPortStart", - ), - ( - &rfc4104::PCELS_IP_HDR_DEST_PORT_END, - "pcelsIPHdrDestPortEnd", - ), - (&rfc4104::PCELS_IP_HDR_DSCP_LIST, "pcelsIPHdrDSCPList"), - (&rfc4104::PCELS_IP_HDR_FLOW_LABEL, "pcelsIPHdrFlowLabel"), - ( - &rfc4104::PCELS_8021_HDR_SOURCE_MAC_ADDRESS, - "pcels8021HdrSourceMACAddress", - ), - ( - &rfc4104::PCELS_8021_HDR_SOURCE_MAC_MASK, - "pcels8021HdrSourceMACMask", - ), - (&rfc4104::PCELS_POLICY_SET_DN, "pcelsPolicySetDN"), - ( - &rfc4104::PCELS_8021_HDR_DEST_MAC_ADDRESS, - "pcels8021HdrDestMACAddress", - ), - ( - &rfc4104::PCELS_8021_HDR_DEST_MAC_MASK, - "pcels8021HdrDestMACMask", - ), - ( - &rfc4104::PCELS_8021_HDR_PROTOCOL_ID, - "pcels8021HdrProtocolID", - ), - (&rfc4104::PCELS_8021_HDR_PRIORITY, "pcels8021HdrPriority"), - (&rfc4104::PCELS_8021_HDR_VLANID, "pcels8021HdrVLANID"), - (&rfc4104::PCELS_FILTER_LIST_NAME, "pcelsFilterListName"), - (&rfc4104::PCELS_FILTER_DIRECTION, "pcelsFilterDirection"), - (&rfc4104::PCELS_FILTER_ENTRY_LIST, "pcelsFilterEntryList"), - ( - &rfc4104::PCELS_VENDOR_VARIABLE_DATA, - "pcelsVendorVariableData", - ), - ( - &rfc4104::PCELS_VENDOR_VARIABLE_ENCODING, - "pcelsVendorVariableEncoding", - ), - ( - &rfc4104::PCELS_CONDITION_LIST_TYPE, - "pcelsConditionListType", - ), - (&rfc4104::PCELS_VENDOR_VALUE_DATA, "pcelsVendorValueData"), - ( - &rfc4104::PCELS_VENDOR_VALUE_ENCODING, - "pcelsVendorValueEncoding", - ), - ( - &rfc4104::PCELS_RULE_VALIDITY_PERIOD_LIST, - "pcelsRuleValidityPeriodList", - ), - (&rfc4104::PCELS_CONDITION_LIST, "pcelsConditionList"), - (&rfc4104::PCELS_ACTION_LIST, "pcelsActionList"), - (&rfc4104::PCELS_SEQUENCED_ACTIONS, "pcelsSequencedActions"), - (&rfc4237::VPIM_USER, "vPIMUser"), - (&rfc4237::VPIM_TELEPHONE_NUMBER, "vPIMTelephoneNumber"), - (&rfc4237::VPIM_SUB_MAILBOXES, "vPIMSubMailboxes"), - (&rfc4237::VPIM_RFC_822_MAILBOX, "vPIMRfc822Mailbox"), - (&rfc4237::VPIM_SPOKEN_NAME, "vPIMSpokenName"), - ( - &rfc4237::VPIM_SUPPORTED_UA_BEHAVIORS, - "vPIMSupportedUABehaviors", - ), - ( - &rfc4237::VPIM_SUPPORTED_AUDIO_MEDIA_TYPES, - "vPIMSupportedAudioMediaTypes", - ), - ( - &rfc4237::VPIM_SUPPORTED_MESSAGE_CONTEXT, - "vPIMSupportedMessageContext", - ), - (&rfc4237::VPIM_TEXT_NAME, "vPIMTextName"), - ( - &rfc4237::VPIM_EXTENDED_ABSENCE_STATUS, - "vPIMExtendedAbsenceStatus", - ), - (&rfc4237::VPIM_MAX_MESSAGE_SIZE, "vPIMMaxMessageSize"), - (&rfc4403::UDDIV_3_SERVICE_KEY, "uddiv3ServiceKey"), - ( - &rfc4403::UDDI_BUSINESS_ENTITY_NAME_FORM, - "uddiBusinessEntityNameForm", - ), - ( - &rfc4403::UDDIV_3_ENTITY_OBITUARY_NAME_FORM, - "uddiv3EntityObituaryNameForm", - ), - (&rfc4403::UDDI_CONTACT_NAME_FORM, "uddiContactNameForm"), - (&rfc4403::UDDI_ADDRESS_NAME_FORM, "uddiAddressNameForm"), - ( - &rfc4403::UDDI_BUSINESS_SERVICE_NAME_FORM, - "uddiBusinessServiceNameForm", - ), - ( - &rfc4403::UDDI_BINDING_TEMPLATE_NAME_FORM, - "uddiBindingTemplateNameForm", - ), - ( - &rfc4403::UDDI_T_MODEL_INSTANCE_INFO_NAME_FORM, - "uddiTModelInstanceInfoNameForm", - ), - (&rfc4403::UDDI_T_MODEL_NAME_FORM, "uddiTModelNameForm"), - ( - &rfc4403::UDDI_PUBLISHER_ASSERTION_NAME_FORM, - "uddiPublisherAssertionNameForm", - ), - ( - &rfc4403::UDDIV_3_SUBSCRIPTION_NAME_FORM, - "uddiv3SubscriptionNameForm", - ), - (&rfc4403::UDDI_BUSINESS_KEY, "uddiBusinessKey"), - (&rfc4403::UDDI_E_MAIL, "uddiEMail"), - (&rfc4403::UDDI_SORT_CODE, "uddiSortCode"), - (&rfc4403::UDDI_T_MODEL_KEY, "uddiTModelKey"), - (&rfc4403::UDDI_ADDRESS_LINE, "uddiAddressLine"), - (&rfc4403::UDDI_IDENTIFIER_BAG, "uddiIdentifierBag"), - (&rfc4403::UDDI_CATEGORY_BAG, "uddiCategoryBag"), - (&rfc4403::UDDI_KEYED_REFERENCE, "uddiKeyedReference"), - (&rfc4403::UDDI_SERVICE_KEY, "uddiServiceKey"), - (&rfc4403::UDDI_BINDING_KEY, "uddiBindingKey"), - (&rfc4403::UDDI_ACCESS_POINT, "uddiAccessPoint"), - (&rfc4403::UDDI_AUTHORIZED_NAME, "uddiAuthorizedName"), - (&rfc4403::UDDI_HOSTING_REDIRECTOR, "uddiHostingRedirector"), - ( - &rfc4403::UDDI_INSTANCE_DESCRIPTION, - "uddiInstanceDescription", - ), - (&rfc4403::UDDI_INSTANCE_PARMS, "uddiInstanceParms"), - ( - &rfc4403::UDDI_OVERVIEW_DESCRIPTION, - "uddiOverviewDescription", - ), - (&rfc4403::UDDI_OVERVIEW_URL, "uddiOverviewURL"), - (&rfc4403::UDDI_FROM_KEY, "uddiFromKey"), - (&rfc4403::UDDI_TO_KEY, "uddiToKey"), - (&rfc4403::UDDI_UUID, "uddiUUID"), - (&rfc4403::UDDI_IS_HIDDEN, "uddiIsHidden"), - (&rfc4403::UDDI_IS_PROJECTION, "uddiIsProjection"), - (&rfc4403::UDDI_OPERATOR, "uddiOperator"), - (&rfc4403::UDDI_LANG, "uddiLang"), - (&rfc4403::UDDIV_3_BUSINESS_KEY, "uddiv3BusinessKey"), - (&rfc4403::UDDIV_3_BINDING_KEY, "uddiv3BindingKey"), - (&rfc4403::UDDIV_3_TMODEL_KEY, "uddiv3TmodelKey"), - ( - &rfc4403::UDDIV_3_DIGITAL_SIGNATURE, - "uddiv3DigitalSignature", - ), - (&rfc4403::UDDIV_3_NODE_ID, "uddiv3NodeId"), - ( - &rfc4403::UDDIV_3_ENTITY_MODIFICATION_TIME, - "uddiv3EntityModificationTime", - ), - (&rfc4403::UDDIV_3_SUBSCRIPTION_KEY, "uddiv3SubscriptionKey"), - ( - &rfc4403::UDDIV_3_SUBSCRIPTION_FILTER, - "uddiv3SubscriptionFilter", - ), - (&rfc4403::UDDI_NAME, "uddiName"), - ( - &rfc4403::UDDIV_3_NOTIFICATION_INTERVAL, - "uddiv3NotificationInterval", - ), - (&rfc4403::UDDIV_3_MAX_ENTITIES, "uddiv3MaxEntities"), - (&rfc4403::UDDIV_3_EXPIRES_AFTER, "uddiv3ExpiresAfter"), - (&rfc4403::UDDIV_3_BRIEF_RESPONSE, "uddiv3BriefResponse"), - (&rfc4403::UDDIV_3_ENTITY_KEY, "uddiv3EntityKey"), - ( - &rfc4403::UDDIV_3_ENTITY_CREATION_TIME, - "uddiv3EntityCreationTime", - ), - ( - &rfc4403::UDDIV_3_ENTITY_DELETION_TIME, - "uddiv3EntityDeletionTime", - ), - (&rfc4403::UDDI_DESCRIPTION, "uddiDescription"), - (&rfc4403::UDDI_DISCOVERY_UR_LS, "uddiDiscoveryURLs"), - (&rfc4403::UDDI_USE_TYPE, "uddiUseType"), - (&rfc4403::UDDI_PERSON_NAME, "uddiPersonName"), - (&rfc4403::UDDI_PHONE, "uddiPhone"), - (&rfc4403::UDDI_BUSINESS_ENTITY, "uddiBusinessEntity"), - (&rfc4403::UDDIV_3_ENTITY_OBITUARY, "uddiv3EntityObituary"), - (&rfc4403::UDDI_CONTACT, "uddiContact"), - (&rfc4403::UDDI_ADDRESS, "uddiAddress"), - (&rfc4403::UDDI_BUSINESS_SERVICE, "uddiBusinessService"), - (&rfc4403::UDDI_BINDING_TEMPLATE, "uddiBindingTemplate"), - ( - &rfc4403::UDDI_T_MODEL_INSTANCE_INFO, - "uddiTModelInstanceInfo", - ), - (&rfc4403::UDDI_T_MODEL, "uddiTModel"), - (&rfc4403::UDDI_PUBLISHER_ASSERTION, "uddiPublisherAssertion"), - (&rfc4403::UDDIV_3_SUBSCRIPTION, "uddiv3Subscription"), - (&rfc4512::EXTENSIBLE_OBJECT, "extensibleObject"), - (&rfc4512::SUPPORTED_CONTROL, "supportedControl"), - ( - &rfc4512::SUPPORTED_SASL_MECHANISMS, - "supportedSASLMechanisms", - ), - (&rfc4512::SUPPORTED_LDAP_VERSION, "supportedLDAPVersion"), - (&rfc4512::LDAP_SYNTAXES, "ldapSyntaxes"), - (&rfc4512::NAMING_CONTEXTS, "namingContexts"), - (&rfc4512::ALT_SERVER, "altServer"), - (&rfc4512::SUPPORTED_EXTENSION, "supportedExtension"), - (&rfc4512::SUPPORTED_FEATURES, "supportedFeatures"), - (&rfc4512::CREATE_TIMESTAMP, "createTimestamp"), - (&rfc4512::SUBSCHEMA_SUBENTRY, "subschemaSubentry"), - (&rfc4512::MODIFY_TIMESTAMP, "modifyTimestamp"), - (&rfc4512::CREATORS_NAME, "creatorsName"), - (&rfc4512::MODIFIERS_NAME, "modifiersName"), - (&rfc4512::SUBSCHEMA, "subschema"), - (&rfc4512::DIT_STRUCTURE_RULES, "dITStructureRules"), - (&rfc4512::GOVERNING_STRUCTURE_RULE, "governingStructureRule"), - (&rfc4512::DIT_CONTENT_RULES, "dITContentRules"), - (&rfc4512::MATCHING_RULES, "matchingRules"), - (&rfc4512::ATTRIBUTE_TYPES, "attributeTypes"), - (&rfc4512::OBJECT_CLASSES, "objectClasses"), - (&rfc4512::NAME_FORMS, "nameForms"), - (&rfc4512::MATCHING_RULE_USE, "matchingRuleUse"), - (&rfc4512::STRUCTURAL_OBJECT_CLASS, "structuralObjectClass"), - (&rfc4512::OBJECT_CLASS, "objectClass"), - (&rfc4512::ALIASED_OBJECT_NAME, "aliasedObjectName"), - (&rfc4512::TOP, "top"), - (&rfc4512::ALIAS, "alias"), - (&rfc4517::CASE_EXACT_IA_5_MATCH, "caseExactIA5Match"), - (&rfc4517::CASE_IGNORE_IA_5_MATCH, "caseIgnoreIA5Match"), - ( - &rfc4517::CASE_IGNORE_IA_5_SUBSTRINGS_MATCH, - "caseIgnoreIA5SubstringsMatch", - ), - (&rfc4517::OBJECT_IDENTIFIER_MATCH, "objectIdentifierMatch"), - (&rfc4517::DISTINGUISHED_NAME_MATCH, "distinguishedNameMatch"), - ( - &rfc4517::NUMERIC_STRING_SUBSTRINGS_MATCH, - "numericStringSubstringsMatch", - ), - (&rfc4517::CASE_IGNORE_LIST_MATCH, "caseIgnoreListMatch"), - ( - &rfc4517::CASE_IGNORE_LIST_SUBSTRINGS_MATCH, - "caseIgnoreListSubstringsMatch", - ), - (&rfc4517::BOOLEAN_MATCH, "booleanMatch"), - (&rfc4517::INTEGER_MATCH, "integerMatch"), - (&rfc4517::INTEGER_ORDERING_MATCH, "integerOrderingMatch"), - (&rfc4517::BIT_STRING_MATCH, "bitStringMatch"), - (&rfc4517::OCTET_STRING_MATCH, "octetStringMatch"), - ( - &rfc4517::OCTET_STRING_ORDERING_MATCH, - "octetStringOrderingMatch", - ), - (&rfc4517::CASE_IGNORE_MATCH, "caseIgnoreMatch"), - (&rfc4517::TELEPHONE_NUMBER_MATCH, "telephoneNumberMatch"), - ( - &rfc4517::TELEPHONE_NUMBER_SUBSTRINGS_MATCH, - "telephoneNumberSubstringsMatch", - ), - (&rfc4517::UNIQUE_MEMBER_MATCH, "uniqueMemberMatch"), - (&rfc4517::GENERALIZED_TIME_MATCH, "generalizedTimeMatch"), - ( - &rfc4517::GENERALIZED_TIME_ORDERING_MATCH, - "generalizedTimeOrderingMatch", - ), - ( - &rfc4517::INTEGER_FIRST_COMPONENT_MATCH, - "integerFirstComponentMatch", - ), - ( - &rfc4517::CASE_IGNORE_ORDERING_MATCH, - "caseIgnoreOrderingMatch", - ), - ( - &rfc4517::OBJECT_IDENTIFIER_FIRST_COMPONENT_MATCH, - "objectIdentifierFirstComponentMatch", - ), - ( - &rfc4517::DIRECTORY_STRING_FIRST_COMPONENT_MATCH, - "directoryStringFirstComponentMatch", - ), - (&rfc4517::WORD_MATCH, "wordMatch"), - (&rfc4517::KEYWORD_MATCH, "keywordMatch"), - ( - &rfc4517::CASE_IGNORE_SUBSTRINGS_MATCH, - "caseIgnoreSubstringsMatch", - ), - (&rfc4517::CASE_EXACT_MATCH, "caseExactMatch"), - ( - &rfc4517::CASE_EXACT_ORDERING_MATCH, - "caseExactOrderingMatch", - ), - ( - &rfc4517::CASE_EXACT_SUBSTRINGS_MATCH, - "caseExactSubstringsMatch", - ), - (&rfc4517::NUMERIC_STRING_MATCH, "numericStringMatch"), - ( - &rfc4517::NUMERIC_STRING_ORDERING_MATCH, - "numericStringOrderingMatch", - ), - (&rfc4519::UID, "uid"), - (&rfc4519::USER_ID, "userId"), - (&rfc4519::DC, "DC"), - (&rfc4519::DOMAIN_COMPONENT, "domainComponent"), - (&rfc4519::UID_OBJECT, "uidObject"), - (&rfc4519::DC_OBJECT, "dcObject"), - (&rfc4519::O, "o"), - (&rfc4519::ORGANIZATION_NAME, "organizationName"), - (&rfc4519::OU, "ou"), - (&rfc4519::ORGANIZATIONAL_UNIT_NAME, "organizationalUnitName"), - (&rfc4519::TITLE, "title"), - (&rfc4519::DESCRIPTION, "description"), - (&rfc4519::SEARCH_GUIDE, "searchGuide"), - (&rfc4519::BUSINESS_CATEGORY, "businessCategory"), - (&rfc4519::POSTAL_ADDRESS, "postalAddress"), - (&rfc4519::POSTAL_CODE, "postalCode"), - (&rfc4519::POST_OFFICE_BOX, "postOfficeBox"), - ( - &rfc4519::PHYSICAL_DELIVERY_OFFICE_NAME, - "physicalDeliveryOfficeName", - ), - (&rfc4519::TELEPHONE_NUMBER, "telephoneNumber"), - (&rfc4519::TELEX_NUMBER, "telexNumber"), - ( - &rfc4519::TELETEX_TERMINAL_IDENTIFIER, - "teletexTerminalIdentifier", - ), - ( - &rfc4519::FACSIMILE_TELEPHONE_NUMBER, - "facsimileTelephoneNumber", - ), - (&rfc4519::X_121_ADDRESS, "x121Address"), - ( - &rfc4519::INTERNATIONALI_SDN_NUMBER, - "internationaliSDNNumber", - ), - (&rfc4519::REGISTERED_ADDRESS, "registeredAddress"), - (&rfc4519::DESTINATION_INDICATOR, "destinationIndicator"), - ( - &rfc4519::PREFERRED_DELIVERY_METHOD, - "preferredDeliveryMethod", - ), - (&rfc4519::CN, "cn"), - (&rfc4519::COMMON_NAME, "commonName"), - (&rfc4519::MEMBER, "member"), - (&rfc4519::OWNER, "owner"), - (&rfc4519::ROLE_OCCUPANT, "roleOccupant"), - (&rfc4519::SEE_ALSO, "seeAlso"), - (&rfc4519::USER_PASSWORD, "userPassword"), - (&rfc4519::SN, "sn"), - (&rfc4519::SURNAME, "surname"), - (&rfc4519::NAME, "name"), - (&rfc4519::GIVEN_NAME, "givenName"), - (&rfc4519::INITIALS, "initials"), - (&rfc4519::GENERATION_QUALIFIER, "generationQualifier"), - (&rfc4519::X_500_UNIQUE_IDENTIFIER, "x500UniqueIdentifier"), - (&rfc4519::DN_QUALIFIER, "dnQualifier"), - (&rfc4519::ENHANCED_SEARCH_GUIDE, "enhancedSearchGuide"), - (&rfc4519::DISTINGUISHED_NAME, "distinguishedName"), - (&rfc4519::SERIAL_NUMBER, "serialNumber"), - (&rfc4519::UNIQUE_MEMBER, "uniqueMember"), - (&rfc4519::HOUSE_IDENTIFIER, "houseIdentifier"), - (&rfc4519::C, "c"), - (&rfc4519::COUNTRY_NAME, "countryName"), - (&rfc4519::L, "L"), - (&rfc4519::LOCALITY_NAME, "localityName"), - (&rfc4519::ST, "st"), - (&rfc4519::STREET, "street"), - (&rfc4519::RESIDENTIAL_PERSON, "residentialPerson"), - (&rfc4519::APPLICATION_PROCESS, "applicationProcess"), - (&rfc4519::DEVICE, "device"), - (&rfc4519::GROUP_OF_UNIQUE_NAMES, "groupOfUniqueNames"), - (&rfc4519::COUNTRY, "country"), - (&rfc4519::LOCALITY, "locality"), - (&rfc4519::ORGANIZATION, "organization"), - (&rfc4519::ORGANIZATIONAL_UNIT, "organizationalUnit"), - (&rfc4519::PERSON, "person"), - (&rfc4519::ORGANIZATIONAL_PERSON, "organizationalPerson"), - (&rfc4519::ORGANIZATIONAL_ROLE, "organizationalRole"), - (&rfc4519::GROUP_OF_NAMES, "groupOfNames"), - (&rfc4523::CERTIFICATE_EXACT_MATCH, "certificateExactMatch"), - (&rfc4523::CERTIFICATE_MATCH, "certificateMatch"), - ( - &rfc4523::CERTIFICATE_PAIR_EXACT_MATCH, - "certificatePairExactMatch", - ), - (&rfc4523::CERTIFICATE_PAIR_MATCH, "certificatePairMatch"), - ( - &rfc4523::CERTIFICATE_LIST_EXACT_MATCH, - "certificateListExactMatch", - ), - (&rfc4523::CERTIFICATE_LIST_MATCH, "certificateListMatch"), - ( - &rfc4523::ALGORITHM_IDENTIFIER_MATCH, - "algorithmIdentifierMatch", - ), - (&rfc4523::USER_CERTIFICATE, "userCertificate"), - (&rfc4523::CA_CERTIFICATE, "cACertificate"), - ( - &rfc4523::AUTHORITY_REVOCATION_LIST, - "authorityRevocationList", - ), - ( - &rfc4523::CERTIFICATE_REVOCATION_LIST, - "certificateRevocationList", - ), - (&rfc4523::CROSS_CERTIFICATE_PAIR, "crossCertificatePair"), - (&rfc4523::SUPPORTED_ALGORITHMS, "supportedAlgorithms"), - (&rfc4523::DELTA_REVOCATION_LIST, "deltaRevocationList"), - ( - &rfc4523::STRONG_AUTHENTICATION_USER, - "strongAuthenticationUser", - ), - (&rfc4523::CERTIFICATION_AUTHORITY, "certificationAuthority"), - ( - &rfc4523::CERTIFICATION_AUTHORITY_V_2, - "certificationAuthority-V2", - ), - ( - &rfc4523::USER_SECURITY_INFORMATION, - "userSecurityInformation", - ), - (&rfc4523::CRL_DISTRIBUTION_POINT, "cRLDistributionPoint"), - (&rfc4523::PKI_USER, "pkiUser"), - (&rfc4523::PKI_CA, "pkiCA"), - (&rfc4523::DELTA_CRL, "deltaCRL"), - (&rfc4524::MANAGER, "manager"), - (&rfc4524::DOCUMENT_IDENTIFIER, "documentIdentifier"), - (&rfc4524::DOCUMENT_TITLE, "documentTitle"), - (&rfc4524::DOCUMENT_VERSION, "documentVersion"), - (&rfc4524::DOCUMENT_AUTHOR, "documentAuthor"), - (&rfc4524::DOCUMENT_LOCATION, "documentLocation"), - (&rfc4524::HOME_PHONE, "homePhone"), - (&rfc4524::HOME_TELEPHONE, "homeTelephone"), - (&rfc4524::SECRETARY, "secretary"), - (&rfc4524::MAIL, "mail"), - (&rfc4524::RFC_822_MAILBOX, "RFC822Mailbox"), - (&rfc4524::ASSOCIATED_DOMAIN, "associatedDomain"), - (&rfc4524::ASSOCIATED_NAME, "associatedName"), - (&rfc4524::HOME_POSTAL_ADDRESS, "homePostalAddress"), - (&rfc4524::INFO, "info"), - (&rfc4524::PERSONAL_TITLE, "personalTitle"), - (&rfc4524::MOBILE, "mobile"), - (&rfc4524::MOBILE_TELEPHONE_NUMBER, "mobileTelephoneNumber"), - (&rfc4524::PAGER, "pager"), - (&rfc4524::PAGER_TELEPHONE_NUMBER, "pagerTelephoneNumber"), - (&rfc4524::CO, "co"), - (&rfc4524::FRIENDLY_COUNTRY_NAME, "friendlyCountryName"), - (&rfc4524::UNIQUE_IDENTIFIER, "uniqueIdentifier"), - (&rfc4524::ORGANIZATIONAL_STATUS, "organizationalStatus"), - (&rfc4524::BUILDING_NAME, "buildingName"), - (&rfc4524::DRINK, "drink"), - (&rfc4524::FAVOURITE_DRINK, "favouriteDrink"), - (&rfc4524::SINGLE_LEVEL_QUALITY, "singleLevelQuality"), - (&rfc4524::DOCUMENT_PUBLISHER, "documentPublisher"), - (&rfc4524::ROOM_NUMBER, "roomNumber"), - (&rfc4524::USER_CLASS, "userClass"), - (&rfc4524::HOST, "host"), - (&rfc4524::DOMAIN, "domain"), - (&rfc4524::RFC_822_LOCAL_PART, "RFC822LocalPart"), - (&rfc4524::DOMAIN_RELATED_OBJECT, "domainRelatedObject"), - (&rfc4524::FRIENDLY_COUNTRY, "friendlyCountry"), - (&rfc4524::SIMPLE_SECURITY_OBJECT, "simpleSecurityObject"), - (&rfc4524::ACCOUNT, "account"), - (&rfc4524::DOCUMENT, "document"), - (&rfc4524::ROOM, "room"), - (&rfc4524::DOCUMENT_SERIES, "documentSeries"), - (&rfc4530::UUID_MATCH, "uuidMatch"), - (&rfc4530::UUID_ORDERING_MATCH, "uuidOrderingMatch"), - (&rfc4530::ENTRY_UUID, "entryUUID"), - (&rfc4876::DEFAULT_SERVER_LIST, "defaultServerList"), - (&rfc4876::DEFAULT_SEARCH_BASE, "defaultSearchBase"), - (&rfc4876::CREDENTIAL_LEVEL, "credentialLevel"), - (&rfc4876::OBJECTCLASS_MAP, "objectclassMap"), - (&rfc4876::DEFAULT_SEARCH_SCOPE, "defaultSearchScope"), - (&rfc4876::SERVICE_CREDENTIAL_LEVEL, "serviceCredentialLevel"), - ( - &rfc4876::SERVICE_SEARCH_DESCRIPTOR, - "serviceSearchDescriptor", - ), - ( - &rfc4876::SERVICE_AUTHENTICATION_METHOD, - "serviceAuthenticationMethod", - ), - (&rfc4876::DEREFERENCE_ALIASES, "dereferenceAliases"), - (&rfc4876::PREFERRED_SERVER_LIST, "preferredServerList"), - (&rfc4876::SEARCH_TIME_LIMIT, "searchTimeLimit"), - (&rfc4876::BIND_TIME_LIMIT, "bindTimeLimit"), - (&rfc4876::FOLLOW_REFERRALS, "followReferrals"), - (&rfc4876::AUTHENTICATION_METHOD, "authenticationMethod"), - (&rfc4876::PROFILE_TTL, "profileTTL"), - (&rfc4876::ATTRIBUTE_MAP, "attributeMap"), - (&rfc4876::DUA_CONFIG_PROFILE, "DUAConfigProfile"), - (&rfc5020::ENTRY_DN, "entryDN"), - (&rfc5280::PKCS_9, "pkcs-9"), - (&rfc5280::ID_PKIX, "id-pkix"), - (&rfc5280::ID_PE, "id-pe"), - ( - &rfc5280::ID_PE_AUTHORITY_INFO_ACCESS, - "id-pe-authorityInfoAccess", - ), - ( - &rfc5280::ID_PE_SUBJECT_INFO_ACCESS, - "id-pe-subjectInfoAccess", - ), - (&rfc5280::ID_QT, "id-qt"), - (&rfc5280::ID_QT_CPS, "id-qt-cps"), - (&rfc5280::ID_QT_UNOTICE, "id-qt-unotice"), - (&rfc5280::ID_KP, "id-kp"), - (&rfc5280::ID_KP_SERVER_AUTH, "id-kp-serverAuth"), - (&rfc5280::ID_KP_CLIENT_AUTH, "id-kp-clientAuth"), - (&rfc5280::ID_KP_CODE_SIGNING, "id-kp-codeSigning"), - (&rfc5280::ID_KP_EMAIL_PROTECTION, "id-kp-emailProtection"), - (&rfc5280::ID_KP_TIME_STAMPING, "id-kp-timeStamping"), - (&rfc5280::ID_KP_OCSP_SIGNING, "id-kp-OCSPSigning"), - (&rfc5280::ID_AD, "id-ad"), - (&rfc5280::ID_AD_OCSP, "id-ad-ocsp"), - (&rfc5280::ID_AD_CA_ISSUERS, "id-ad-caIssuers"), - (&rfc5280::ID_AD_TIME_STAMPING, "id-ad-timeStamping"), - (&rfc5280::ID_AD_CA_REPOSITORY, "id-ad-caRepository"), - (&rfc5280::HOLD_INSTRUCTION, "holdInstruction"), - (&rfc5280::ID_HOLDINSTRUCTION_NONE, "id-holdinstruction-none"), - ( - &rfc5280::ID_HOLDINSTRUCTION_CALLISSUER, - "id-holdinstruction-callissuer", - ), - ( - &rfc5280::ID_HOLDINSTRUCTION_REJECT, - "id-holdinstruction-reject", - ), - (&rfc5280::ID_CE, "id-ce"), - ( - &rfc5280::ID_CE_SUBJECT_KEY_IDENTIFIER, - "id-ce-subjectKeyIdentifier", - ), - (&rfc5280::ID_CE_KEY_USAGE, "id-ce-keyUsage"), - ( - &rfc5280::ID_CE_PRIVATE_KEY_USAGE_PERIOD, - "id-ce-privateKeyUsagePeriod", - ), - (&rfc5280::ID_CE_SUBJECT_ALT_NAME, "id-ce-subjectAltName"), - (&rfc5280::ID_CE_ISSUER_ALT_NAME, "id-ce-issuerAltName"), - (&rfc5280::ID_CE_BASIC_CONSTRAINTS, "id-ce-basicConstraints"), - (&rfc5280::ID_CE_CRL_NUMBER, "id-ce-cRLNumber"), - (&rfc5280::ID_CE_CRL_REASONS, "id-ce-cRLReasons"), - ( - &rfc5280::ID_CE_HOLD_INSTRUCTION_CODE, - "id-ce-holdInstructionCode", - ), - (&rfc5280::ID_CE_INVALIDITY_DATE, "id-ce-invalidityDate"), - ( - &rfc5280::ID_CE_DELTA_CRL_INDICATOR, - "id-ce-deltaCRLIndicator", - ), - ( - &rfc5280::ID_CE_ISSUING_DISTRIBUTION_POINT, - "id-ce-issuingDistributionPoint", - ), - ( - &rfc5280::ID_CE_CERTIFICATE_ISSUER, - "id-ce-certificateIssuer", - ), - (&rfc5280::ID_CE_NAME_CONSTRAINTS, "id-ce-nameConstraints"), - ( - &rfc5280::ID_CE_CRL_DISTRIBUTION_POINTS, - "id-ce-cRLDistributionPoints", - ), - ( - &rfc5280::ID_CE_CERTIFICATE_POLICIES, - "id-ce-certificatePolicies", - ), - (&rfc5280::ANY_POLICY, "anyPolicy"), - (&rfc5280::ID_CE_POLICY_MAPPINGS, "id-ce-policyMappings"), - ( - &rfc5280::ID_CE_AUTHORITY_KEY_IDENTIFIER, - "id-ce-authorityKeyIdentifier", - ), - ( - &rfc5280::ID_CE_POLICY_CONSTRAINTS, - "id-ce-policyConstraints", - ), - (&rfc5280::ID_CE_EXT_KEY_USAGE, "id-ce-extKeyUsage"), - (&rfc5280::ANY_EXTENDED_KEY_USAGE, "anyExtendedKeyUsage"), - (&rfc5280::ID_CE_FRESHEST_CRL, "id-ce-freshestCRL"), - (&rfc5280::ID_CE_INHIBIT_ANY_POLICY, "id-ce-inhibitAnyPolicy"), - ( - &rfc5280::ID_CE_SUBJECT_DIRECTORY_ATTRIBUTES, - "id-ce-subjectDirectoryAttributes", - ), - (&rfc5280::ID_AT, "id-at"), - (&rfc5911::ID_PBKDF_2, "id-PBKDF2"), - (&rfc5911::ID_DATA, "id-data"), - (&rfc5911::ID_SIGNED_DATA, "id-signedData"), - (&rfc5911::ID_ENVELOPED_DATA, "id-envelopedData"), - (&rfc5911::ID_DIGESTED_DATA, "id-digestedData"), - (&rfc5911::ID_ENCRYPTED_DATA, "id-encryptedData"), - (&rfc5911::SMIME_CAPABILITIES, "smimeCapabilities"), - (&rfc5911::ID_SMIME, "id-smime"), - (&rfc5911::ID_CT_RECEIPT, "id-ct-receipt"), - (&rfc5911::ID_CT_FIRMWARE_PACKAGE, "id-ct-firmwarePackage"), - ( - &rfc5911::ID_CT_FIRMWARE_LOAD_RECEIPT, - "id-ct-firmwareLoadReceipt", - ), - ( - &rfc5911::ID_CT_FIRMWARE_LOAD_ERROR, - "id-ct-firmwareLoadError", - ), - (&rfc5911::ID_CT_AUTH_DATA, "id-ct-authData"), - ( - &rfc5911::ID_CT_AUTH_ENVELOPED_DATA, - "id-ct-authEnvelopedData", - ), - (&rfc5911::ID_CT_CONTENT_INFO, "id-ct-contentInfo"), - (&rfc5911::ID_CAP, "id-cap"), - ( - &rfc5911::ID_CAP_PREFER_BINARY_INSIDE, - "id-cap-preferBinaryInside", - ), - (&rfc5911::ID_AA, "id-aa"), - (&rfc5911::ID_AA_RECEIPT_REQUEST, "id-aa-receiptRequest"), - (&rfc5911::ID_AA_CONTENT_REFERENCE, "id-aa-contentReference"), - (&rfc5911::ID_AA_ENCRYP_KEY_PREF, "id-aa-encrypKeyPref"), - ( - &rfc5911::ID_AA_SIGNING_CERTIFICATE, - "id-aa-signingCertificate", - ), - (&rfc5911::ID_AA_SECURITY_LABEL, "id-aa-securityLabel"), - (&rfc5911::ID_AA_ML_EXPAND_HISTORY, "id-aa-mlExpandHistory"), - ( - &rfc5911::ID_AA_FIRMWARE_PACKAGE_ID, - "id-aa-firmwarePackageID", - ), - ( - &rfc5911::ID_AA_TARGET_HARDWARE_I_DS, - "id-aa-targetHardwareIDs", - ), - (&rfc5911::ID_AA_DECRYPT_KEY_ID, "id-aa-decryptKeyID"), - (&rfc5911::ID_AA_IMPL_CRYPTO_ALGS, "id-aa-implCryptoAlgs"), - ( - &rfc5911::ID_AA_WRAPPED_FIRMWARE_KEY, - "id-aa-wrappedFirmwareKey", - ), - (&rfc5911::ID_AA_CONTENT_HINT, "id-aa-contentHint"), - ( - &rfc5911::ID_AA_COMMUNITY_IDENTIFIERS, - "id-aa-communityIdentifiers", - ), - ( - &rfc5911::ID_AA_FIRMWARE_PACKAGE_INFO, - "id-aa-firmwarePackageInfo", - ), - (&rfc5911::ID_AA_IMPL_COMPRESS_ALGS, "id-aa-implCompressAlgs"), - ( - &rfc5911::ID_AA_SIGNING_CERTIFICATE_V_2, - "id-aa-signingCertificateV2", - ), - (&rfc5911::ID_AA_ER_INTERNAL, "id-aa-er-internal"), - (&rfc5911::ID_AA_MSG_SIG_DIGEST, "id-aa-msgSigDigest"), - (&rfc5911::ID_AA_ER_EXTERNAL, "id-aa-er-external"), - ( - &rfc5911::ID_AA_CONTENT_IDENTIFIER, - "id-aa-contentIdentifier", - ), - (&rfc5911::ID_AA_EQUIVALENT_LABELS, "id-aa-equivalentLabels"), - (&rfc5911::ID_ALG_SSDH, "id-alg-SSDH"), - (&rfc5911::ID_ALG_ESDH, "id-alg-ESDH"), - (&rfc5911::ID_ALG_CMS_3_DE_SWRAP, "id-alg-CMS3DESwrap"), - (&rfc5911::ID_ALG_CMSRC_2_WRAP, "id-alg-CMSRC2wrap"), - (&rfc5911::ID_SKD, "id-skd"), - (&rfc5911::ID_SKD_GL_USE_KEK, "id-skd-glUseKEK"), - (&rfc5911::ID_SKD_GLA_QUERY_REQUEST, "id-skd-glaQueryRequest"), - ( - &rfc5911::ID_SKD_GLA_QUERY_RESPONSE, - "id-skd-glaQueryResponse", - ), - (&rfc5911::ID_SKD_GL_PROVIDE_CERT, "id-skd-glProvideCert"), - (&rfc5911::ID_SKD_GL_MANAGE_CERT, "id-skd-glManageCert"), - (&rfc5911::ID_SKD_GL_KEY, "id-skd-glKey"), - (&rfc5911::ID_SKD_GL_DELETE, "id-skd-glDelete"), - (&rfc5911::ID_SKD_GL_ADD_MEMBER, "id-skd-glAddMember"), - (&rfc5911::ID_SKD_GL_DELETE_MEMBER, "id-skd-glDeleteMember"), - (&rfc5911::ID_SKD_GL_REKEY, "id-skd-glRekey"), - (&rfc5911::ID_SKD_GL_ADD_OWNER, "id-skd-glAddOwner"), - (&rfc5911::ID_SKD_GL_REMOVE_OWNER, "id-skd-glRemoveOwner"), - (&rfc5911::ID_SKD_GL_KEY_COMPROMISE, "id-skd-glKeyCompromise"), - (&rfc5911::ID_SKD_GLK_REFRESH, "id-skd-glkRefresh"), - (&rfc5911::ID_CONTENT_TYPE, "id-contentType"), - (&rfc5911::ID_MESSAGE_DIGEST, "id-messageDigest"), - (&rfc5911::ID_SIGNING_TIME, "id-signingTime"), - (&rfc5911::ID_COUNTERSIGNATURE, "id-countersignature"), - (&rfc5911::RC_2_CBC, "rc2-cbc"), - (&rfc5911::DES_EDE_3_CBC, "des-ede3-cbc"), - (&rfc5911::LTANS, "ltans"), - (&rfc5911::ID_CET_SKD_FAIL_INFO, "id-cet-skdFailInfo"), - (&rfc5911::ID_CMC_GLA_RR, "id-cmc-glaRR"), - ( - &rfc5911::ID_CMC_GLA_SKD_ALG_REQUEST, - "id-cmc-gla-skdAlgRequest", - ), - ( - &rfc5911::ID_CMC_GLA_SKD_ALG_RESPONSE, - "id-cmc-gla-skdAlgResponse", - ), - ( - &rfc5911::ID_ON_HARDWARE_MODULE_NAME, - "id-on-hardwareModuleName", - ), - (&rfc5911::HMAC_SHA_1, "hMAC-SHA1"), - (&rfc5911::AES, "aes"), - (&rfc5911::ID_AES_128_CBC, "id-aes128-CBC"), - (&rfc5911::ID_AES_192_CBC, "id-aes192-CBC"), - (&rfc5911::ID_AES_192_WRAP, "id-aes192-wrap"), - (&rfc5911::ID_AES_192_GCM, "id-aes192-GCM"), - (&rfc5911::ID_AES_192_CCM, "id-aes192-CCM"), - (&rfc5911::ID_AES_256_CBC, "id-aes256-CBC"), - (&rfc5911::ID_AES_256_WRAP, "id-aes256-wrap"), - (&rfc5911::ID_AES_256_GCM, "id-aes256-GCM"), - (&rfc5911::ID_AES_256_CCM, "id-aes256-CCM"), - (&rfc5911::ID_AES_128_WRAP, "id-aes128-wrap"), - (&rfc5911::ID_AES_128_GCM, "id-aes128-GCM"), - (&rfc5911::ID_AES_128_CCM, "id-aes128-CCM"), - (&rfc5912::ID_DSA, "id-dsa"), - (&rfc5912::DSA_WITH_SHA_1, "dsa-with-sha1"), - (&rfc5912::ID_EC_PUBLIC_KEY, "id-ecPublicKey"), - (&rfc5912::SECP_256_R_1, "secp256r1"), - (&rfc5912::ECDSA_WITH_SHA_224, "ecdsa-with-SHA224"), - (&rfc5912::ECDSA_WITH_SHA_256, "ecdsa-with-SHA256"), - (&rfc5912::ECDSA_WITH_SHA_384, "ecdsa-with-SHA384"), - (&rfc5912::ECDSA_WITH_SHA_512, "ecdsa-with-SHA512"), - (&rfc5912::DHPUBLICNUMBER, "dhpublicnumber"), - (&rfc5912::ID_PASSWORD_BASED_MAC, "id-PasswordBasedMac"), - (&rfc5912::ID_DH_BASED_MAC, "id-DHBasedMac"), - (&rfc5912::PKCS_1, "pkcs-1"), - (&rfc5912::RSA_ENCRYPTION, "rsaEncryption"), - (&rfc5912::ID_RSASSA_PSS, "id-RSASSA-PSS"), - ( - &rfc5912::SHA_256_WITH_RSA_ENCRYPTION, - "sha256WithRSAEncryption", - ), - ( - &rfc5912::SHA_384_WITH_RSA_ENCRYPTION, - "sha384WithRSAEncryption", - ), - ( - &rfc5912::SHA_512_WITH_RSA_ENCRYPTION, - "sha512WithRSAEncryption", - ), - ( - &rfc5912::SHA_224_WITH_RSA_ENCRYPTION, - "sha224WithRSAEncryption", - ), - (&rfc5912::MD_2_WITH_RSA_ENCRYPTION, "md2WithRSAEncryption"), - (&rfc5912::MD_5_WITH_RSA_ENCRYPTION, "md5WithRSAEncryption"), - (&rfc5912::SHA_1_WITH_RSA_ENCRYPTION, "sha1WithRSAEncryption"), - (&rfc5912::ID_RSAES_OAEP, "id-RSAES-OAEP"), - (&rfc5912::ID_MGF_1, "id-mgf1"), - (&rfc5912::ID_P_SPECIFIED, "id-pSpecified"), - (&rfc5912::PKCS_9, "pkcs-9"), - (&rfc5912::ID_EXTENSION_REQ, "id-ExtensionReq"), - (&rfc5912::ID_SMIME, "id-smime"), - (&rfc5912::ID_CT, "id-ct"), - ( - &rfc5912::ID_CT_SCVP_CERT_VAL_REQUEST, - "id-ct-scvp-certValRequest", - ), - ( - &rfc5912::ID_CT_SCVP_CERT_VAL_RESPONSE, - "id-ct-scvp-certValResponse", - ), - ( - &rfc5912::ID_CT_SCVP_VAL_POL_REQUEST, - "id-ct-scvp-valPolRequest", - ), - ( - &rfc5912::ID_CT_SCVP_VAL_POL_RESPONSE, - "id-ct-scvp-valPolResponse", - ), - (&rfc5912::ID_CT_ENC_KEY_WITH_ID, "id-ct-encKeyWithID"), - (&rfc5912::ID_AA, "id-aa"), - (&rfc5912::ID_AA_CMC_UNSIGNED_DATA, "id-aa-cmc-unsignedData"), - (&rfc5912::ID_MD_2, "id-md2"), - (&rfc5912::ID_MD_5, "id-md5"), - (&rfc5912::SECT_163_K_1, "sect163k1"), - (&rfc5912::SECT_163_R_2, "sect163r2"), - (&rfc5912::SECT_283_K_1, "sect283k1"), - (&rfc5912::SECT_283_R_1, "sect283r1"), - (&rfc5912::SECT_233_K_1, "sect233k1"), - (&rfc5912::SECT_233_R_1, "sect233r1"), - (&rfc5912::SECP_224_R_1, "secp224r1"), - (&rfc5912::SECP_384_R_1, "secp384r1"), - (&rfc5912::SECP_521_R_1, "secp521r1"), - (&rfc5912::SECT_409_K_1, "sect409k1"), - (&rfc5912::SECT_409_R_1, "sect409r1"), - (&rfc5912::SECT_571_K_1, "sect571k1"), - (&rfc5912::SECT_571_R_1, "sect571r1"), - (&rfc5912::ID_EC_DH, "id-ecDH"), - (&rfc5912::ID_EC_MQV, "id-ecMQV"), - (&rfc5912::ID_SHA_1, "id-sha1"), - (&rfc5912::ID_PKIX, "id-pkix"), - (&rfc5912::ID_PE, "id-pe"), - ( - &rfc5912::ID_PE_AUTHORITY_INFO_ACCESS, - "id-pe-authorityInfoAccess", - ), - (&rfc5912::ID_PE_AC_PROXYING, "id-pe-ac-proxying"), - ( - &rfc5912::ID_PE_SUBJECT_INFO_ACCESS, - "id-pe-subjectInfoAccess", - ), - (&rfc5912::ID_PE_AC_AUDIT_IDENTITY, "id-pe-ac-auditIdentity"), - (&rfc5912::ID_PE_AA_CONTROLS, "id-pe-aaControls"), - (&rfc5912::ID_ACA, "id-aca"), - ( - &rfc5912::ID_ACA_AUTHENTICATION_INFO, - "id-aca-authenticationInfo", - ), - (&rfc5912::ID_ACA_ACCESS_IDENTITY, "id-aca-accessIdentity"), - ( - &rfc5912::ID_ACA_CHARGING_IDENTITY, - "id-aca-chargingIdentity", - ), - (&rfc5912::ID_ACA_GROUP, "id-aca-group"), - (&rfc5912::ID_ACA_ENC_ATTRS, "id-aca-encAttrs"), - (&rfc5912::ID_CCT, "id-cct"), - (&rfc5912::ID_CCT_PKI_DATA, "id-cct-PKIData"), - (&rfc5912::ID_CCT_PKI_RESPONSE, "id-cct-PKIResponse"), - (&rfc5912::ID_STC, "id-stc"), - (&rfc5912::ID_STC_BUILD_PKC_PATH, "id-stc-build-pkc-path"), - ( - &rfc5912::ID_STC_BUILD_VALID_PKC_PATH, - "id-stc-build-valid-pkc-path", - ), - ( - &rfc5912::ID_STC_BUILD_STATUS_CHECKED_PKC_PATH, - "id-stc-build-status-checked-pkc-path", - ), - (&rfc5912::ID_STC_BUILD_AA_PATH, "id-stc-build-aa-path"), - ( - &rfc5912::ID_STC_BUILD_VALID_AA_PATH, - "id-stc-build-valid-aa-path", - ), - ( - &rfc5912::ID_STC_BUILD_STATUS_CHECKED_AA_PATH, - "id-stc-build-status-checked-aa-path", - ), - ( - &rfc5912::ID_STC_STATUS_CHECK_AC_AND_BUILD_STATUS_CHECKED_AA_PATH, - "id-stc-status-check-ac-and-build-status-checked-aa-path", - ), - (&rfc5912::ID_SWB, "id-swb"), - ( - &rfc5912::ID_SWB_PKC_BEST_CERT_PATH, - "id-swb-pkc-best-cert-path", - ), - (&rfc5912::ID_SWB_PKC_CERT, "id-swb-pkc-cert"), - (&rfc5912::ID_SWB_AC_CERT, "id-swb-ac-cert"), - ( - &rfc5912::ID_SWB_PKC_ALL_CERT_PATHS, - "id-swb-pkc-all-cert-paths", - ), - ( - &rfc5912::ID_SWB_PKC_EE_REVOCATION_INFO, - "id-swb-pkc-ee-revocation-info", - ), - ( - &rfc5912::ID_SWB_PKC_C_AS_REVOCATION_INFO, - "id-swb-pkc-CAs-revocation-info", - ), - ( - &rfc5912::ID_SWB_PKC_REVOCATION_INFO, - "id-swb-pkc-revocation-info", - ), - ( - &rfc5912::ID_SWB_PKC_PUBLIC_KEY_INFO, - "id-swb-pkc-public-key-info", - ), - (&rfc5912::ID_SWB_AA_CERT_PATH, "id-swb-aa-cert-path"), - ( - &rfc5912::ID_SWB_AA_REVOCATION_INFO, - "id-swb-aa-revocation-info", - ), - ( - &rfc5912::ID_SWB_AC_REVOCATION_INFO, - "id-swb-ac-revocation-info", - ), - ( - &rfc5912::ID_SWB_RELAYED_RESPONSES, - "id-swb-relayed-responses", - ), - (&rfc5912::ID_SVP, "id-svp"), - ( - &rfc5912::ID_SVP_DEFAULT_VAL_POLICY, - "id-svp-defaultValPolicy", - ), - (&rfc5912::ID_SVP_NAME_VAL_ALG, "id-svp-nameValAlg"), - (&rfc5912::ID_SVP_BASIC_VAL_ALG, "id-svp-basicValAlg"), - (&rfc5912::NAME_COMP_ALG_SET, "NameCompAlgSet"), - (&rfc5912::ID_NVA_DN_COMP_ALG, "id-nva-dnCompAlg"), - (&rfc5912::ID_QT, "id-qt"), - (&rfc5912::ID_QT_CPS, "id-qt-cps"), - (&rfc5912::ID_QT_UNOTICE, "id-qt-unotice"), - (&rfc5912::ID_KP, "id-kp"), - (&rfc5912::ID_KP_SERVER_AUTH, "id-kp-serverAuth"), - (&rfc5912::ID_KP_SCVP_SERVER, "id-kp-scvpServer"), - (&rfc5912::ID_KP_SCVP_CLIENT, "id-kp-scvpClient"), - (&rfc5912::ID_KP_CLIENT_AUTH, "id-kp-clientAuth"), - (&rfc5912::ID_KP_CODE_SIGNING, "id-kp-codeSigning"), - (&rfc5912::ID_KP_EMAIL_PROTECTION, "id-kp-emailProtection"), - (&rfc5912::ID_KP_TIME_STAMPING, "id-kp-timeStamping"), - (&rfc5912::ID_KP_OCSP_SIGNING, "id-kp-OCSPSigning"), - (&rfc5912::ID_IT, "id-it"), - (&rfc5912::ID_IT_CA_PROT_ENC_CERT, "id-it-caProtEncCert"), - (&rfc5912::ID_IT_KEY_PAIR_PARAM_REQ, "id-it-keyPairParamReq"), - (&rfc5912::ID_IT_KEY_PAIR_PARAM_REP, "id-it-keyPairParamRep"), - (&rfc5912::ID_IT_REV_PASSPHRASE, "id-it-revPassphrase"), - (&rfc5912::ID_IT_IMPLICIT_CONFIRM, "id-it-implicitConfirm"), - (&rfc5912::ID_IT_CONFIRM_WAIT_TIME, "id-it-confirmWaitTime"), - (&rfc5912::ID_IT_ORIG_PKI_MESSAGE, "id-it-origPKIMessage"), - (&rfc5912::ID_IT_SUPP_LANG_TAGS, "id-it-suppLangTags"), - ( - &rfc5912::ID_IT_SIGN_KEY_PAIR_TYPES, - "id-it-signKeyPairTypes", - ), - (&rfc5912::ID_IT_ENC_KEY_PAIR_TYPES, "id-it-encKeyPairTypes"), - (&rfc5912::ID_IT_PREFERRED_SYMM_ALG, "id-it-preferredSymmAlg"), - (&rfc5912::ID_IT_CA_KEY_UPDATE_INFO, "id-it-caKeyUpdateInfo"), - (&rfc5912::ID_IT_CURRENT_CRL, "id-it-currentCRL"), - (&rfc5912::ID_IT_UNSUPPORTED_OI_DS, "id-it-unsupportedOIDs"), - (&rfc5912::ID_AD, "id-ad"), - (&rfc5912::ID_AD_OCSP, "id-ad-ocsp"), - (&rfc5912::ID_AD_CA_ISSUERS, "id-ad-caIssuers"), - (&rfc5912::ID_AD_TIME_STAMPING, "id-ad-timeStamping"), - (&rfc5912::ID_AD_CA_REPOSITORY, "id-ad-caRepository"), - (&rfc5912::ID_PKIP, "id-pkip"), - (&rfc5912::ID_REG_CTRL, "id-regCtrl"), - (&rfc5912::ID_REG_CTRL_REG_TOKEN, "id-regCtrl-regToken"), - ( - &rfc5912::ID_REG_CTRL_AUTHENTICATOR, - "id-regCtrl-authenticator", - ), - ( - &rfc5912::ID_REG_CTRL_PKI_PUBLICATION_INFO, - "id-regCtrl-pkiPublicationInfo", - ), - ( - &rfc5912::ID_REG_CTRL_PKI_ARCHIVE_OPTIONS, - "id-regCtrl-pkiArchiveOptions", - ), - (&rfc5912::ID_REG_CTRL_OLD_CERT_ID, "id-regCtrl-oldCertID"), - ( - &rfc5912::ID_REG_CTRL_PROTOCOL_ENCR_KEY, - "id-regCtrl-protocolEncrKey", - ), - (&rfc5912::ID_REG_INFO, "id-regInfo"), - (&rfc5912::ID_REG_INFO_UTF_8_PAIRS, "id-regInfo-utf8Pairs"), - (&rfc5912::ID_REG_INFO_CERT_REQ, "id-regInfo-certReq"), - (&rfc5912::ID_ALG_NO_SIGNATURE, "id-alg-noSignature"), - (&rfc5912::ID_CMC, "id-cmc"), - (&rfc5912::ID_CMC_STATUS_INFO, "id-cmc-statusInfo"), - (&rfc5912::ID_CMC_DECRYPTED_POP, "id-cmc-decryptedPOP"), - (&rfc5912::ID_CMC_LRA_POP_WITNESS, "id-cmc-lraPOPWitness"), - (&rfc5912::ID_CMC_GET_CERT, "id-cmc-getCert"), - (&rfc5912::ID_CMC_GET_CRL, "id-cmc-getCRL"), - (&rfc5912::ID_CMC_REVOKE_REQUEST, "id-cmc-revokeRequest"), - (&rfc5912::ID_CMC_REG_INFO, "id-cmc-regInfo"), - (&rfc5912::ID_CMC_RESPONSE_INFO, "id-cmc-responseInfo"), - (&rfc5912::ID_CMC_IDENTIFICATION, "id-cmc-identification"), - (&rfc5912::ID_CMC_QUERY_PENDING, "id-cmc-queryPending"), - (&rfc5912::ID_CMC_POP_LINK_RANDOM, "id-cmc-popLinkRandom"), - (&rfc5912::ID_CMC_POP_LINK_WITNESS, "id-cmc-popLinkWitness"), - ( - &rfc5912::ID_CMC_CONFIRM_CERT_ACCEPTANCE, - "id-cmc-confirmCertAcceptance", - ), - (&rfc5912::ID_CMC_STATUS_INFO_V_2, "id-cmc-statusInfoV2"), - (&rfc5912::ID_CMC_TRUSTED_ANCHORS, "id-cmc-trustedAnchors"), - (&rfc5912::ID_CMC_AUTH_DATA, "id-cmc-authData"), - (&rfc5912::ID_CMC_BATCH_REQUESTS, "id-cmc-batchRequests"), - (&rfc5912::ID_CMC_BATCH_RESPONSES, "id-cmc-batchResponses"), - (&rfc5912::ID_CMC_IDENTITY_PROOF, "id-cmc-identityProof"), - (&rfc5912::ID_CMC_PUBLISH_CERT, "id-cmc-publishCert"), - (&rfc5912::ID_CMC_MOD_CERT_TEMPLATE, "id-cmc-modCertTemplate"), - ( - &rfc5912::ID_CMC_CONTROL_PROCESSED, - "id-cmc-controlProcessed", - ), - ( - &rfc5912::ID_CMC_IDENTITY_PROOF_V_2, - "id-cmc-identityProofV2", - ), - ( - &rfc5912::ID_CMC_POP_LINK_WITNESS_V_2, - "id-cmc-popLinkWitnessV2", - ), - (&rfc5912::ID_CMC_DATA_RETURN, "id-cmc-dataReturn"), - (&rfc5912::ID_CMC_TRANSACTION_ID, "id-cmc-transactionId"), - (&rfc5912::ID_CMC_SENDER_NONCE, "id-cmc-senderNonce"), - (&rfc5912::ID_CMC_RECIPIENT_NONCE, "id-cmc-recipientNonce"), - (&rfc5912::ID_CMC_ADD_EXTENSIONS, "id-cmc-addExtensions"), - (&rfc5912::ID_CMC_ENCRYPTED_POP, "id-cmc-encryptedPOP"), - ( - &rfc5912::ID_KEY_EXCHANGE_ALGORITHM, - "id-keyExchangeAlgorithm", - ), - (&rfc5912::ID_SHA_256, "id-sha256"), - (&rfc5912::ID_SHA_384, "id-sha384"), - (&rfc5912::ID_SHA_512, "id-sha512"), - (&rfc5912::ID_SHA_224, "id-sha224"), - (&rfc5912::DSA_WITH_SHA_224, "dsa-with-sha224"), - (&rfc5912::DSA_WITH_SHA_256, "dsa-with-sha256"), - (&rfc5912::HOLD_INSTRUCTION, "holdInstruction"), - (&rfc5912::ID_HOLDINSTRUCTION_NONE, "id-holdinstruction-none"), - ( - &rfc5912::ID_HOLDINSTRUCTION_CALLISSUER, - "id-holdinstruction-callissuer", - ), - ( - &rfc5912::ID_HOLDINSTRUCTION_REJECT, - "id-holdinstruction-reject", - ), - (&rfc5912::ID_CE, "id-ce"), - ( - &rfc5912::ID_CE_SUBJECT_KEY_IDENTIFIER, - "id-ce-subjectKeyIdentifier", - ), - (&rfc5912::ID_CE_KEY_USAGE, "id-ce-keyUsage"), - ( - &rfc5912::ID_CE_PRIVATE_KEY_USAGE_PERIOD, - "id-ce-privateKeyUsagePeriod", - ), - (&rfc5912::ID_CE_SUBJECT_ALT_NAME, "id-ce-subjectAltName"), - (&rfc5912::ID_CE_ISSUER_ALT_NAME, "id-ce-issuerAltName"), - (&rfc5912::ID_CE_BASIC_CONSTRAINTS, "id-ce-basicConstraints"), - (&rfc5912::ID_CE_CRL_NUMBER, "id-ce-cRLNumber"), - (&rfc5912::ID_CE_CRL_REASONS, "id-ce-cRLReasons"), - ( - &rfc5912::ID_CE_HOLD_INSTRUCTION_CODE, - "id-ce-holdInstructionCode", - ), - (&rfc5912::ID_CE_INVALIDITY_DATE, "id-ce-invalidityDate"), - ( - &rfc5912::ID_CE_DELTA_CRL_INDICATOR, - "id-ce-deltaCRLIndicator", - ), - ( - &rfc5912::ID_CE_ISSUING_DISTRIBUTION_POINT, - "id-ce-issuingDistributionPoint", - ), - ( - &rfc5912::ID_CE_CERTIFICATE_ISSUER, - "id-ce-certificateIssuer", - ), - (&rfc5912::ID_CE_NAME_CONSTRAINTS, "id-ce-nameConstraints"), - ( - &rfc5912::ID_CE_CRL_DISTRIBUTION_POINTS, - "id-ce-cRLDistributionPoints", - ), - ( - &rfc5912::ID_CE_CERTIFICATE_POLICIES, - "id-ce-certificatePolicies", - ), - (&rfc5912::ID_CE_POLICY_MAPPINGS, "id-ce-policyMappings"), - ( - &rfc5912::ID_CE_AUTHORITY_KEY_IDENTIFIER, - "id-ce-authorityKeyIdentifier", - ), - ( - &rfc5912::ID_CE_POLICY_CONSTRAINTS, - "id-ce-policyConstraints", - ), - (&rfc5912::ID_CE_EXT_KEY_USAGE, "id-ce-extKeyUsage"), - (&rfc5912::ANY_EXTENDED_KEY_USAGE, "anyExtendedKeyUsage"), - (&rfc5912::ID_CE_FRESHEST_CRL, "id-ce-freshestCRL"), - (&rfc5912::ID_CE_INHIBIT_ANY_POLICY, "id-ce-inhibitAnyPolicy"), - ( - &rfc5912::ID_CE_TARGET_INFORMATION, - "id-ce-targetInformation", - ), - (&rfc5912::ID_CE_NO_REV_AVAIL, "id-ce-noRevAvail"), - ( - &rfc5912::ID_CE_SUBJECT_DIRECTORY_ATTRIBUTES, - "id-ce-subjectDirectoryAttributes", - ), - (&rfc5912::ID_AT, "id-at"), - (&rfc5912::ID_AT_ROLE, "id-at-role"), - (&rfc6109::LDIF_LOCATION_URL_OBJECT, "LDIFLocationURLObject"), - (&rfc6109::PROVIDER, "provider"), - ( - &rfc6109::PROVIDER_CERTIFICATE_HASH, - "providerCertificateHash", - ), - (&rfc6109::PROVIDER_CERTIFICATE, "providerCertificate"), - (&rfc6109::PROVIDER_NAME, "providerName"), - (&rfc6109::MAIL_RECEIPT, "mailReceipt"), - (&rfc6109::MANAGED_DOMAINS, "managedDomains"), - (&rfc6109::LDIF_LOCATION_URL, "LDIFLocationURL"), - (&rfc6109::PROVIDER_UNIT, "providerUnit"), - (&rfc6268::RSADSI, "rsadsi"), - (&rfc6268::ID_DATA, "id-data"), - (&rfc6268::ID_SIGNED_DATA, "id-signedData"), - (&rfc6268::ID_ENVELOPED_DATA, "id-envelopedData"), - (&rfc6268::ID_DIGESTED_DATA, "id-digestedData"), - (&rfc6268::ID_ENCRYPTED_DATA, "id-encryptedData"), - ( - &rfc6268::ID_CT_CONTENT_COLLECTION, - "id-ct-contentCollection", - ), - (&rfc6268::ID_CT_AUTH_DATA, "id-ct-authData"), - (&rfc6268::ID_CT_CONTENT_WITH_ATTRS, "id-ct-contentWithAttrs"), - ( - &rfc6268::ID_CT_AUTH_ENVELOPED_DATA, - "id-ct-authEnvelopedData", - ), - (&rfc6268::ID_CT_CONTENT_INFO, "id-ct-contentInfo"), - (&rfc6268::ID_CT_COMPRESSED_DATA, "id-ct-compressedData"), - ( - &rfc6268::ID_AA_BINARY_SIGNING_TIME, - "id-aa-binarySigningTime", - ), - (&rfc6268::ID_ALG_ZLIB_COMPRESS, "id-alg-zlibCompress"), - ( - &rfc6268::ID_AA_MULTIPLE_SIGNATURES, - "id-aa-multipleSignatures", - ), - (&rfc6268::ID_CONTENT_TYPE, "id-contentType"), - (&rfc6268::ID_MESSAGE_DIGEST, "id-messageDigest"), - (&rfc6268::ID_SIGNING_TIME, "id-signingTime"), - (&rfc6268::ID_COUNTERSIGNATURE, "id-countersignature"), - (&rfc6268::DIGEST_ALGORITHM, "digestAlgorithm"), - (&rfc6268::ID_HMAC_WITH_SHA_384, "id-hmacWithSHA384"), - (&rfc6268::ID_HMAC_WITH_SHA_512, "id-hmacWithSHA512"), - (&rfc6268::ID_HMAC_WITH_SHA_224, "id-hmacWithSHA224"), - (&rfc6268::ID_HMAC_WITH_SHA_256, "id-hmacWithSHA256"), - (&rfc6960::ID_PKIX_OCSP, "id-pkix-ocsp"), - (&rfc6960::ID_PKIX_OCSP_BASIC, "id-pkix-ocsp-basic"), - (&rfc6960::ID_PKIX_OCSP_NONCE, "id-pkix-ocsp-nonce"), - (&rfc6960::ID_PKIX_OCSP_CRL, "id-pkix-ocsp-crl"), - (&rfc6960::ID_PKIX_OCSP_RESPONSE, "id-pkix-ocsp-response"), - (&rfc6960::ID_PKIX_OCSP_NOCHECK, "id-pkix-ocsp-nocheck"), - ( - &rfc6960::ID_PKIX_OCSP_ARCHIVE_CUTOFF, - "id-pkix-ocsp-archive-cutoff", - ), - ( - &rfc6960::ID_PKIX_OCSP_SERVICE_LOCATOR, - "id-pkix-ocsp-service-locator", - ), - ( - &rfc6960::ID_PKIX_OCSP_PREF_SIG_ALGS, - "id-pkix-ocsp-pref-sig-algs", - ), - ( - &rfc6960::ID_PKIX_OCSP_EXTENDED_REVOKE, - "id-pkix-ocsp-extended-revoke", - ), - (&rfc6962::GOOGLE, "google"), - (&rfc6962::CT_PRECERT_SCTS, "ct-precert-scts"), - (&rfc6962::CT_PRECERT_POISON, "ct-precert-poison"), - (&rfc6962::CT_PRECERT_SIGNING_CERT, "ct-precert-signing-cert"), - (&rfc7107::ID_SMIME, "id-smime"), - (&rfc7107::ID_MOD, "id-mod"), - (&rfc7107::ID_CT, "id-ct"), - (&rfc7107::ID_EIT, "id-eit"), - (&rfc7107::ID_CAP, "id-cap"), - (&rfc7107::ID_PSKC, "id-pskc"), - (&rfc7107::ID_AA, "id-aa"), - (&rfc7107::ID_ALG, "id-alg"), - (&rfc7107::ID_CD, "id-cd"), - (&rfc7107::ID_SPQ, "id-spq"), - (&rfc7107::ID_CTI, "id-cti"), - (&rfc7107::ID_TSP, "id-tsp"), - (&rfc7107::ID_SKD, "id-skd"), - (&rfc7107::ID_STI, "id-sti"), - (&rfc7299::ID_PKIX, "id-pkix"), - (&rfc7299::ID_MOD, "id-mod"), - (&rfc7299::ID_PE, "id-pe"), - (&rfc7299::ID_ACA, "id-aca"), - (&rfc7299::ID_QCS, "id-qcs"), - (&rfc7299::ID_CCT, "id-cct"), - (&rfc7299::ID_TEST, "id-TEST"), - (&rfc7299::ID_CP, "id-cp"), - (&rfc7299::ID_CET, "id-cet"), - (&rfc7299::ID_RI, "id-ri"), - (&rfc7299::ID_SCT, "id-sct"), - (&rfc7299::ID_SWB, "id-swb"), - (&rfc7299::ID_SVP, "id-svp"), - (&rfc7299::ID_NVAE, "id-nvae"), - (&rfc7299::ID_BVAE, "id-bvae"), - (&rfc7299::ID_DNVAE, "id-dnvae"), - (&rfc7299::ID_QT, "id-qt"), - (&rfc7299::ID_LOGO, "id-logo"), - (&rfc7299::ID_PPL, "id-ppl"), - (&rfc7299::ID_MR, "id-mr"), - (&rfc7299::ID_SKIS, "id-skis"), - (&rfc7299::ID_KP, "id-kp"), - (&rfc7299::ID_IT, "id-it"), - (&rfc7299::ID_AD, "id-ad"), - (&rfc7299::ID_PKIX_OCSP, "id-pkix-ocsp"), - (&rfc7299::ID_PKIP, "id-pkip"), - (&rfc7299::ID_REG_CTRL, "id-regCtrl"), - (&rfc7299::ID_REG_INFO, "id-regInfo"), - (&rfc7299::ID_ALG, "id-alg"), - (&rfc7299::ID_CMC, "id-cmc"), - (&rfc7299::ID_CMC_GLA_RR, "id-cmc-glaRR"), - (&rfc7299::ID_ON, "id-on"), - (&rfc7299::ID_PDA, "id-pda"), - (&rfc7532::FEDFS_UUID, "fedfsUuid"), - (&rfc7532::FEDFS_FSL_PORT, "fedfsFslPort"), - (&rfc7532::FEDFS_NFS_PATH, "fedfsNfsPath"), - ( - &rfc7532::FEDFS_NSDB_CONTAINER_INFO, - "fedfsNsdbContainerInfo", - ), - (&rfc7532::FEDFS_FSN, "fedfsFsn"), - (&rfc7532::FEDFS_FSL, "fedfsFsl"), - (&rfc7532::FEDFS_NFS_FSL, "fedfsNfsFsl"), - (&rfc7532::FEDFS_NFS_MAJOR_VER, "fedfsNfsMajorVer"), - (&rfc7532::FEDFS_NFS_MINOR_VER, "fedfsNfsMinorVer"), - (&rfc7532::FEDFS_NFS_CURRENCY, "fedfsNfsCurrency"), - ( - &rfc7532::FEDFS_NFS_GEN_FLAG_WRITABLE, - "fedfsNfsGenFlagWritable", - ), - (&rfc7532::FEDFS_NFS_GEN_FLAG_GOING, "fedfsNfsGenFlagGoing"), - (&rfc7532::FEDFS_NFS_GEN_FLAG_SPLIT, "fedfsNfsGenFlagSplit"), - (&rfc7532::FEDFS_NFS_TRANS_FLAG_RDMA, "fedfsNfsTransFlagRdma"), - (&rfc7532::FEDFS_NFS_CLASS_SIMUL, "fedfsNfsClassSimul"), - (&rfc7532::FEDFS_NFS_CLASS_HANDLE, "fedfsNfsClassHandle"), - (&rfc7532::FEDFS_FSL_TTL, "fedfsFslTTL"), - (&rfc7532::FEDFS_NFS_CLASS_FILEID, "fedfsNfsClassFileid"), - (&rfc7532::FEDFS_NFS_CLASS_WRITEVER, "fedfsNfsClassWritever"), - (&rfc7532::FEDFS_NFS_CLASS_CHANGE, "fedfsNfsClassChange"), - (&rfc7532::FEDFS_NFS_CLASS_READDIR, "fedfsNfsClassReaddir"), - (&rfc7532::FEDFS_NFS_READ_RANK, "fedfsNfsReadRank"), - (&rfc7532::FEDFS_NFS_READ_ORDER, "fedfsNfsReadOrder"), - (&rfc7532::FEDFS_NFS_WRITE_RANK, "fedfsNfsWriteRank"), - (&rfc7532::FEDFS_NFS_WRITE_ORDER, "fedfsNfsWriteOrder"), - (&rfc7532::FEDFS_NFS_VAR_SUB, "fedfsNfsVarSub"), - (&rfc7532::FEDFS_NFS_VALID_FOR, "fedfsNfsValidFor"), - (&rfc7532::FEDFS_ANNOTATION, "fedfsAnnotation"), - (&rfc7532::FEDFS_NFS_URI, "fedfsNfsURI"), - (&rfc7532::FEDFS_DESCR, "fedfsDescr"), - (&rfc7532::FEDFS_NCE_DN, "fedfsNceDN"), - (&rfc7532::FEDFS_FSN_TTL, "fedfsFsnTTL"), - (&rfc7532::FEDFS_NET_ADDR, "fedfsNetAddr"), - (&rfc7532::FEDFS_NET_PORT, "fedfsNetPort"), - (&rfc7532::FEDFS_FSN_UUID, "fedfsFsnUuid"), - (&rfc7532::FEDFS_NSDB_NAME, "fedfsNsdbName"), - (&rfc7532::FEDFS_NSDB_PORT, "fedfsNsdbPort"), - (&rfc7532::FEDFS_NCE_PREFIX, "fedfsNcePrefix"), - (&rfc7532::FEDFS_FSL_UUID, "fedfsFslUuid"), - (&rfc7532::FEDFS_FSL_HOST, "fedfsFslHost"), - (&rfc7612::PRINTER_DEVICE_ID, "printer-device-id"), - ( - &rfc7612::PRINTER_DEVICE_SERVICE_COUNT, - "printer-device-service-count", - ), - (&rfc7612::PRINTER_UUID, "printer-uuid"), - (&rfc7612::PRINTER_CHARGE_INFO, "printer-charge-info"), - (&rfc7612::PRINTER_CHARGE_INFO_URI, "printer-charge-info-uri"), - (&rfc7612::PRINTER_GEO_LOCATION, "printer-geo-location"), - ( - &rfc7612::PRINTER_IPP_FEATURES_SUPPORTED, - "printer-ipp-features-supported", - ), - (&rfc8284::JID_OBJECT, "JIDObject"), - (&rfc8284::JID, "jid"), - (&rfc8410::ID_EDWARDS_CURVE_ALGS, "id-edwards-curve-algs"), - (&rfc8410::ID_X_25519, "id-X25519"), - (&rfc8410::ID_X_448, "id-X448"), - (&rfc8410::ID_ED_25519, "id-Ed25519"), - (&rfc8410::ID_ED_448, "id-Ed448"), - (&rfc8894::ID_VERI_SIGN, "id-VeriSign"), - (&rfc8894::ID_PKI, "id-pki"), - (&rfc8894::ID_ATTRIBUTES, "id-attributes"), - (&rfc8894::ID_MESSAGE_TYPE, "id-messageType"), - (&rfc8894::ID_PKI_STATUS, "id-pkiStatus"), - (&rfc8894::ID_FAIL_INFO, "id-failInfo"), - (&rfc8894::ID_SENDER_NONCE, "id-senderNonce"), - (&rfc8894::ID_RECIPIENT_NONCE, "id-recipientNonce"), - (&rfc8894::ID_TRANSACTION_ID, "id-transactionID"), -]); diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/encoder.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/encoder.rs deleted file mode 100644 index 4df3aab4507d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/encoder.rs +++ /dev/null @@ -1,165 +0,0 @@ -//! OID encoder with `const` support. - -use crate::{ - arcs::{ARC_MAX_FIRST, ARC_MAX_SECOND}, - Arc, Error, ObjectIdentifier, Result, -}; - -/// BER/DER encoder -#[derive(Debug)] -pub(crate) struct Encoder { - /// Current state - state: State, - - /// Bytes of the OID being encoded in-progress - bytes: [u8; ObjectIdentifier::MAX_SIZE], - - /// Current position within the byte buffer - cursor: usize, -} - -/// Current state of the encoder -#[derive(Debug)] -enum State { - /// Initial state - no arcs yet encoded - Initial, - - /// First arc parsed - FirstArc(Arc), - - /// Encoding base 128 body of the OID - Body, -} - -impl Encoder { - /// Create a new encoder initialized to an empty default state. - pub(crate) const fn new() -> Self { - Self { - state: State::Initial, - bytes: [0u8; ObjectIdentifier::MAX_SIZE], - cursor: 0, - } - } - - /// Extend an existing OID. - pub(crate) const fn extend(oid: ObjectIdentifier) -> Self { - Self { - state: State::Body, - bytes: oid.bytes, - cursor: oid.length as usize, - } - } - - /// Encode an [`Arc`] as base 128 into the internal buffer. - pub(crate) const fn arc(mut self, arc: Arc) -> Result { - match self.state { - State::Initial => { - if arc > ARC_MAX_FIRST { - return Err(Error::ArcInvalid { arc }); - } - - self.state = State::FirstArc(arc); - Ok(self) - } - // Ensured not to overflow by `ARC_MAX_SECOND` check - #[allow(clippy::integer_arithmetic)] - State::FirstArc(first_arc) => { - if arc > ARC_MAX_SECOND { - return Err(Error::ArcInvalid { arc }); - } - - self.state = State::Body; - self.bytes[0] = (first_arc * (ARC_MAX_SECOND + 1)) as u8 + arc as u8; - self.cursor = 1; - Ok(self) - } - // TODO(tarcieri): finer-grained overflow safety / checked arithmetic - #[allow(clippy::integer_arithmetic)] - State::Body => { - // Total number of bytes in encoded arc - 1 - let nbytes = base128_len(arc); - - // Shouldn't overflow on any 16-bit+ architectures - if self.cursor + nbytes + 1 >= ObjectIdentifier::MAX_SIZE { - return Err(Error::Length); - } - - let new_cursor = self.cursor + nbytes + 1; - - // TODO(tarcieri): use `?` when stable in `const fn` - match self.encode_base128_byte(arc, nbytes, false) { - Ok(mut encoder) => { - encoder.cursor = new_cursor; - Ok(encoder) - } - Err(err) => Err(err), - } - } - } - } - - /// Finish encoding an OID. - pub(crate) const fn finish(self) -> Result { - if self.cursor >= 2 { - Ok(ObjectIdentifier { - bytes: self.bytes, - length: self.cursor as u8, - }) - } else { - Err(Error::NotEnoughArcs) - } - } - - /// Encode a single byte of a Base 128 value. - const fn encode_base128_byte(mut self, mut n: u32, i: usize, continued: bool) -> Result { - let mask = if continued { 0b10000000 } else { 0 }; - - // Underflow checked by branch - #[allow(clippy::integer_arithmetic)] - if n > 0x80 { - self.bytes[checked_add!(self.cursor, i)] = (n & 0b1111111) as u8 | mask; - n >>= 7; - - if i > 0 { - self.encode_base128_byte(n, i.saturating_sub(1), true) - } else { - Err(Error::Base128) - } - } else { - self.bytes[self.cursor] = n as u8 | mask; - Ok(self) - } - } -} - -/// Compute the length - 1 of an arc when encoded in base 128. -const fn base128_len(arc: Arc) -> usize { - match arc { - 0..=0x7f => 0, - 0x80..=0x3fff => 1, - 0x4000..=0x1fffff => 2, - 0x200000..=0x1fffffff => 3, - _ => 4, - } -} - -#[cfg(test)] -mod tests { - use super::Encoder; - use hex_literal::hex; - - /// OID `1.2.840.10045.2.1` encoded as ASN.1 BER/DER - const EXAMPLE_OID_BER: &[u8] = &hex!("2A8648CE3D0201"); - - #[test] - fn encode() { - let encoder = Encoder::new(); - let encoder = encoder.arc(1).unwrap(); - let encoder = encoder.arc(2).unwrap(); - let encoder = encoder.arc(840).unwrap(); - let encoder = encoder.arc(10045).unwrap(); - let encoder = encoder.arc(2).unwrap(); - let encoder = encoder.arc(1).unwrap(); - assert_eq!(&encoder.bytes[..encoder.cursor], EXAMPLE_OID_BER); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/error.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/error.rs deleted file mode 100644 index 528ce785c4d5..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/error.rs +++ /dev/null @@ -1,83 +0,0 @@ -//! Error types - -use crate::Arc; -use core::fmt; - -/// Result type -pub type Result = core::result::Result; - -/// OID errors. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub enum Error { - /// Arc exceeds allowed range (i.e. for first or second OID) - ArcInvalid { - /// Arc value that is erroneous. - arc: Arc, - }, - - /// Arc is too big (exceeds 32-bit limits of this library). - /// - /// Technically the size of an arc is not constrained by X.660, however - /// this library has elected to use `u32` as the arc representation as - /// sufficient for PKIX/PKCS usages. - ArcTooBig, - - /// Base 128 encoding error (used in BER/DER serialization of arcs). - Base128, - - /// Expected a digit, but was provided something else. - DigitExpected { - /// What was found instead of a digit - actual: u8, - }, - - /// Input data is empty. - Empty, - - /// OID length is invalid (too short or too long). - Length, - - /// Minimum 3 arcs required. - NotEnoughArcs, - - /// Trailing `.` character at end of input. - TrailingDot, -} - -impl Error { - /// Escalate this error into a panic. - /// - /// This is a workaround until `Result::unwrap` is allowed in `const fn`. - #[allow(clippy::panic)] - pub(crate) const fn panic(self) -> ! { - match self { - Error::ArcInvalid { .. } | Error::ArcTooBig => panic!("OID contains invalid arc"), - Error::Base128 => panic!("OID contains arc with invalid base 128 encoding"), - Error::DigitExpected { .. } => panic!("OID expected to start with digit"), - Error::Empty => panic!("OID value is empty"), - Error::Length => panic!("OID length invalid"), - Error::NotEnoughArcs => panic!("OID requires minimum of 3 arcs"), - Error::TrailingDot => panic!("OID ends with invalid trailing '.'"), - } - } -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self { - Error::ArcInvalid { arc } => write!(f, "OID contains out-of-range arc: {}", arc), - Error::ArcTooBig => f.write_str("OID contains arc which is larger than 32-bits"), - Error::Base128 => f.write_str("OID contains arc with invalid base 128 encoding"), - Error::DigitExpected { actual } => { - write!(f, "expected digit, got '{}'", char::from(actual)) - } - Error::Empty => f.write_str("OID value is empty"), - Error::Length => f.write_str("OID length invalid"), - Error::NotEnoughArcs => f.write_str("OID requires minimum of 3 arcs"), - Error::TrailingDot => f.write_str("OID ends with invalid trailing '.'"), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/lib.rs deleted file mode 100644 index 5bdef085dfe3..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/lib.rs +++ /dev/null @@ -1,280 +0,0 @@ -#![no_std] -#![cfg_attr(docsrs, feature(doc_cfg))] -#![doc = include_str!("../README.md")] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" -)] -#![forbid(unsafe_code)] -#![warn( - clippy::integer_arithmetic, - clippy::panic, - clippy::panic_in_result_fn, - clippy::unwrap_used, - missing_docs, - rust_2018_idioms, - unused_lifetimes, - unused_qualifications -)] - -#[cfg(feature = "std")] -extern crate std; - -#[macro_use] -mod checked; - -mod arcs; -mod encoder; -mod error; -mod parser; - -#[cfg(feature = "db")] -#[cfg_attr(docsrs, doc(cfg(feature = "db")))] -pub mod db; - -pub use crate::{ - arcs::{Arc, Arcs}, - error::{Error, Result}, -}; - -use crate::encoder::Encoder; -use core::{fmt, str::FromStr}; - -/// A trait which associates an OID with a type. -pub trait AssociatedOid { - /// The OID associated with this type. - const OID: ObjectIdentifier; -} - -/// A trait which associates a dynamic, `&self`-dependent OID with a type, -/// which may change depending on the type's value. -/// -/// This trait is object safe and auto-impl'd for any types which impl -/// [`AssociatedOid`]. -pub trait DynAssociatedOid { - /// Get the OID associated with this value. - fn oid(&self) -> ObjectIdentifier; -} - -impl DynAssociatedOid for T { - fn oid(&self) -> ObjectIdentifier { - T::OID - } -} - -/// Object identifier (OID). -/// -/// OIDs are hierarchical structures consisting of "arcs", i.e. integer -/// identifiers. -/// -/// # Validity -/// -/// In order for an OID to be considered valid by this library, it must meet -/// the following criteria: -/// -/// - The OID MUST have at least 3 arcs -/// - The first arc MUST be within the range 0-2 -/// - The second arc MUST be within the range 0-39 -/// - The BER/DER encoding of the OID MUST be shorter than -/// [`ObjectIdentifier::MAX_SIZE`] -#[derive(Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] -pub struct ObjectIdentifier { - /// Length in bytes - length: u8, - - /// Array containing BER/DER-serialized bytes (no header) - bytes: [u8; Self::MAX_SIZE], -} - -#[allow(clippy::len_without_is_empty)] -impl ObjectIdentifier { - /// Maximum size of a BER/DER-encoded OID in bytes. - pub const MAX_SIZE: usize = 39; // makes `ObjectIdentifier` 40-bytes total w\ 1-byte length - - /// Parse an [`ObjectIdentifier`] from the dot-delimited string form, - /// panicking on parse errors. - /// - /// This function exists as a workaround for `unwrap` not yet being - /// stable in `const fn` contexts, and is intended to allow the result to - /// be bound to a constant value: - /// - /// ``` - /// use const_oid::ObjectIdentifier; - /// - /// pub const MY_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.1"); - /// ``` - /// - /// In future versions of Rust it should be possible to replace this with - /// `ObjectIdentifier::new(...).unwrap()`. - /// - /// Use [`ObjectIdentifier::new`] for fallible parsing. - // TODO(tarcieri): remove this when `Result::unwrap` is `const fn` - pub const fn new_unwrap(s: &str) -> Self { - match Self::new(s) { - Ok(oid) => oid, - Err(err) => err.panic(), - } - } - - /// Parse an [`ObjectIdentifier`] from the dot-delimited string form. - pub const fn new(s: &str) -> Result { - // TODO(tarcieri): use `?` when stable in `const fn` - match parser::Parser::parse(s) { - Ok(parser) => parser.finish(), - Err(err) => Err(err), - } - } - - /// Parse an OID from a slice of [`Arc`] values (i.e. integers). - pub fn from_arcs(arcs: impl IntoIterator) -> Result { - let mut encoder = Encoder::new(); - - for arc in arcs { - encoder = encoder.arc(arc)?; - } - - encoder.finish() - } - - /// Parse an OID from from its BER/DER encoding. - pub fn from_bytes(ber_bytes: &[u8]) -> Result { - let len = ber_bytes.len(); - - match len { - 0 => return Err(Error::Empty), - 3..=Self::MAX_SIZE => (), - _ => return Err(Error::NotEnoughArcs), - } - let mut bytes = [0u8; Self::MAX_SIZE]; - bytes[..len].copy_from_slice(ber_bytes); - - let oid = Self { - bytes, - length: len as u8, - }; - - // Ensure arcs are well-formed - let mut arcs = oid.arcs(); - while arcs.try_next()?.is_some() {} - - Ok(oid) - } - - /// Get the BER/DER serialization of this OID as bytes. - /// - /// Note that this encoding omits the tag/length, and only contains the - /// value portion of the encoded OID. - pub fn as_bytes(&self) -> &[u8] { - &self.bytes[..self.length as usize] - } - - /// Return the arc with the given index, if it exists. - pub fn arc(&self, index: usize) -> Option { - self.arcs().nth(index) - } - - /// Iterate over the arcs (a.k.a. nodes) of an [`ObjectIdentifier`]. - /// - /// Returns [`Arcs`], an iterator over [`Arc`] values. - pub fn arcs(&self) -> Arcs<'_> { - Arcs::new(self) - } - - /// Get the length of this [`ObjectIdentifier`] in arcs. - pub fn len(&self) -> usize { - self.arcs().count() - } - - /// Get the parent OID of this one (if applicable). - pub fn parent(&self) -> Option { - let num_arcs = self.len().checked_sub(1)?; - Self::from_arcs(self.arcs().take(num_arcs)).ok() - } - - /// Push an additional arc onto this OID, returning the child OID. - pub const fn push_arc(self, arc: Arc) -> Result { - // TODO(tarcieri): use `?` when stable in `const fn` - match Encoder::extend(self).arc(arc) { - Ok(encoder) => encoder.finish(), - Err(err) => Err(err), - } - } -} - -impl AsRef<[u8]> for ObjectIdentifier { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } -} - -impl FromStr for ObjectIdentifier { - type Err = Error; - - fn from_str(string: &str) -> Result { - Self::new(string) - } -} - -impl TryFrom<&[u8]> for ObjectIdentifier { - type Error = Error; - - fn try_from(ber_bytes: &[u8]) -> Result { - Self::from_bytes(ber_bytes) - } -} - -impl From<&ObjectIdentifier> for ObjectIdentifier { - fn from(oid: &ObjectIdentifier) -> ObjectIdentifier { - *oid - } -} - -impl fmt::Debug for ObjectIdentifier { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "ObjectIdentifier({})", self) - } -} - -impl fmt::Display for ObjectIdentifier { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let len = self.arcs().count(); - - for (i, arc) in self.arcs().enumerate() { - write!(f, "{}", arc)?; - - if let Some(j) = i.checked_add(1) { - if j < len { - write!(f, ".")?; - } - } - } - - Ok(()) - } -} - -// Implement by hand because the derive would create invalid values. -// Use the constructor to create a valid oid with at least 3 arcs. -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for ObjectIdentifier { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - let first = u.int_in_range(0..=arcs::ARC_MAX_FIRST)?; - let second = u.int_in_range(0..=arcs::ARC_MAX_SECOND)?; - let third = u.arbitrary()?; - - let mut oid = Self::from_arcs([first, second, third]) - .map_err(|_| arbitrary::Error::IncorrectFormat)?; - - for arc in u.arbitrary_iter()? { - oid = oid - .push_arc(arc?) - .map_err(|_| arbitrary::Error::IncorrectFormat)?; - } - - Ok(oid) - } - - fn size_hint(depth: usize) -> (usize, Option) { - (Arc::size_hint(depth).0.saturating_mul(3), None) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/parser.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/parser.rs deleted file mode 100644 index 6f875faaa656..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/parser.rs +++ /dev/null @@ -1,112 +0,0 @@ -//! OID string parser with `const` support. - -use crate::{encoder::Encoder, Arc, Error, ObjectIdentifier, Result}; - -/// Const-friendly OID string parser. -/// -/// Parses an OID from the dotted string representation. -#[derive(Debug)] -pub(crate) struct Parser { - /// Current arc in progress - current_arc: Arc, - - /// BER/DER encoder - encoder: Encoder, -} - -impl Parser { - /// Parse an OID from a dot-delimited string e.g. `1.2.840.113549.1.1.1` - pub(crate) const fn parse(s: &str) -> Result { - let bytes = s.as_bytes(); - - if bytes.is_empty() { - return Err(Error::Empty); - } - - match bytes[0] { - b'0'..=b'9' => Self { - current_arc: 0, - encoder: Encoder::new(), - } - .parse_bytes(bytes), - actual => Err(Error::DigitExpected { actual }), - } - } - - /// Finish parsing, returning the result - pub(crate) const fn finish(self) -> Result { - self.encoder.finish() - } - - /// Parse the remaining bytes - const fn parse_bytes(mut self, bytes: &[u8]) -> Result { - match bytes { - // TODO(tarcieri): use `?` when stable in `const fn` - [] => match self.encoder.arc(self.current_arc) { - Ok(encoder) => { - self.encoder = encoder; - Ok(self) - } - Err(err) => Err(err), - }, - // TODO(tarcieri): checked arithmetic - #[allow(clippy::integer_arithmetic)] - [byte @ b'0'..=b'9', remaining @ ..] => { - let digit = byte.saturating_sub(b'0'); - self.current_arc = self.current_arc * 10 + digit as Arc; - self.parse_bytes(remaining) - } - [b'.', remaining @ ..] => { - if remaining.is_empty() { - return Err(Error::TrailingDot); - } - - // TODO(tarcieri): use `?` when stable in `const fn` - match self.encoder.arc(self.current_arc) { - Ok(encoder) => { - self.encoder = encoder; - self.current_arc = 0; - self.parse_bytes(remaining) - } - Err(err) => Err(err), - } - } - [byte, ..] => Err(Error::DigitExpected { actual: *byte }), - } - } -} - -#[cfg(test)] -mod tests { - use super::Parser; - use crate::Error; - - #[test] - fn parse() { - let oid = Parser::parse("1.23.456").unwrap().finish().unwrap(); - assert_eq!(oid, "1.23.456".parse().unwrap()); - } - - #[test] - fn reject_empty_string() { - assert_eq!(Parser::parse("").err().unwrap(), Error::Empty); - } - - #[test] - fn reject_non_digits() { - assert_eq!( - Parser::parse("X").err().unwrap(), - Error::DigitExpected { actual: b'X' } - ); - - assert_eq!( - Parser::parse("1.2.X").err().unwrap(), - Error::DigitExpected { actual: b'X' } - ); - } - - #[test] - fn reject_trailing_dot() { - assert_eq!(Parser::parse("1.23.").err().unwrap(), Error::TrailingDot); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/tests/lib.rs b/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/tests/lib.rs deleted file mode 100644 index e91dfc6cae46..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/tests/lib.rs +++ /dev/null @@ -1,209 +0,0 @@ -//! `const-oid` crate tests - -// TODO(tarcieri): test full set of OID encoding constraints specified here: -// - -use const_oid::{Error, ObjectIdentifier}; -use hex_literal::hex; -use std::string::ToString; - -/// Example OID value with a root arc of `0` (and large arc). -const EXAMPLE_OID_0_STR: &str = "0.9.2342.19200300.100.1.1"; -const EXAMPLE_OID_0_BER: &[u8] = &hex!("0992268993F22C640101"); -const EXAMPLE_OID_0: ObjectIdentifier = ObjectIdentifier::new_unwrap(EXAMPLE_OID_0_STR); - -/// Example OID value with a root arc of `1`. -const EXAMPLE_OID_1_STR: &str = "1.2.840.10045.2.1"; -const EXAMPLE_OID_1_BER: &[u8] = &hex!("2A8648CE3D0201"); -const EXAMPLE_OID_1: ObjectIdentifier = ObjectIdentifier::new_unwrap(EXAMPLE_OID_1_STR); - -/// Example OID value with a root arc of `2`. -const EXAMPLE_OID_2_STR: &str = "2.16.840.1.101.3.4.1.42"; -const EXAMPLE_OID_2_BER: &[u8] = &hex!("60864801650304012A"); -const EXAMPLE_OID_2: ObjectIdentifier = ObjectIdentifier::new_unwrap(EXAMPLE_OID_2_STR); - -/// Example OID value with a large arc -const EXAMPLE_OID_LARGE_ARC_STR: &str = "0.9.2342.19200300.100.1.1"; -const EXAMPLE_OID_LARGE_ARC_BER: &[u8] = &hex!("0992268993F22C640101"); -const EXAMPLE_OID_LARGE_ARC: ObjectIdentifier = - ObjectIdentifier::new_unwrap("0.9.2342.19200300.100.1.1"); - -#[test] -fn from_bytes() { - let oid0 = ObjectIdentifier::from_bytes(EXAMPLE_OID_0_BER).unwrap(); - assert_eq!(oid0.arc(0).unwrap(), 0); - assert_eq!(oid0.arc(1).unwrap(), 9); - assert_eq!(oid0, EXAMPLE_OID_0); - - let oid1 = ObjectIdentifier::from_bytes(EXAMPLE_OID_1_BER).unwrap(); - assert_eq!(oid1.arc(0).unwrap(), 1); - assert_eq!(oid1.arc(1).unwrap(), 2); - assert_eq!(oid1, EXAMPLE_OID_1); - - let oid2 = ObjectIdentifier::from_bytes(EXAMPLE_OID_2_BER).unwrap(); - assert_eq!(oid2.arc(0).unwrap(), 2); - assert_eq!(oid2.arc(1).unwrap(), 16); - assert_eq!(oid2, EXAMPLE_OID_2); - - let oid3 = ObjectIdentifier::from_bytes(EXAMPLE_OID_LARGE_ARC_BER).unwrap(); - assert_eq!(oid3.arc(0).unwrap(), 0); - assert_eq!(oid3.arc(1).unwrap(), 9); - assert_eq!(oid3.arc(2).unwrap(), 2342); - assert_eq!(oid3.arc(3).unwrap(), 19200300); - assert_eq!(oid3.arc(4).unwrap(), 100); - assert_eq!(oid3.arc(5).unwrap(), 1); - assert_eq!(oid3.arc(6).unwrap(), 1); - assert_eq!(oid3, EXAMPLE_OID_LARGE_ARC); - - // Empty - assert_eq!(ObjectIdentifier::from_bytes(&[]), Err(Error::Empty)); - - // Truncated - assert_eq!( - ObjectIdentifier::from_bytes(&[42]), - Err(Error::NotEnoughArcs) - ); - assert_eq!( - ObjectIdentifier::from_bytes(&[42, 134]), - Err(Error::NotEnoughArcs) - ); -} - -#[test] -fn from_str() { - let oid0 = EXAMPLE_OID_0_STR.parse::().unwrap(); - assert_eq!(oid0.arc(0).unwrap(), 0); - assert_eq!(oid0.arc(1).unwrap(), 9); - assert_eq!(oid0, EXAMPLE_OID_0); - - let oid1 = EXAMPLE_OID_1_STR.parse::().unwrap(); - assert_eq!(oid1.arc(0).unwrap(), 1); - assert_eq!(oid1.arc(1).unwrap(), 2); - assert_eq!(oid1, EXAMPLE_OID_1); - - let oid2 = EXAMPLE_OID_2_STR.parse::().unwrap(); - assert_eq!(oid2.arc(0).unwrap(), 2); - assert_eq!(oid2.arc(1).unwrap(), 16); - assert_eq!(oid2, EXAMPLE_OID_2); - - let oid3 = EXAMPLE_OID_LARGE_ARC_STR - .parse::() - .unwrap(); - assert_eq!(oid3.arc(0).unwrap(), 0); - assert_eq!(oid3.arc(1).unwrap(), 9); - assert_eq!(oid3.arc(2).unwrap(), 2342); - assert_eq!(oid3.arc(3).unwrap(), 19200300); - assert_eq!(oid3.arc(4).unwrap(), 100); - assert_eq!(oid3.arc(5).unwrap(), 1); - assert_eq!(oid3.arc(6).unwrap(), 1); - assert_eq!(oid3, EXAMPLE_OID_LARGE_ARC); - - // Too short - assert_eq!("1.2".parse::(), Err(Error::NotEnoughArcs)); - - // Truncated - assert_eq!( - "1.2.840.10045.2.".parse::(), - Err(Error::TrailingDot) - ); - - // Invalid first arc - assert_eq!( - "3.2.840.10045.2.1".parse::(), - Err(Error::ArcInvalid { arc: 3 }) - ); - - // Invalid second arc - assert_eq!( - "1.40.840.10045.2.1".parse::(), - Err(Error::ArcInvalid { arc: 40 }) - ); -} - -#[test] -fn display() { - assert_eq!(EXAMPLE_OID_0.to_string(), EXAMPLE_OID_0_STR); - assert_eq!(EXAMPLE_OID_1.to_string(), EXAMPLE_OID_1_STR); - assert_eq!(EXAMPLE_OID_2.to_string(), EXAMPLE_OID_2_STR); - assert_eq!(EXAMPLE_OID_LARGE_ARC.to_string(), EXAMPLE_OID_LARGE_ARC_STR); -} - -#[test] -fn try_from_u32_slice() { - let oid1 = ObjectIdentifier::from_arcs([1, 2, 840, 10045, 2, 1]).unwrap(); - assert_eq!(oid1.arc(0).unwrap(), 1); - assert_eq!(oid1.arc(1).unwrap(), 2); - assert_eq!(EXAMPLE_OID_1, oid1); - - let oid2 = ObjectIdentifier::from_arcs([2, 16, 840, 1, 101, 3, 4, 1, 42]).unwrap(); - assert_eq!(oid2.arc(0).unwrap(), 2); - assert_eq!(oid2.arc(1).unwrap(), 16); - assert_eq!(EXAMPLE_OID_2, oid2); - - // Too short - assert_eq!( - ObjectIdentifier::from_arcs([1, 2]), - Err(Error::NotEnoughArcs) - ); - - // Invalid first arc - assert_eq!( - ObjectIdentifier::from_arcs([3, 2, 840, 10045, 3, 1, 7]), - Err(Error::ArcInvalid { arc: 3 }) - ); - - // Invalid second arc - assert_eq!( - ObjectIdentifier::from_arcs([1, 40, 840, 10045, 3, 1, 7]), - Err(Error::ArcInvalid { arc: 40 }) - ); -} - -#[test] -fn as_bytes() { - assert_eq!(EXAMPLE_OID_1.as_bytes(), EXAMPLE_OID_1_BER); - assert_eq!(EXAMPLE_OID_2.as_bytes(), EXAMPLE_OID_2_BER); -} - -#[test] -fn parse_empty() { - assert_eq!(ObjectIdentifier::new(""), Err(Error::Empty)); -} - -#[test] -fn parse_not_enough_arcs() { - assert_eq!(ObjectIdentifier::new("1.2"), Err(Error::NotEnoughArcs)); -} - -#[test] -fn parse_invalid_first_arc() { - assert_eq!( - ObjectIdentifier::new("3.2.840.10045.3.1.7"), - Err(Error::ArcInvalid { arc: 3 }) - ); -} - -#[test] -fn parse_invalid_second_arc() { - assert_eq!( - ObjectIdentifier::new("1.40.840.10045.3.1.7"), - Err(Error::ArcInvalid { arc: 40 }) - ); -} - -#[test] -fn parent() { - let oid = ObjectIdentifier::new("1.2.3.4").unwrap(); - let parent = oid.parent().unwrap(); - assert_eq!(parent, ObjectIdentifier::new("1.2.3").unwrap()); - assert_eq!(parent.parent(), None); -} - -#[test] -fn push_arc() { - let oid = ObjectIdentifier::new("1.2.3").unwrap(); - assert_eq!( - oid.push_arc(4).unwrap(), - ObjectIdentifier::new("1.2.3.4").unwrap() - ); -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/.cargo_vcs_info.json deleted file mode 100644 index 073cd348b956..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "9bf880934c350a5af67df17ba12bf8636486f7f9" - }, - "path_in_vcs": "der" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/CHANGELOG.md b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/CHANGELOG.md deleted file mode 100644 index d82e7235dd6d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/CHANGELOG.md +++ /dev/null @@ -1,465 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## 0.7.9 (2024-04-01) -### Changed -- ignore RUSTSEC-2023-0071 (backport [#1276]) -- make sure der is comptatible with potential language breaking changed (backport [#1374]) - -[#1276]: https://github.com/RustCrypto/formats/pull/1276 -[#1374]: https://github.com/RustCrypto/formats/pull/1374 - -## 0.7.8 (2023-08-07) -### Added -- `bytes` feature ([#1156]) -- impl `RefToOwned`/`OwnedToRef` for `&[u8]`/`Box<[u8]>` ([#1188]) -- `BmpString` ([#1164]) - -### Changed -- no-panic cleanup ([#1169]) -- Bump `der_derive` dependency to v0.7.2 ([#1192]) - -[#1156]: https://github.com/RustCrypto/formats/pull/1156 -[#1164]: https://github.com/RustCrypto/formats/pull/1164 -[#1169]: https://github.com/RustCrypto/formats/pull/1169 -[#1188]: https://github.com/RustCrypto/formats/pull/1188 -[#1192]: https://github.com/RustCrypto/formats/pull/1192 - -## 0.7.7 (2023-06-29) -### Added -- `TryFrom` impl for strings based on `StrOwned` ([#1064]) - -[#1064]: https://github.com/RustCrypto/formats/pull/1064 - -## 0.7.6 (2023-05-16) -### Added -- `SetOfVec::{extend, from_iter}` methods ([#1065]) -- `SetOf(Vec)::{insert, insert_ordered}` methods ([#1067]) - -### Changed -- Deprecate `SetOf(Vec)::add` ([#1067]) - -### Fixed -- Off-by-one error in `BMPString` tag ([#1037]) -- Handling of non-unique items in `SetOf`(Vec) ([#1066]) - -[#1037]: https://github.com/RustCrypto/formats/pull/1037 -[#1065]: https://github.com/RustCrypto/formats/pull/1065 -[#1066]: https://github.com/RustCrypto/formats/pull/1066 -[#1067]: https://github.com/RustCrypto/formats/pull/1067 - -## 0.7.5 (2023-04-24) -### Added -- adds support for `DateTime::INFINITY` ([#1026]) - -[#1026]: https://github.com/RustCrypto/formats/pull/1026 - -## 0.7.4 (2023-04-19) -### Added -- `Decode` and `Encode` impls for `PhantomData` ([#1009]) -- `ValueOrd` and `DerOrd` impls for `PhantomData` ([#1012]) - -### Changed -- Bump `hex-literal` dependency to v0.4.1 ([#999]) -- Bump `der_derive` dependency to v0.7.1 ([#1016]) - -[#1009]: https://github.com/RustCrypto/formats/pull/1009 -[#1012]: https://github.com/RustCrypto/formats/pull/1012 -[#1016]: https://github.com/RustCrypto/formats/pull/1016 - -## 0.7.3 (2023-04-06) -### Added -- `UtcTime::MAX_YEAR` associated constant ([#989]) - -[#989]: https://github.com/RustCrypto/formats/pull/989 - -## 0.7.2 (2023-04-04) -### Added -- Expose `NestedReader ([#925]) -- `From` impl for `Any` ([#965]) -- `Any::null` helper ([#969]) -- `Any::encode_from` ([#976]) - -[#925]: https://github.com/RustCrypto/formats/pull/925 -[#965]: https://github.com/RustCrypto/formats/pull/965 -[#969]: https://github.com/RustCrypto/formats/pull/969 -[#976]: https://github.com/RustCrypto/formats/pull/976 - -## 0.7.1 (2023-03-07) -### Changed -- Make `zeroize`'s `alloc` feature conditional ([#920]) - -[#920]: https://github.com/RustCrypto/formats/pull/920 - -## 0.7.0 (2023-02-26) [YANKED] -### Added -- `OwnedtoRef`/`RefToOwned` traits; MSRV 1.65 ([#797]) -- `OctetStringRef::decode_into` ([#817]) -- `Int` and `IntRef` types ([#823]) -- `IndefiniteLength` type ([#830]) -- `Any::value` accessor ([#833]) -- Buffered PEM reader ([#839]) -- `OctetString::into_bytes` ([#845]) -- Blanket impls on `Box` for `DecodeValue`, `EncodeValue`, and `Sequence` ([#860]) - -### Changed -- Rename `UIntRef` => `UintRef` ([#786]) -- Replace use of `dyn Writer` with `impl Writer` ([#828]) -- Rename `AnyRef::decode_into` -> `::decode_as` ([#829]) -- Bump `pem-rfc7468` dependency to v0.7 ([#894]) -- Rename `Encode::to_vec` => `::to_der` ([#898]) - -### Removed -- `Sequence::fields` method ([#828]) -- Inherent `AnyRef` decoding methods ([#829]) - -[#786]: https://github.com/RustCrypto/formats/pull/786 -[#797]: https://github.com/RustCrypto/formats/pull/797 -[#817]: https://github.com/RustCrypto/formats/pull/817 -[#823]: https://github.com/RustCrypto/formats/pull/823 -[#828]: https://github.com/RustCrypto/formats/pull/828 -[#829]: https://github.com/RustCrypto/formats/pull/829 -[#830]: https://github.com/RustCrypto/formats/pull/830 -[#833]: https://github.com/RustCrypto/formats/pull/833 -[#839]: https://github.com/RustCrypto/formats/pull/839 -[#845]: https://github.com/RustCrypto/formats/pull/845 -[#860]: https://github.com/RustCrypto/formats/pull/860 -[#894]: https://github.com/RustCrypto/formats/pull/894 -[#898]: https://github.com/RustCrypto/formats/pull/898 - -## 0.6.1 (2022-12-05) -### Added -- Rudimentary implementation of `TeletexString` and `VideotexString` ([#691]) -- Impl `ValueOrd` for `FlagSet` and `UIntRef` ([#723]) - -### Changed -- Eliminate some boilerplate code by using `Deref` ([#697]) - -[#691]: https://github.com/RustCrypto/formats/pull/691 -[#697]: https://github.com/RustCrypto/formats/pull/697 -[#723]: https://github.com/RustCrypto/formats/pull/723 - -## 0.6.0 (2022-05-08) -### Added -- Impl `ValueOrd` for `SetOf` and `SetOfVec` ([#362]) -- `SequenceRef` type ([#374]) -- Support for `SetOf` sorting on heapless `no_std` targets ([#401]) -- Support for mapping `BitString` to/from a `FlagSet` ([#412]) -- `DecodeOwned` marker trait ([#529]) -- Support for the ASN.1 `REAL` type ([#346]) -- `DecodePem` and `EncodePem` traits ([#571]) -- `Document` and `SecretDocument` types ([#571]) -- `EncodeRef`/`EncodeValueRef` wrapper types ([#604]) -- `Writer` trait ([#605]) -- `Reader` trait ([#606]) -- Streaming on-the-fly `PemReader` and `PemWriter` ([#618], [#636]) -- Owned `BitString` ([#636]) -- Owned `Any` and `OctetString` types ([#640]) - -### Changed -- Pass `Header` to `DecodeValue` ([#392]) -- Bump `const-oid` dependency to v0.9 ([#507]) -- Renamed `Decodable`/`Encodable` => `Decode`/`Encode` ([#523]) -- Enable arithmetic, casting, and panic `clippy` lints ([#556], [#579]) -- Use `&mut dyn Writer` as output for `Encode::encode` and `EncodeValue::encode_value` ([#611]) -- Bump `pem-rfc7468` dependency to v0.6 ([#620]) -- Use `Reader<'a>` as input for `Decode::decode` and `DecodeValue::decode_value` ([#633]) -- Renamed `Any` => `AnyRef` ([#637]) -- Renamed `BitString` => `BitStringRef` ([#637]) -- Renamed `Ia5String` => `Ia5StringRef` ([#637]) -- Renamed `OctetString` => `OctetStringRef` ([#637]) -- Renamed `PrintableString` => `PrintableStringRef` ([#637]) -- Renamed `Utf8String` => `Utf8StringRef` ([#637]) -- Renamed `UIntBytes` => `UIntRef` ([#637]) -- Renamed `Decoder` => `SliceReader` ([#651]) -- Renamed `Encoder` => `SliceWriter` ([#651]) - -### Fixed -- Handling of oversized unsigned `INTEGER` inputs ([#447]) - -### Removed -- `bigint` feature ([#344]) -- `OrdIsValueOrd` trait ([#359]) -- `Document` trait ([#571]) -- `OptionalRef` ([#604]) -- Decode-time SET OF ordering checks ([#625]) - -[#344]: https://github.com/RustCrypto/formats/pull/344 -[#346]: https://github.com/RustCrypto/formats/pull/346 -[#359]: https://github.com/RustCrypto/formats/pull/359 -[#362]: https://github.com/RustCrypto/formats/pull/362 -[#374]: https://github.com/RustCrypto/formats/pull/374 -[#392]: https://github.com/RustCrypto/formats/pull/392 -[#401]: https://github.com/RustCrypto/formats/pull/401 -[#412]: https://github.com/RustCrypto/formats/pull/412 -[#447]: https://github.com/RustCrypto/formats/pull/447 -[#507]: https://github.com/RustCrypto/formats/pull/507 -[#523]: https://github.com/RustCrypto/formats/pull/523 -[#529]: https://github.com/RustCrypto/formats/pull/529 -[#556]: https://github.com/RustCrypto/formats/pull/556 -[#571]: https://github.com/RustCrypto/formats/pull/571 -[#579]: https://github.com/RustCrypto/formats/pull/579 -[#604]: https://github.com/RustCrypto/formats/pull/604 -[#605]: https://github.com/RustCrypto/formats/pull/605 -[#606]: https://github.com/RustCrypto/formats/pull/606 -[#611]: https://github.com/RustCrypto/formats/pull/611 -[#618]: https://github.com/RustCrypto/formats/pull/618 -[#620]: https://github.com/RustCrypto/formats/pull/620 -[#625]: https://github.com/RustCrypto/formats/pull/625 -[#633]: https://github.com/RustCrypto/formats/pull/633 -[#636]: https://github.com/RustCrypto/formats/pull/636 -[#637]: https://github.com/RustCrypto/formats/pull/637 -[#640]: https://github.com/RustCrypto/formats/pull/640 -[#651]: https://github.com/RustCrypto/formats/pull/651 - -## 0.5.1 (2021-11-17) -### Added -- `Any::NULL` constant ([#226]) - -[#226]: https://github.com/RustCrypto/formats/pull/226 - -## 0.5.0 (2021-11-15) [YANKED] -### Added -- Support for `IMPLICIT` mode `CONTEXT-SPECIFIC` fields ([#61]) -- `DecodeValue`/`EncodeValue` traits ([#63]) -- Expose `DateTime` through public API ([#75]) -- `SEQUENCE OF` support for `[T; N]` ([#90]) -- `SequenceOf` type ([#95]) -- `SEQUENCE OF` support for `Vec` ([#96]) -- `Document` trait ([#117]) -- Basic integration with `time` crate ([#129]) -- `Tag::NumericString` ([#132]) -- Support for unused bits to `BitString` ([#141]) -- `Decoder::{peek_tag, peek_header}` ([#142]) -- Type hint in `encoder `sequence` method ([#147]) -- `Tag::Enumerated` ([#153]) -- `ErrorKind::TagNumberInvalid` ([#156]) -- `Tag::VisibleString` and `Tag::BmpString` ([#160]) -- Inherent constants for all valid `TagNumber`s ([#165]) -- `DerOrd` and `ValueOrd` traits ([#190]) -- `ContextSpecificRef` type ([#199]) - -### Changed -- Make `ContextSpecific` generic around an inner type ([#60]) -- Removed `SetOf` trait; rename `SetOfArray` => `SetOf` ([#97]) -- Rename `Message` trait to `Sequence` ([#99]) -- Make `GeneralizedTime`/`UtcTime` into `DateTime` newtypes ([#102]) -- Rust 2021 edition upgrade; MSRV 1.56 ([#136]) -- Replace `ErrorKind::Truncated` with `ErrorKind::Incomplete` ([#143]) -- Rename `ErrorKind::UnknownTagMode` => `ErrorKind::TagModeUnknown` ([#155]) -- Rename `ErrorKind::UnexpectedTag` => `ErrorKind::TagUnexpected` ([#155]) -- Rename `ErrorKind::UnknownTag` => `ErrorKind::TagUnknown` ([#155]) -- Consolidate `ErrorKind::{Incomplete, Underlength}` ([#157]) -- Rename `Tagged` => `FixedTag`; add new `Tagged` trait ([#189]) -- Use `DerOrd` for `SetOf*` types ([#200]) -- Switch `impl From for &[u8]` to `TryFrom` ([#203]) -- Bump `crypto-bigint` dependency to v0.3 ([#215]) -- Bump `const-oid` dependency to v0.7 ([#216]) -- Bump `pem-rfc7468` dependency to v0.3 ([#217]) -- Bump `der_derive` dependency to v0.5 ([#221]) - -### Removed -- `Sequence` struct ([#98]) -- `Tagged` bound on `ContextSpecific::decode_implicit` ([#161]) -- `ErrorKind::DuplicateField` ([#162]) - -[#60]: https://github.com/RustCrypto/formats/pull/60 -[#61]: https://github.com/RustCrypto/formats/pull/61 -[#63]: https://github.com/RustCrypto/formats/pull/63 -[#75]: https://github.com/RustCrypto/formats/pull/75 -[#90]: https://github.com/RustCrypto/formats/pull/90 -[#95]: https://github.com/RustCrypto/formats/pull/95 -[#96]: https://github.com/RustCrypto/formats/pull/96 -[#97]: https://github.com/RustCrypto/formats/pull/97 -[#98]: https://github.com/RustCrypto/formats/pull/98 -[#99]: https://github.com/RustCrypto/formats/pull/99 -[#102]: https://github.com/RustCrypto/formats/pull/102 -[#117]: https://github.com/RustCrypto/formats/pull/117 -[#129]: https://github.com/RustCrypto/formats/pull/129 -[#132]: https://github.com/RustCrypto/formats/pull/132 -[#136]: https://github.com/RustCrypto/formats/pull/136 -[#141]: https://github.com/RustCrypto/formats/pull/141 -[#142]: https://github.com/RustCrypto/formats/pull/142 -[#143]: https://github.com/RustCrypto/formats/pull/143 -[#147]: https://github.com/RustCrypto/formats/pull/147 -[#153]: https://github.com/RustCrypto/formats/pull/153 -[#155]: https://github.com/RustCrypto/formats/pull/155 -[#156]: https://github.com/RustCrypto/formats/pull/156 -[#157]: https://github.com/RustCrypto/formats/pull/157 -[#160]: https://github.com/RustCrypto/formats/pull/160 -[#161]: https://github.com/RustCrypto/formats/pull/161 -[#162]: https://github.com/RustCrypto/formats/pull/162 -[#165]: https://github.com/RustCrypto/formats/pull/165 -[#189]: https://github.com/RustCrypto/formats/pull/189 -[#190]: https://github.com/RustCrypto/formats/pull/190 -[#199]: https://github.com/RustCrypto/formats/pull/199 -[#200]: https://github.com/RustCrypto/formats/pull/200 -[#203]: https://github.com/RustCrypto/formats/pull/203 -[#215]: https://github.com/RustCrypto/formats/pull/215 -[#216]: https://github.com/RustCrypto/formats/pull/216 -[#217]: https://github.com/RustCrypto/formats/pull/217 -[#221]: https://github.com/RustCrypto/formats/pull/221 - -## 0.4.5 (2021-12-01) -### Fixed -- Backport [#147] type hint fix for WASM platforms to 0.4.x - -## 0.4.4 (2021-10-06) -### Removed -- Accidentally checked-in `target/` directory ([#66]) - -[#66]: https://github.com/RustCrypto/formats/pull/66 - -## 0.4.3 (2021-09-15) -### Added -- `Tag::unexpected_error` ([#33]) - -[#33]: https://github.com/RustCrypto/formats/pull/33 - -## 0.4.2 (2021-09-14) -### Changed -- Moved to `formats` repo ([#2]) - -### Fixed -- ASN.1 `SET` type now flagged with the constructed bit - -[#2]: https://github.com/RustCrypto/formats/pull/2 - -## 0.4.1 (2021-08-08) -### Fixed -- Encoding `UTCTime` for dates with `20xx` years - -## 0.4.0 (2021-06-07) -### Added -- `TagNumber` type -- Const generic integer de/encoders with support for all of Rust's integer - primitives -- `crypto-bigint` support -- `Tag` number helpers -- `Tag::octet` -- `ErrorKind::Value` helpers -- `SequenceIter` - -### Changed -- Bump `const-oid` crate dependency to v0.6 -- Make `Tag` structured -- Namespace ASN.1 types in `asn1` module -- Refactor context-specific field decoding -- MSRV 1.51 -- Rename `big-uint` crate feature to `bigint` -- Rename `BigUInt` to `UIntBytes` -- Have `Decoder::error()` return an `Error` - -### Removed -- Deprecated methods replaced by associated constants - -## 0.3.5 (2021-05-24) -### Added -- Helper methods for context-specific fields -- `ContextSpecific` field wrapper -- Decoder position tracking for errors during `Any<'a>` decoding - -### Fixed -- `From` conversion for `BitString` into `Any` - -## 0.3.4 (2021-05-16) -### Changed -- Support `Length` of up to 1 MiB - -## 0.3.3 (2021-04-15) -### Added -- `Length` constants - -### Changed -- Deprecate `const fn` methods replaced by `Length` constants - -## 0.3.2 (2021-04-15) -### Fixed -- Non-critical bug allowing `Length` to exceed the max invariant - -## 0.3.1 (2021-04-01) [YANKED] -### Added -- `PartialOrd` + `Ord` impls to all ASN.1 types - -## 0.3.0 (2021-03-22) [YANKED] -### Added -- Impl `Decode`/`Encoded`/`Tagged` for `String` -- `Length::one` and `Length::for_tlv` -- `SET OF` support with `SetOf` trait and `SetOfRef` - -### Changed -- Rename `Decodable::from_bytes` => `Decodable::from_der` -- Separate `sequence` and `message` -- Rename `ErrorKind::Oid` => `ErrorKind::MalformedOid` -- Auto-derive `From` impls for variants when deriving `Choice` -- Make `Length` use `u32` internally -- Make `Sequence` constructor private -- Bump `const_oid` to v0.5 -- Bump `der_derive` to v0.3 - -### Removed -- Deprecated methods -- `BigUIntSize` - -## 0.2.10 (2021-02-28) -### Added -- Impl `From` for `Any` - -### Changed -- Bump minimum `const-oid` dependency to v0.4.4 - -## 0.2.9 (2021-02-24) -### Added -- Support for `IA5String` - -## 0.2.8 (2021-02-22) -### Added -- `Choice` trait - -## 0.2.7 (2021-02-20) -### Added -- Export `Header` publicly -- Make `Encoder::reserve` public - -## 0.2.6 (2021-02-19) -### Added -- Make the unit type an encoding of `NULL` - -## 0.2.5 (2021-02-18) -### Added -- `ErrorKind::UnknownOid` variant - -## 0.2.4 (2021-02-16) -### Added -- `Any::is_null` method - -### Changed -- Deprecate `Any::null` method - -## 0.2.3 (2021-02-15) -### Added -- Additional `rustdoc` documentation - -## 0.2.2 (2021-02-12) -### Added -- Support for `UTCTime` and `GeneralizedTime` - -## 0.2.1 (2021-02-02) -### Added -- Support for `PrintableString` and `Utf8String` - -## 0.2.0 (2021-01-22) -### Added -- `BigUInt` type -- `i16` support -- `u8` and `u16` support -- Integer decoder helper methods - -### Fixed -- Handle leading byte of `BIT STRING`s - -## 0.1.0 (2020-12-21) -- Initial release diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/Cargo.toml deleted file mode 100644 index 027b88a6e5a7..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/Cargo.toml +++ /dev/null @@ -1,109 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -rust-version = "1.65" -name = "der" -version = "0.7.9" -authors = ["RustCrypto Developers"] -description = """ -Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules -(DER) for Abstract Syntax Notation One (ASN.1) as described in ITU X.690 with -full support for heapless no_std targets -""" -readme = "README.md" -keywords = [ - "asn1", - "crypto", - "itu", - "pkcs", -] -categories = [ - "cryptography", - "data-structures", - "encoding", - "no-std", - "parser-implementations", -] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/formats/tree/master/der" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = [ - "--cfg", - "docsrs", -] - -[dependencies.arbitrary] -version = "1.3" -features = ["derive"] -optional = true - -[dependencies.bytes] -version = "1" -optional = true -default-features = false - -[dependencies.const-oid] -version = "0.9.2" -optional = true - -[dependencies.der_derive] -version = "0.7.2" -optional = true - -[dependencies.flagset] -version = "0.4.3" -optional = true - -[dependencies.pem-rfc7468] -version = "0.7" -features = ["alloc"] -optional = true - -[dependencies.time] -version = "0.3.4" -optional = true -default-features = false - -[dependencies.zeroize] -version = "1.5" -optional = true -default-features = false - -[dev-dependencies.hex-literal] -version = "0.4.1" - -[dev-dependencies.proptest] -version = "1" - -[features] -alloc = ["zeroize?/alloc"] -arbitrary = [ - "dep:arbitrary", - "const-oid?/arbitrary", - "std", -] -bytes = [ - "dep:bytes", - "alloc", -] -derive = ["dep:der_derive"] -oid = ["dep:const-oid"] -pem = [ - "dep:pem-rfc7468", - "alloc", - "zeroize", -] -real = [] -std = ["alloc"] diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/Cargo.toml.orig deleted file mode 100644 index 4233b40a3b44..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/Cargo.toml.orig +++ /dev/null @@ -1,45 +0,0 @@ -[package] -name = "der" -version = "0.7.9" -description = """ -Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules -(DER) for Abstract Syntax Notation One (ASN.1) as described in ITU X.690 with -full support for heapless no_std targets -""" -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/formats/tree/master/der" -categories = ["cryptography", "data-structures", "encoding", "no-std", "parser-implementations"] -keywords = ["asn1", "crypto", "itu", "pkcs"] -readme = "README.md" -edition = "2021" -rust-version = "1.65" - -[dependencies] -arbitrary = { version = "1.3", features = ["derive"], optional = true } -bytes = { version = "1", optional = true, default-features = false } -const-oid = { version = "0.9.2", optional = true } -der_derive = { version = "0.7.2", optional = true } -flagset = { version = "0.4.3", optional = true } -pem-rfc7468 = { version = "0.7", optional = true, features = ["alloc"] } -time = { version = "0.3.4", optional = true, default-features = false } -zeroize = { version = "1.5", optional = true, default-features = false } - -[dev-dependencies] -hex-literal = "0.4.1" -proptest = "1" - -[features] -alloc = ["zeroize?/alloc"] -std = ["alloc"] - -arbitrary = ["dep:arbitrary", "const-oid?/arbitrary", "std"] -bytes = ["dep:bytes", "alloc"] -derive = ["dep:der_derive"] -oid = ["dep:const-oid"] -pem = ["dep:pem-rfc7468", "alloc", "zeroize"] -real = [] - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-APACHE b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-APACHE deleted file mode 100644 index 78173fa2e753..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - 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. diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-MIT b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-MIT deleted file mode 100644 index e0d082780149..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2020-2023 The RustCrypto Project Developers - -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. diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/README.md b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/README.md deleted file mode 100644 index f13053ffe613..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/README.md +++ /dev/null @@ -1,96 +0,0 @@ -# [RustCrypto]: ASN.1 DER - -[![Crate][crate-image]][crate-link] -[![Docs][docs-image]][docs-link] -[![Build Status][build-image]][build-link] -![Apache2/MIT licensed][license-image] -![Rust Version][rustc-image] -[![Project Chat][chat-image]][chat-link] - -Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules (DER) -for Abstract Syntax Notation One (ASN.1) as described in ITU X.690. - -[Documentation][docs-link] - -## About - -This crate provides a `no_std`-friendly implementation of a subset of ASN.1 DER -necessary for decoding/encoding the following cryptography-related formats -implemented as crates maintained by the [RustCrypto] project: - -- [`pkcs1`]: RSA Cryptography Specifications -- [`pkcs5`]: Password-Based Cryptography Specification -- [`pkcs7`]: Cryptographic Message Syntax -- [`pkcs8`]: Private-Key Information Syntax Specification -- [`pkcs10`]: Certification Request Syntax Specification -- [`sec1`]: Elliptic Curve Cryptography -- [`spki`]: X.509 Subject Public Key Info -- [`x501`]: Directory Services Types -- [`x509`]: Public Key Infrastructure Certificate - -The core implementation avoids any heap usage (with convenience methods -that allocate gated under the off-by-default `alloc` feature). - -The DER decoder in this crate performs checks to ensure that the input document -is in canonical form, and will return errors if non-canonical productions are -encountered. There is currently no way to disable these checks. - -### Features - -- Rich support for ASN.1 types used by PKCS/PKIX documents -- Performs DER canonicalization checks at decoding time -- `no_std` friendly: supports "heapless" usage -- Optionally supports `alloc` and `std` if desired -- No hard dependencies! Self-contained implementation with optional - integrations with the following crates, all of which are `no_std` friendly: - - `const-oid`: const-friendly OID implementation - - `pem-rfc7468`: PKCS/PKIX-flavored PEM library with constant-time decoder/encoders - - `time` crate: date/time library - -## Minimum Supported Rust Version - -This crate requires **Rust 1.65** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - -## License - -Licensed under either of: - - * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) - * [MIT license](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. - -[//]: # (badges) - -[crate-image]: https://buildstats.info/crate/der -[crate-link]: https://crates.io/crates/der -[docs-image]: https://docs.rs/der/badge.svg -[docs-link]: https://docs.rs/der/ -[build-image]: https://github.com/RustCrypto/formats/actions/workflows/der.yml/badge.svg -[build-link]: https://github.com/RustCrypto/formats/actions/workflows/der.yml -[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.65+-blue.svg -[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg -[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/300570-formats - -[//]: # (links) - -[RustCrypto]: https://github.com/rustcrypto -[`pkcs1`]: https://github.com/RustCrypto/formats/tree/master/pkcs1 -[`pkcs5`]: https://github.com/RustCrypto/formats/tree/master/pkcs5 -[`pkcs7`]: https://github.com/RustCrypto/formats/tree/master/pkcs7 -[`pkcs8`]: https://github.com/RustCrypto/formats/tree/master/pkcs8 -[`pkcs10`]: https://github.com/RustCrypto/formats/tree/master/pkcs10 -[`sec1`]: https://github.com/RustCrypto/formats/tree/master/sec1 -[`spki`]: https://github.com/RustCrypto/formats/tree/master/spki -[`x501`]: https://github.com/RustCrypto/formats/tree/master/x501 -[`x509`]: https://github.com/RustCrypto/formats/tree/master/x509 diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/arrayvec.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/arrayvec.rs deleted file mode 100644 index 6ce608d97c9c..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/arrayvec.rs +++ /dev/null @@ -1,145 +0,0 @@ -//! Array-backed append-only vector type. -// TODO(tarcieri): use `core` impl of `ArrayVec` -// See: https://github.com/rust-lang/rfcs/pull/2990 - -use crate::{ErrorKind, Result}; - -/// Array-backed append-only vector type. -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub(crate) struct ArrayVec { - /// Elements of the set. - elements: [Option; N], - - /// Last populated element. - length: usize, -} - -impl ArrayVec { - /// Create a new [`ArrayVec`]. - pub fn new() -> Self { - Self { - elements: [(); N].map(|_| None), - length: 0, - } - } - - /// Push an item into this [`ArrayVec`]. - pub fn push(&mut self, item: T) -> Result<()> { - match self.length.checked_add(1) { - Some(n) if n <= N => { - self.elements[self.length] = Some(item); - self.length = n; - Ok(()) - } - _ => Err(ErrorKind::Overlength.into()), - } - } - - /// Get an element from this [`ArrayVec`]. - pub fn get(&self, index: usize) -> Option<&T> { - match self.elements.get(index) { - Some(Some(ref item)) => Some(item), - _ => None, - } - } - - /// Iterate over the elements in this [`ArrayVec`]. - pub fn iter(&self) -> Iter<'_, T> { - Iter::new(&self.elements) - } - - /// Is this [`ArrayVec`] empty? - pub fn is_empty(&self) -> bool { - self.length == 0 - } - - /// Get the number of elements in this [`ArrayVec`]. - pub fn len(&self) -> usize { - self.length - } - - /// Get the last item from this [`ArrayVec`]. - pub fn last(&self) -> Option<&T> { - self.length.checked_sub(1).and_then(|n| self.get(n)) - } - - /// Extract the inner array. - pub fn into_array(self) -> [Option; N] { - self.elements - } -} - -impl AsRef<[Option]> for ArrayVec { - fn as_ref(&self) -> &[Option] { - &self.elements[..self.length] - } -} - -impl AsMut<[Option]> for ArrayVec { - fn as_mut(&mut self) -> &mut [Option] { - &mut self.elements[..self.length] - } -} - -impl Default for ArrayVec { - fn default() -> Self { - Self::new() - } -} - -/// Iterator over the elements of an [`ArrayVec`]. -#[derive(Clone, Debug)] -pub struct Iter<'a, T> { - /// Decoder which iterates over the elements of the message. - elements: &'a [Option], - - /// Position within the iterator. - position: usize, -} - -impl<'a, T> Iter<'a, T> { - pub(crate) fn new(elements: &'a [Option]) -> Self { - Self { - elements, - position: 0, - } - } -} - -impl<'a, T> Iterator for Iter<'a, T> { - type Item = &'a T; - - fn next(&mut self) -> Option<&'a T> { - match self.elements.get(self.position) { - Some(Some(res)) => { - self.position = self.position.checked_add(1)?; - Some(res) - } - _ => None, - } - } - - fn size_hint(&self) -> (usize, Option) { - let len = self.elements.len().saturating_sub(self.position); - (len, Some(len)) - } -} - -impl<'a, T> ExactSizeIterator for Iter<'a, T> {} - -#[cfg(test)] -mod tests { - use super::ArrayVec; - use crate::ErrorKind; - - #[test] - fn add() { - let mut vec = ArrayVec::::new(); - vec.push(1).unwrap(); - vec.push(2).unwrap(); - vec.push(3).unwrap(); - - assert_eq!(vec.push(4).err().unwrap(), ErrorKind::Overlength.into()); - assert_eq!(vec.len(), 3); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1.rs deleted file mode 100644 index b04b1b58f54d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1.rs +++ /dev/null @@ -1,67 +0,0 @@ -//! Module containing all of the various ASN.1 built-in types supported by -//! this library. - -#[macro_use] -mod internal_macros; - -mod any; -mod bit_string; -#[cfg(feature = "alloc")] -mod bmp_string; -mod boolean; -mod choice; -mod context_specific; -mod generalized_time; -mod ia5_string; -mod integer; -mod null; -mod octet_string; -#[cfg(feature = "oid")] -mod oid; -mod optional; -mod printable_string; -#[cfg(feature = "real")] -mod real; -mod sequence; -mod sequence_of; -mod set_of; -mod teletex_string; -mod utc_time; -mod utf8_string; -mod videotex_string; - -pub use self::{ - any::AnyRef, - bit_string::{BitStringIter, BitStringRef}, - choice::Choice, - context_specific::{ContextSpecific, ContextSpecificRef}, - generalized_time::GeneralizedTime, - ia5_string::Ia5StringRef, - integer::{int::IntRef, uint::UintRef}, - null::Null, - octet_string::OctetStringRef, - printable_string::PrintableStringRef, - sequence::{Sequence, SequenceRef}, - sequence_of::{SequenceOf, SequenceOfIter}, - set_of::{SetOf, SetOfIter}, - teletex_string::TeletexStringRef, - utc_time::UtcTime, - utf8_string::Utf8StringRef, - videotex_string::VideotexStringRef, -}; - -#[cfg(feature = "alloc")] -pub use self::{ - any::Any, - bit_string::BitString, - bmp_string::BmpString, - ia5_string::Ia5String, - integer::{int::Int, uint::Uint}, - octet_string::OctetString, - printable_string::PrintableString, - set_of::SetOfVec, - teletex_string::TeletexString, -}; - -#[cfg(feature = "oid")] -pub use const_oid::ObjectIdentifier; diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/any.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/any.rs deleted file mode 100644 index 017a90908229..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/any.rs +++ /dev/null @@ -1,315 +0,0 @@ -//! ASN.1 `ANY` type. - -#![cfg_attr(feature = "arbitrary", allow(clippy::integer_arithmetic))] - -use crate::{ - BytesRef, Choice, Decode, DecodeValue, DerOrd, EncodeValue, Error, ErrorKind, Header, Length, - Reader, Result, SliceReader, Tag, Tagged, ValueOrd, Writer, -}; -use core::cmp::Ordering; - -#[cfg(feature = "alloc")] -use crate::SliceWriter; - -/// ASN.1 `ANY`: represents any explicitly tagged ASN.1 value. -/// -/// This is a zero-copy reference type which borrows from the input data. -/// -/// Technically `ANY` hasn't been a recommended part of ASN.1 since the X.209 -/// revision from 1988. It was deprecated and replaced by Information Object -/// Classes in X.680 in 1994, and X.690 no longer refers to it whatsoever. -/// -/// Nevertheless, this crate defines an `ANY` type as it remains a familiar -/// and useful concept which is still extensively used in things like -/// PKI-related RFCs. -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct AnyRef<'a> { - /// Tag representing the type of the encoded value. - tag: Tag, - - /// Inner value encoded as bytes. - value: BytesRef<'a>, -} - -impl<'a> AnyRef<'a> { - /// [`AnyRef`] representation of the ASN.1 `NULL` type. - pub const NULL: Self = Self { - tag: Tag::Null, - value: BytesRef::EMPTY, - }; - - /// Create a new [`AnyRef`] from the provided [`Tag`] and DER bytes. - pub fn new(tag: Tag, bytes: &'a [u8]) -> Result { - let value = BytesRef::new(bytes).map_err(|_| ErrorKind::Length { tag })?; - Ok(Self { tag, value }) - } - - /// Infallible creation of an [`AnyRef`] from a [`BytesRef`]. - pub(crate) fn from_tag_and_value(tag: Tag, value: BytesRef<'a>) -> Self { - Self { tag, value } - } - - /// Get the raw value for this [`AnyRef`] type as a byte slice. - pub fn value(self) -> &'a [u8] { - self.value.as_slice() - } - - /// Attempt to decode this [`AnyRef`] type into the inner value. - pub fn decode_as(self) -> Result - where - T: Choice<'a> + DecodeValue<'a>, - { - if !T::can_decode(self.tag) { - return Err(self.tag.unexpected_error(None)); - } - - let header = Header { - tag: self.tag, - length: self.value.len(), - }; - - let mut decoder = SliceReader::new(self.value())?; - let result = T::decode_value(&mut decoder, header)?; - decoder.finish(result) - } - - /// Is this value an ASN.1 `NULL` value? - pub fn is_null(self) -> bool { - self == Self::NULL - } - - /// Attempt to decode this value an ASN.1 `SEQUENCE`, creating a new - /// nested reader and calling the provided argument with it. - pub fn sequence(self, f: F) -> Result - where - F: FnOnce(&mut SliceReader<'a>) -> Result, - { - self.tag.assert_eq(Tag::Sequence)?; - let mut reader = SliceReader::new(self.value.as_slice())?; - let result = f(&mut reader)?; - reader.finish(result) - } -} - -impl<'a> Choice<'a> for AnyRef<'a> { - fn can_decode(_: Tag) -> bool { - true - } -} - -impl<'a> Decode<'a> for AnyRef<'a> { - fn decode>(reader: &mut R) -> Result> { - let header = Header::decode(reader)?; - Self::decode_value(reader, header) - } -} - -impl<'a> DecodeValue<'a> for AnyRef<'a> { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Ok(Self { - tag: header.tag, - value: BytesRef::decode_value(reader, header)?, - }) - } -} - -impl EncodeValue for AnyRef<'_> { - fn value_len(&self) -> Result { - Ok(self.value.len()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.value()) - } -} - -impl Tagged for AnyRef<'_> { - fn tag(&self) -> Tag { - self.tag - } -} - -impl ValueOrd for AnyRef<'_> { - fn value_cmp(&self, other: &Self) -> Result { - self.value.der_cmp(&other.value) - } -} - -impl<'a> From> for BytesRef<'a> { - fn from(any: AnyRef<'a>) -> BytesRef<'a> { - any.value - } -} - -impl<'a> TryFrom<&'a [u8]> for AnyRef<'a> { - type Error = Error; - - fn try_from(bytes: &'a [u8]) -> Result> { - AnyRef::from_der(bytes) - } -} - -#[cfg(feature = "alloc")] -pub use self::allocating::Any; - -#[cfg(feature = "alloc")] -mod allocating { - use super::*; - use crate::{referenced::*, BytesOwned}; - use alloc::boxed::Box; - - /// ASN.1 `ANY`: represents any explicitly tagged ASN.1 value. - /// - /// This type provides the same functionality as [`AnyRef`] but owns the - /// backing data. - #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] - #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] - pub struct Any { - /// Tag representing the type of the encoded value. - tag: Tag, - - /// Inner value encoded as bytes. - value: BytesOwned, - } - - impl Any { - /// Create a new [`Any`] from the provided [`Tag`] and DER bytes. - pub fn new(tag: Tag, bytes: impl Into>) -> Result { - let value = BytesOwned::new(bytes)?; - - // Ensure the tag and value are a valid `AnyRef`. - AnyRef::new(tag, value.as_slice())?; - Ok(Self { tag, value }) - } - - /// Allow access to value - pub fn value(&self) -> &[u8] { - self.value.as_slice() - } - - /// Attempt to decode this [`Any`] type into the inner value. - pub fn decode_as<'a, T>(&'a self) -> Result - where - T: Choice<'a> + DecodeValue<'a>, - { - AnyRef::from(self).decode_as() - } - - /// Encode the provided type as an [`Any`] value. - pub fn encode_from(msg: &T) -> Result - where - T: Tagged + EncodeValue, - { - let encoded_len = usize::try_from(msg.value_len()?)?; - let mut buf = vec![0u8; encoded_len]; - let mut writer = SliceWriter::new(&mut buf); - msg.encode_value(&mut writer)?; - writer.finish()?; - Any::new(msg.tag(), buf) - } - - /// Attempt to decode this value an ASN.1 `SEQUENCE`, creating a new - /// nested reader and calling the provided argument with it. - pub fn sequence<'a, F, T>(&'a self, f: F) -> Result - where - F: FnOnce(&mut SliceReader<'a>) -> Result, - { - AnyRef::from(self).sequence(f) - } - - /// [`Any`] representation of the ASN.1 `NULL` type. - pub fn null() -> Self { - Self { - tag: Tag::Null, - value: BytesOwned::default(), - } - } - } - - impl Choice<'_> for Any { - fn can_decode(_: Tag) -> bool { - true - } - } - - impl<'a> Decode<'a> for Any { - fn decode>(reader: &mut R) -> Result { - let header = Header::decode(reader)?; - Self::decode_value(reader, header) - } - } - - impl<'a> DecodeValue<'a> for Any { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let value = reader.read_vec(header.length)?; - Self::new(header.tag, value) - } - } - - impl EncodeValue for Any { - fn value_len(&self) -> Result { - Ok(self.value.len()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.value.as_slice()) - } - } - - impl<'a> From<&'a Any> for AnyRef<'a> { - fn from(any: &'a Any) -> AnyRef<'a> { - // Ensured to parse successfully in constructor - AnyRef::new(any.tag, any.value.as_slice()).expect("invalid ANY") - } - } - - impl Tagged for Any { - fn tag(&self) -> Tag { - self.tag - } - } - - impl ValueOrd for Any { - fn value_cmp(&self, other: &Self) -> Result { - self.value.der_cmp(&other.value) - } - } - - impl<'a, T> From for Any - where - T: Into>, - { - fn from(input: T) -> Any { - let anyref: AnyRef<'a> = input.into(); - Self { - tag: anyref.tag(), - value: BytesOwned::from(anyref.value), - } - } - } - - impl<'a> RefToOwned<'a> for AnyRef<'a> { - type Owned = Any; - fn ref_to_owned(&self) -> Self::Owned { - Any { - tag: self.tag(), - value: BytesOwned::from(self.value), - } - } - } - - impl OwnedToRef for Any { - type Borrowed<'a> = AnyRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - self.into() - } - } - - impl Any { - /// Is this value an ASN.1 `NULL` value? - pub fn is_null(&self) -> bool { - self.owned_to_ref() == AnyRef::NULL - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bit_string.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bit_string.rs deleted file mode 100644 index bf3371c40980..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bit_string.rs +++ /dev/null @@ -1,552 +0,0 @@ -//! ASN.1 `BIT STRING` support. - -use crate::{ - BytesRef, DecodeValue, DerOrd, EncodeValue, Error, ErrorKind, FixedTag, Header, Length, Reader, - Result, Tag, ValueOrd, Writer, -}; -use core::{cmp::Ordering, iter::FusedIterator}; - -/// ASN.1 `BIT STRING` type. -/// -/// This type contains a sequence of any number of bits, modeled internally as -/// a sequence of bytes with a known number of "unused bits". -/// -/// This is a zero-copy reference type which borrows from the input data. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct BitStringRef<'a> { - /// Number of unused bits in the final octet. - unused_bits: u8, - - /// Length of this `BIT STRING` in bits. - bit_length: usize, - - /// Bitstring represented as a slice of bytes. - inner: BytesRef<'a>, -} - -impl<'a> BitStringRef<'a> { - /// Maximum number of unused bits allowed. - pub const MAX_UNUSED_BITS: u8 = 7; - - /// Create a new ASN.1 `BIT STRING` from a byte slice. - /// - /// Accepts an optional number of "unused bits" (0-7) which are omitted - /// from the final octet. This number is 0 if the value is octet-aligned. - pub fn new(unused_bits: u8, bytes: &'a [u8]) -> Result { - if (unused_bits > Self::MAX_UNUSED_BITS) || (unused_bits != 0 && bytes.is_empty()) { - return Err(Self::TAG.value_error()); - } - - let inner = BytesRef::new(bytes).map_err(|_| Self::TAG.length_error())?; - - let bit_length = usize::try_from(inner.len())? - .checked_mul(8) - .and_then(|n| n.checked_sub(usize::from(unused_bits))) - .ok_or(ErrorKind::Overflow)?; - - Ok(Self { - unused_bits, - bit_length, - inner, - }) - } - - /// Create a new ASN.1 `BIT STRING` from the given bytes. - /// - /// The "unused bits" are set to 0. - pub fn from_bytes(bytes: &'a [u8]) -> Result { - Self::new(0, bytes) - } - - /// Get the number of unused bits in this byte slice. - pub fn unused_bits(&self) -> u8 { - self.unused_bits - } - - /// Is the number of unused bits a value other than 0? - pub fn has_unused_bits(&self) -> bool { - self.unused_bits != 0 - } - - /// Get the length of this `BIT STRING` in bits. - pub fn bit_len(&self) -> usize { - self.bit_length - } - - /// Get the number of bytes/octets needed to represent this `BIT STRING` - /// when serialized in an octet-aligned manner. - pub fn byte_len(&self) -> Length { - self.inner.len() - } - - /// Is the inner byte slice empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - /// Borrow the inner byte slice. - /// - /// Returns `None` if the number of unused bits is *not* equal to zero, - /// i.e. if the `BIT STRING` is not octet aligned. - /// - /// Use [`BitString::raw_bytes`] to obtain access to the raw value - /// regardless of the presence of unused bits. - pub fn as_bytes(&self) -> Option<&'a [u8]> { - if self.has_unused_bits() { - None - } else { - Some(self.raw_bytes()) - } - } - - /// Borrow the raw bytes of this `BIT STRING`. - /// - /// Note that the byte string may contain extra unused bits in the final - /// octet. If the number of unused bits is expected to be 0, the - /// [`BitStringRef::as_bytes`] function can be used instead. - pub fn raw_bytes(&self) -> &'a [u8] { - self.inner.as_slice() - } - - /// Iterator over the bits of this `BIT STRING`. - pub fn bits(self) -> BitStringIter<'a> { - BitStringIter { - bit_string: self, - position: 0, - } - } -} - -impl_any_conversions!(BitStringRef<'a>, 'a); - -impl<'a> DecodeValue<'a> for BitStringRef<'a> { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let header = Header { - tag: header.tag, - length: (header.length - Length::ONE)?, - }; - - let unused_bits = reader.read_byte()?; - let inner = BytesRef::decode_value(reader, header)?; - Self::new(unused_bits, inner.as_slice()) - } -} - -impl EncodeValue for BitStringRef<'_> { - fn value_len(&self) -> Result { - self.byte_len() + Length::ONE - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write_byte(self.unused_bits)?; - writer.write(self.raw_bytes()) - } -} - -impl ValueOrd for BitStringRef<'_> { - fn value_cmp(&self, other: &Self) -> Result { - match self.unused_bits.cmp(&other.unused_bits) { - Ordering::Equal => self.inner.der_cmp(&other.inner), - ordering => Ok(ordering), - } - } -} - -impl<'a> From<&BitStringRef<'a>> for BitStringRef<'a> { - fn from(value: &BitStringRef<'a>) -> BitStringRef<'a> { - *value - } -} - -impl<'a> TryFrom<&'a [u8]> for BitStringRef<'a> { - type Error = Error; - - fn try_from(bytes: &'a [u8]) -> Result> { - BitStringRef::from_bytes(bytes) - } -} - -/// Hack for simplifying the custom derive use case. -impl<'a> TryFrom<&&'a [u8]> for BitStringRef<'a> { - type Error = Error; - - fn try_from(bytes: &&'a [u8]) -> Result> { - BitStringRef::from_bytes(bytes) - } -} - -impl<'a> TryFrom> for &'a [u8] { - type Error = Error; - - fn try_from(bit_string: BitStringRef<'a>) -> Result<&'a [u8]> { - bit_string - .as_bytes() - .ok_or_else(|| Tag::BitString.value_error()) - } -} - -impl<'a> FixedTag for BitStringRef<'a> { - const TAG: Tag = Tag::BitString; -} - -// Implement by hand because the derive would create invalid values. -// Use the constructor to create a valid value. -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for BitStringRef<'a> { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - Self::new( - u.int_in_range(0..=Self::MAX_UNUSED_BITS)?, - BytesRef::arbitrary(u)?.as_slice(), - ) - .map_err(|_| arbitrary::Error::IncorrectFormat) - } - - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and(u8::size_hint(depth), BytesRef::size_hint(depth)) - } -} - -#[cfg(feature = "alloc")] -pub use self::allocating::BitString; - -#[cfg(feature = "alloc")] -mod allocating { - use super::*; - use crate::referenced::*; - use alloc::vec::Vec; - - /// Owned form of ASN.1 `BIT STRING` type. - /// - /// This type provides the same functionality as [`BitStringRef`] but owns the - /// backing data. - #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] - pub struct BitString { - /// Number of unused bits in the final octet. - unused_bits: u8, - - /// Length of this `BIT STRING` in bits. - bit_length: usize, - - /// Bitstring represented as a slice of bytes. - inner: Vec, - } - - impl BitString { - /// Maximum number of unused bits allowed. - pub const MAX_UNUSED_BITS: u8 = 7; - - /// Create a new ASN.1 `BIT STRING` from a byte slice. - /// - /// Accepts an optional number of "unused bits" (0-7) which are omitted - /// from the final octet. This number is 0 if the value is octet-aligned. - pub fn new(unused_bits: u8, bytes: impl Into>) -> Result { - let inner = bytes.into(); - - // Ensure parameters parse successfully as a `BitStringRef`. - let bit_length = BitStringRef::new(unused_bits, &inner)?.bit_length; - - Ok(BitString { - unused_bits, - bit_length, - inner, - }) - } - - /// Create a new ASN.1 `BIT STRING` from the given bytes. - /// - /// The "unused bits" are set to 0. - pub fn from_bytes(bytes: &[u8]) -> Result { - Self::new(0, bytes) - } - - /// Get the number of unused bits in the octet serialization of this - /// `BIT STRING`. - pub fn unused_bits(&self) -> u8 { - self.unused_bits - } - - /// Is the number of unused bits a value other than 0? - pub fn has_unused_bits(&self) -> bool { - self.unused_bits != 0 - } - - /// Get the length of this `BIT STRING` in bits. - pub fn bit_len(&self) -> usize { - self.bit_length - } - - /// Is the inner byte slice empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - /// Borrow the inner byte slice. - /// - /// Returns `None` if the number of unused bits is *not* equal to zero, - /// i.e. if the `BIT STRING` is not octet aligned. - /// - /// Use [`BitString::raw_bytes`] to obtain access to the raw value - /// regardless of the presence of unused bits. - pub fn as_bytes(&self) -> Option<&[u8]> { - if self.has_unused_bits() { - None - } else { - Some(self.raw_bytes()) - } - } - - /// Borrow the raw bytes of this `BIT STRING`. - pub fn raw_bytes(&self) -> &[u8] { - self.inner.as_slice() - } - - /// Iterator over the bits of this `BIT STRING`. - pub fn bits(&self) -> BitStringIter<'_> { - BitStringRef::from(self).bits() - } - } - - impl_any_conversions!(BitString); - - impl<'a> DecodeValue<'a> for BitString { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let inner_len = (header.length - Length::ONE)?; - let unused_bits = reader.read_byte()?; - let inner = reader.read_vec(inner_len)?; - Self::new(unused_bits, inner) - } - } - - impl EncodeValue for BitString { - fn value_len(&self) -> Result { - Length::ONE + Length::try_from(self.inner.len())? - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write_byte(self.unused_bits)?; - writer.write(&self.inner) - } - } - - impl FixedTag for BitString { - const TAG: Tag = Tag::BitString; - } - - impl<'a> From<&'a BitString> for BitStringRef<'a> { - fn from(bit_string: &'a BitString) -> BitStringRef<'a> { - // Ensured to parse successfully in constructor - BitStringRef::new(bit_string.unused_bits, &bit_string.inner) - .expect("invalid BIT STRING") - } - } - - impl ValueOrd for BitString { - fn value_cmp(&self, other: &Self) -> Result { - match self.unused_bits.cmp(&other.unused_bits) { - Ordering::Equal => self.inner.der_cmp(&other.inner), - ordering => Ok(ordering), - } - } - } - - // Implement by hand because the derive would create invalid values. - // Use the constructor to create a valid value. - #[cfg(feature = "arbitrary")] - impl<'a> arbitrary::Arbitrary<'a> for BitString { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - Self::new( - u.int_in_range(0..=Self::MAX_UNUSED_BITS)?, - BytesRef::arbitrary(u)?.as_slice(), - ) - .map_err(|_| arbitrary::Error::IncorrectFormat) - } - - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and(u8::size_hint(depth), BytesRef::size_hint(depth)) - } - } - - impl<'a> RefToOwned<'a> for BitStringRef<'a> { - type Owned = BitString; - fn ref_to_owned(&self) -> Self::Owned { - BitString { - unused_bits: self.unused_bits, - bit_length: self.bit_length, - inner: Vec::from(self.inner.as_slice()), - } - } - } - - impl OwnedToRef for BitString { - type Borrowed<'a> = BitStringRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - self.into() - } - } -} - -/// Iterator over the bits of a [`BitString`]. -pub struct BitStringIter<'a> { - /// [`BitString`] being iterated over. - bit_string: BitStringRef<'a>, - - /// Current bit position within the iterator. - position: usize, -} - -impl<'a> Iterator for BitStringIter<'a> { - type Item = bool; - - #[allow(clippy::integer_arithmetic)] - fn next(&mut self) -> Option { - if self.position >= self.bit_string.bit_len() { - return None; - } - - let byte = self.bit_string.raw_bytes().get(self.position / 8)?; - let bit = 1u8 << (7 - (self.position % 8)); - self.position = self.position.checked_add(1)?; - Some(byte & bit != 0) - } -} - -impl<'a> ExactSizeIterator for BitStringIter<'a> { - fn len(&self) -> usize { - self.bit_string.bit_len() - } -} - -impl<'a> FusedIterator for BitStringIter<'a> {} - -#[cfg(feature = "flagset")] -impl FixedTag for flagset::FlagSet { - const TAG: Tag = BitStringRef::TAG; -} - -#[cfg(feature = "flagset")] -impl ValueOrd for flagset::FlagSet -where - T: flagset::Flags, - T::Type: Ord, -{ - fn value_cmp(&self, other: &Self) -> Result { - Ok(self.bits().cmp(&other.bits())) - } -} - -#[cfg(feature = "flagset")] -#[allow(clippy::integer_arithmetic)] -impl<'a, T> DecodeValue<'a> for flagset::FlagSet -where - T: flagset::Flags, - T::Type: From, - T::Type: core::ops::Shl, -{ - fn decode_value>(reader: &mut R, header: Header) -> Result { - let position = reader.position(); - let bits = BitStringRef::decode_value(reader, header)?; - - let mut flags = T::none().bits(); - - if bits.bit_len() > core::mem::size_of_val(&flags) * 8 { - return Err(Error::new(ErrorKind::Overlength, position)); - } - - for (i, bit) in bits.bits().enumerate() { - flags |= T::Type::from(bit) << i; - } - - Ok(Self::new_truncated(flags)) - } -} - -#[cfg(feature = "flagset")] -#[allow(clippy::integer_arithmetic)] -#[inline(always)] -fn encode_flagset(set: &flagset::FlagSet) -> (usize, [u8; 16]) -where - T: flagset::Flags, - u128: From, -{ - let bits: u128 = set.bits().into(); - let mut swap = 0u128; - - for i in 0..128 { - let on = bits & (1 << i); - swap |= on >> i << (128 - i - 1); - } - - (bits.leading_zeros() as usize, swap.to_be_bytes()) -} - -#[cfg(feature = "flagset")] -#[allow(clippy::cast_possible_truncation, clippy::integer_arithmetic)] -impl EncodeValue for flagset::FlagSet -where - T::Type: From, - T::Type: core::ops::Shl, - u128: From, -{ - fn value_len(&self) -> Result { - let (lead, buff) = encode_flagset(self); - let buff = &buff[..buff.len() - lead / 8]; - BitStringRef::new((lead % 8) as u8, buff)?.value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - let (lead, buff) = encode_flagset(self); - let buff = &buff[..buff.len() - lead / 8]; - BitStringRef::new((lead % 8) as u8, buff)?.encode_value(writer) - } -} - -#[cfg(test)] -mod tests { - use super::{BitStringRef, Result, Tag}; - use crate::asn1::AnyRef; - use hex_literal::hex; - - /// Parse a `BitString` from an ASN.1 `Any` value to test decoding behaviors. - fn parse_bitstring(bytes: &[u8]) -> Result> { - AnyRef::new(Tag::BitString, bytes)?.try_into() - } - - #[test] - fn decode_empty_bitstring() { - let bs = parse_bitstring(&hex!("00")).unwrap(); - assert_eq!(bs.as_bytes().unwrap(), &[]); - } - - #[test] - fn decode_non_empty_bitstring() { - let bs = parse_bitstring(&hex!("00010203")).unwrap(); - assert_eq!(bs.as_bytes().unwrap(), &[0x01, 0x02, 0x03]); - } - - #[test] - fn decode_bitstring_with_unused_bits() { - let bs = parse_bitstring(&hex!("066e5dc0")).unwrap(); - assert_eq!(bs.unused_bits(), 6); - assert_eq!(bs.raw_bytes(), &hex!("6e5dc0")); - - // Expected: 011011100101110111 - let mut bits = bs.bits(); - assert_eq!(bits.len(), 18); - - for bit in [0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1] { - assert_eq!(u8::from(bits.next().unwrap()), bit) - } - - // Ensure `None` is returned on successive calls - assert_eq!(bits.next(), None); - assert_eq!(bits.next(), None); - } - - #[test] - fn reject_unused_bits_in_empty_string() { - assert_eq!( - parse_bitstring(&[0x03]).err().unwrap().kind(), - Tag::BitString.value_error().kind() - ) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bmp_string.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bmp_string.rs deleted file mode 100644 index b4135d518bba..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bmp_string.rs +++ /dev/null @@ -1,164 +0,0 @@ -//! ASN.1 `BMPString` support. - -use crate::{ - BytesOwned, DecodeValue, EncodeValue, Error, FixedTag, Header, Length, Reader, Result, Tag, - Writer, -}; -use alloc::{boxed::Box, vec::Vec}; -use core::{fmt, str::FromStr}; - -/// ASN.1 `BMPString` type. -/// -/// Encodes Basic Multilingual Plane (BMP) subset of Unicode (ISO 10646), -/// a.k.a. UCS-2. -#[derive(Clone, Eq, PartialEq, PartialOrd, Ord)] -pub struct BmpString { - bytes: BytesOwned, -} - -impl BmpString { - /// Create a new [`BmpString`] from its UCS-2 encoding. - pub fn from_ucs2(bytes: impl Into>) -> Result { - let bytes = bytes.into(); - - if bytes.len() % 2 != 0 { - return Err(Tag::BmpString.length_error()); - } - - let ret = Self { - bytes: bytes.try_into()?, - }; - - for maybe_char in char::decode_utf16(ret.codepoints()) { - match maybe_char { - // All surrogates paired and character is in the Basic Multilingual Plane - Ok(c) if (c as u64) < u64::from(u16::MAX) => (), - // Unpaired surrogates or characters outside Basic Multilingual Plane - _ => return Err(Tag::BmpString.value_error()), - } - } - - Ok(ret) - } - - /// Create a new [`BmpString`] from a UTF-8 string. - pub fn from_utf8(utf8: &str) -> Result { - let capacity = utf8 - .len() - .checked_mul(2) - .ok_or_else(|| Tag::BmpString.length_error())?; - - let mut bytes = Vec::with_capacity(capacity); - - for code_point in utf8.encode_utf16() { - bytes.extend(code_point.to_be_bytes()); - } - - Self::from_ucs2(bytes) - } - - /// Borrow the encoded UCS-2 as bytes. - pub fn as_bytes(&self) -> &[u8] { - self.bytes.as_ref() - } - - /// Obtain the inner bytes. - #[inline] - pub fn into_bytes(self) -> Box<[u8]> { - self.bytes.into() - } - - /// Get an iterator over characters in the string. - pub fn chars(&self) -> impl Iterator + '_ { - char::decode_utf16(self.codepoints()) - .map(|maybe_char| maybe_char.expect("unpaired surrogates checked in constructor")) - } - - /// Get an iterator over the `u16` codepoints. - pub fn codepoints(&self) -> impl Iterator + '_ { - // TODO(tarcieri): use `array_chunks` - self.as_bytes() - .chunks_exact(2) - .map(|chunk| u16::from_be_bytes([chunk[0], chunk[1]])) - } -} - -impl AsRef<[u8]> for BmpString { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } -} - -impl<'a> DecodeValue<'a> for BmpString { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Self::from_ucs2(reader.read_vec(header.length)?) - } -} - -impl EncodeValue for BmpString { - fn value_len(&self) -> Result { - Ok(self.bytes.len()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_bytes()) - } -} - -impl FixedTag for BmpString { - const TAG: Tag = Tag::BmpString; -} - -impl FromStr for BmpString { - type Err = Error; - - fn from_str(s: &str) -> Result { - Self::from_utf8(s) - } -} - -impl fmt::Debug for BmpString { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "BmpString(\"{}\")", self) - } -} - -impl fmt::Display for BmpString { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - for c in self.chars() { - write!(f, "{}", c)?; - } - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::BmpString; - use crate::{Decode, Encode}; - use alloc::string::ToString; - use hex_literal::hex; - - const EXAMPLE_BYTES: &[u8] = &hex!( - "1e 26 00 43 00 65 00 72 00 74" - " 00 69 00 66 00 69 00 63" - " 00 61 00 74 00 65 00 54" - " 00 65 00 6d 00 70 00 6c" - " 00 61 00 74 00 65" - ); - - const EXAMPLE_UTF8: &str = "CertificateTemplate"; - - #[test] - fn decode() { - let bmp_string = BmpString::from_der(EXAMPLE_BYTES).unwrap(); - assert_eq!(bmp_string.to_string(), EXAMPLE_UTF8); - } - - #[test] - fn encode() { - let bmp_string = BmpString::from_utf8(EXAMPLE_UTF8).unwrap(); - let encoded = bmp_string.to_der().unwrap(); - assert_eq!(encoded, EXAMPLE_BYTES); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/boolean.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/boolean.rs deleted file mode 100644 index 3eb0f2e68101..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/boolean.rs +++ /dev/null @@ -1,82 +0,0 @@ -//! ASN.1 `BOOLEAN` support. - -use crate::{ - asn1::AnyRef, ord::OrdIsValueOrd, DecodeValue, EncodeValue, Error, ErrorKind, FixedTag, Header, - Length, Reader, Result, Tag, Writer, -}; - -/// Byte used to encode `true` in ASN.1 DER. From X.690 Section 11.1: -/// -/// > If the encoding represents the boolean value TRUE, its single contents -/// > octet shall have all eight bits set to one. -const TRUE_OCTET: u8 = 0b11111111; - -/// Byte used to encode `false` in ASN.1 DER. -const FALSE_OCTET: u8 = 0b00000000; - -impl<'a> DecodeValue<'a> for bool { - fn decode_value>(reader: &mut R, header: Header) -> Result { - if header.length != Length::ONE { - return Err(reader.error(ErrorKind::Length { tag: Self::TAG })); - } - - match reader.read_byte()? { - FALSE_OCTET => Ok(false), - TRUE_OCTET => Ok(true), - _ => Err(Self::TAG.non_canonical_error()), - } - } -} - -impl EncodeValue for bool { - fn value_len(&self) -> Result { - Ok(Length::ONE) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write_byte(if *self { TRUE_OCTET } else { FALSE_OCTET }) - } -} - -impl FixedTag for bool { - const TAG: Tag = Tag::Boolean; -} - -impl OrdIsValueOrd for bool {} - -impl TryFrom> for bool { - type Error = Error; - - fn try_from(any: AnyRef<'_>) -> Result { - any.try_into() - } -} - -#[cfg(test)] -mod tests { - use crate::{Decode, Encode}; - - #[test] - fn decode() { - assert_eq!(true, bool::from_der(&[0x01, 0x01, 0xFF]).unwrap()); - assert_eq!(false, bool::from_der(&[0x01, 0x01, 0x00]).unwrap()); - } - - #[test] - fn encode() { - let mut buffer = [0u8; 3]; - assert_eq!( - &[0x01, 0x01, 0xFF], - true.encode_to_slice(&mut buffer).unwrap() - ); - assert_eq!( - &[0x01, 0x01, 0x00], - false.encode_to_slice(&mut buffer).unwrap() - ); - } - - #[test] - fn reject_non_canonical() { - assert!(bool::from_der(&[0x01, 0x01, 0x01]).is_err()); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/choice.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/choice.rs deleted file mode 100644 index 40c7720ca02a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/choice.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! ASN.1 `CHOICE` support. - -use crate::{Decode, FixedTag, Tag, Tagged}; - -/// ASN.1 `CHOICE` denotes a union of one or more possible alternatives. -/// -/// The types MUST have distinct tags. -/// -/// This crate models choice as a trait, with a blanket impl for all types -/// which impl `Decode + FixedTag` (i.e. they are modeled as a `CHOICE` -/// with only one possible variant) -pub trait Choice<'a>: Decode<'a> + Tagged { - /// Is the provided [`Tag`] decodable as a variant of this `CHOICE`? - fn can_decode(tag: Tag) -> bool; -} - -/// This blanket impl allows any [`Tagged`] type to function as a [`Choice`] -/// with a single alternative. -impl<'a, T> Choice<'a> for T -where - T: Decode<'a> + FixedTag, -{ - fn can_decode(tag: Tag) -> bool { - T::TAG == tag - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/context_specific.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/context_specific.rs deleted file mode 100644 index 101ddf0225f3..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/context_specific.rs +++ /dev/null @@ -1,354 +0,0 @@ -//! Context-specific field. - -use crate::{ - asn1::AnyRef, Choice, Decode, DecodeValue, DerOrd, Encode, EncodeValue, EncodeValueRef, Error, - Header, Length, Reader, Result, Tag, TagMode, TagNumber, Tagged, ValueOrd, Writer, -}; -use core::cmp::Ordering; - -/// Context-specific field which wraps an owned inner value. -/// -/// This type decodes/encodes a field which is specific to a particular context -/// and is identified by a [`TagNumber`]. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct ContextSpecific { - /// Context-specific tag number sans the leading `0b10000000` class - /// identifier bit and `0b100000` constructed flag. - pub tag_number: TagNumber, - - /// Tag mode: `EXPLICIT` VS `IMPLICIT`. - pub tag_mode: TagMode, - - /// Value of the field. - pub value: T, -} - -impl ContextSpecific { - /// Attempt to decode an `EXPLICIT` ASN.1 `CONTEXT-SPECIFIC` field with the - /// provided [`TagNumber`]. - /// - /// This method has the following behavior which is designed to simplify - /// handling of extension fields, which are denoted in an ASN.1 schema - /// using the `...` ellipsis extension marker: - /// - /// - Skips over [`ContextSpecific`] fields with a tag number lower than - /// the current one, consuming and ignoring them. - /// - Returns `Ok(None)` if a [`ContextSpecific`] field with a higher tag - /// number is encountered. These fields are not consumed in this case, - /// allowing a field with a lower tag number to be omitted, then the - /// higher numbered field consumed as a follow-up. - /// - Returns `Ok(None)` if anything other than a [`ContextSpecific`] field - /// is encountered. - pub fn decode_explicit<'a, R: Reader<'a>>( - reader: &mut R, - tag_number: TagNumber, - ) -> Result> - where - T: Decode<'a>, - { - Self::decode_with(reader, tag_number, |reader| Self::decode(reader)) - } - - /// Attempt to decode an `IMPLICIT` ASN.1 `CONTEXT-SPECIFIC` field with the - /// provided [`TagNumber`]. - /// - /// This method otherwise behaves the same as `decode_explicit`, - /// but should be used in cases where the particular fields are `IMPLICIT` - /// as opposed to `EXPLICIT`. - pub fn decode_implicit<'a, R: Reader<'a>>( - reader: &mut R, - tag_number: TagNumber, - ) -> Result> - where - T: DecodeValue<'a> + Tagged, - { - Self::decode_with(reader, tag_number, |reader| { - let header = Header::decode(reader)?; - let value = T::decode_value(reader, header)?; - - if header.tag.is_constructed() != value.tag().is_constructed() { - return Err(header.tag.non_canonical_error()); - } - - Ok(Self { - tag_number, - tag_mode: TagMode::Implicit, - value, - }) - }) - } - - /// Attempt to decode a context-specific field with the given - /// helper callback. - fn decode_with<'a, F, R: Reader<'a>>( - reader: &mut R, - tag_number: TagNumber, - f: F, - ) -> Result> - where - F: FnOnce(&mut R) -> Result, - { - while let Some(octet) = reader.peek_byte() { - let tag = Tag::try_from(octet)?; - - if !tag.is_context_specific() || (tag.number() > tag_number) { - break; - } else if tag.number() == tag_number { - return Some(f(reader)).transpose(); - } else { - AnyRef::decode(reader)?; - } - } - - Ok(None) - } -} - -impl<'a, T> Choice<'a> for ContextSpecific -where - T: Decode<'a> + Tagged, -{ - fn can_decode(tag: Tag) -> bool { - tag.is_context_specific() - } -} - -impl<'a, T> Decode<'a> for ContextSpecific -where - T: Decode<'a>, -{ - fn decode>(reader: &mut R) -> Result { - let header = Header::decode(reader)?; - - match header.tag { - Tag::ContextSpecific { - number, - constructed: true, - } => Ok(Self { - tag_number: number, - tag_mode: TagMode::default(), - value: reader.read_nested(header.length, |reader| T::decode(reader))?, - }), - tag => Err(tag.unexpected_error(None)), - } - } -} - -impl EncodeValue for ContextSpecific -where - T: EncodeValue + Tagged, -{ - fn value_len(&self) -> Result { - match self.tag_mode { - TagMode::Explicit => self.value.encoded_len(), - TagMode::Implicit => self.value.value_len(), - } - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - match self.tag_mode { - TagMode::Explicit => self.value.encode(writer), - TagMode::Implicit => self.value.encode_value(writer), - } - } -} - -impl Tagged for ContextSpecific -where - T: Tagged, -{ - fn tag(&self) -> Tag { - let constructed = match self.tag_mode { - TagMode::Explicit => true, - TagMode::Implicit => self.value.tag().is_constructed(), - }; - - Tag::ContextSpecific { - number: self.tag_number, - constructed, - } - } -} - -impl<'a, T> TryFrom> for ContextSpecific -where - T: Decode<'a>, -{ - type Error = Error; - - fn try_from(any: AnyRef<'a>) -> Result> { - match any.tag() { - Tag::ContextSpecific { - number, - constructed: true, - } => Ok(Self { - tag_number: number, - tag_mode: TagMode::default(), - value: T::from_der(any.value())?, - }), - tag => Err(tag.unexpected_error(None)), - } - } -} - -impl ValueOrd for ContextSpecific -where - T: EncodeValue + ValueOrd + Tagged, -{ - fn value_cmp(&self, other: &Self) -> Result { - match self.tag_mode { - TagMode::Explicit => self.der_cmp(other), - TagMode::Implicit => self.value_cmp(other), - } - } -} - -/// Context-specific field reference. -/// -/// This type encodes a field which is specific to a particular context -/// and is identified by a [`TagNumber`]. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct ContextSpecificRef<'a, T> { - /// Context-specific tag number sans the leading `0b10000000` class - /// identifier bit and `0b100000` constructed flag. - pub tag_number: TagNumber, - - /// Tag mode: `EXPLICIT` VS `IMPLICIT`. - pub tag_mode: TagMode, - - /// Value of the field. - pub value: &'a T, -} - -impl<'a, T> ContextSpecificRef<'a, T> { - /// Convert to a [`ContextSpecific`]. - fn encoder(&self) -> ContextSpecific> { - ContextSpecific { - tag_number: self.tag_number, - tag_mode: self.tag_mode, - value: EncodeValueRef(self.value), - } - } -} - -impl<'a, T> EncodeValue for ContextSpecificRef<'a, T> -where - T: EncodeValue + Tagged, -{ - fn value_len(&self) -> Result { - self.encoder().value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - self.encoder().encode_value(writer) - } -} - -impl<'a, T> Tagged for ContextSpecificRef<'a, T> -where - T: Tagged, -{ - fn tag(&self) -> Tag { - self.encoder().tag() - } -} - -#[cfg(test)] -mod tests { - use super::ContextSpecific; - use crate::{asn1::BitStringRef, Decode, Encode, SliceReader, TagMode, TagNumber}; - use hex_literal::hex; - - // Public key data from `pkcs8` crate's `ed25519-pkcs8-v2.der` - const EXAMPLE_BYTES: &[u8] = - &hex!("A123032100A3A7EAE3A8373830BC47E1167BC50E1DB551999651E0E2DC587623438EAC3F31"); - - #[test] - fn round_trip() { - let field = ContextSpecific::>::from_der(EXAMPLE_BYTES).unwrap(); - assert_eq!(field.tag_number.value(), 1); - assert_eq!( - field.value, - BitStringRef::from_bytes(&EXAMPLE_BYTES[5..]).unwrap() - ); - - let mut buf = [0u8; 128]; - let encoded = field.encode_to_slice(&mut buf).unwrap(); - assert_eq!(encoded, EXAMPLE_BYTES); - } - - #[test] - fn context_specific_with_explicit_field() { - let tag_number = TagNumber::new(0); - - // Empty message - let mut reader = SliceReader::new(&[]).unwrap(); - assert_eq!( - ContextSpecific::::decode_explicit(&mut reader, tag_number).unwrap(), - None - ); - - // Message containing a non-context-specific type - let mut reader = SliceReader::new(&hex!("020100")).unwrap(); - assert_eq!( - ContextSpecific::::decode_explicit(&mut reader, tag_number).unwrap(), - None - ); - - // Message containing an EXPLICIT context-specific field - let mut reader = SliceReader::new(&hex!("A003020100")).unwrap(); - let field = ContextSpecific::::decode_explicit(&mut reader, tag_number) - .unwrap() - .unwrap(); - - assert_eq!(field.tag_number, tag_number); - assert_eq!(field.tag_mode, TagMode::Explicit); - assert_eq!(field.value, 0); - } - - #[test] - fn context_specific_with_implicit_field() { - // From RFC8410 Section 10.3: - // - // - // 81 33: [1] 00 19 BF 44 09 69 84 CD FE 85 41 BA C1 67 DC 3B - // 96 C8 50 86 AA 30 B6 B6 CB 0C 5C 38 AD 70 31 66 - // E1 - let context_specific_implicit_bytes = - hex!("81210019BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1"); - - let tag_number = TagNumber::new(1); - - let mut reader = SliceReader::new(&context_specific_implicit_bytes).unwrap(); - let field = ContextSpecific::>::decode_implicit(&mut reader, tag_number) - .unwrap() - .unwrap(); - - assert_eq!(field.tag_number, tag_number); - assert_eq!(field.tag_mode, TagMode::Implicit); - assert_eq!( - field.value.as_bytes().unwrap(), - &context_specific_implicit_bytes[3..] - ); - } - - #[test] - fn context_specific_skipping_unknown_field() { - let tag = TagNumber::new(1); - let mut reader = SliceReader::new(&hex!("A003020100A103020101")).unwrap(); - let field = ContextSpecific::::decode_explicit(&mut reader, tag) - .unwrap() - .unwrap(); - assert_eq!(field.value, 1); - } - - #[test] - fn context_specific_returns_none_on_greater_tag_number() { - let tag = TagNumber::new(0); - let mut reader = SliceReader::new(&hex!("A103020101")).unwrap(); - assert_eq!( - ContextSpecific::::decode_explicit(&mut reader, tag).unwrap(), - None - ); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/generalized_time.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/generalized_time.rs deleted file mode 100644 index 8837917c38c5..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/generalized_time.rs +++ /dev/null @@ -1,327 +0,0 @@ -//! ASN.1 `GeneralizedTime` support. -#![cfg_attr(feature = "arbitrary", allow(clippy::integer_arithmetic))] - -use crate::{ - datetime::{self, DateTime}, - ord::OrdIsValueOrd, - DecodeValue, EncodeValue, ErrorKind, FixedTag, Header, Length, Reader, Result, Tag, Writer, -}; -use core::time::Duration; - -#[cfg(feature = "std")] -use { - crate::{asn1::AnyRef, Error}, - std::time::SystemTime, -}; - -#[cfg(feature = "time")] -use time::PrimitiveDateTime; - -/// ASN.1 `GeneralizedTime` type. -/// -/// This type implements the validity requirements specified in -/// [RFC 5280 Section 4.1.2.5.2][1], namely: -/// -/// > For the purposes of this profile, GeneralizedTime values MUST be -/// > expressed in Greenwich Mean Time (Zulu) and MUST include seconds -/// > (i.e., times are `YYYYMMDDHHMMSSZ`), even where the number of seconds -/// > is zero. GeneralizedTime values MUST NOT include fractional seconds. -/// -/// [1]: https://tools.ietf.org/html/rfc5280#section-4.1.2.5.2 -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct GeneralizedTime(DateTime); - -impl GeneralizedTime { - /// Length of an RFC 5280-flavored ASN.1 DER-encoded [`GeneralizedTime`]. - const LENGTH: usize = 15; - - /// Create a [`GeneralizedTime`] from a [`DateTime`]. - pub const fn from_date_time(datetime: DateTime) -> Self { - Self(datetime) - } - - /// Convert this [`GeneralizedTime`] into a [`DateTime`]. - pub fn to_date_time(&self) -> DateTime { - self.0 - } - - /// Create a new [`GeneralizedTime`] given a [`Duration`] since `UNIX_EPOCH` - /// (a.k.a. "Unix time") - pub fn from_unix_duration(unix_duration: Duration) -> Result { - DateTime::from_unix_duration(unix_duration) - .map(Into::into) - .map_err(|_| Self::TAG.value_error()) - } - - /// Get the duration of this timestamp since `UNIX_EPOCH`. - pub fn to_unix_duration(&self) -> Duration { - self.0.unix_duration() - } - - /// Instantiate from [`SystemTime`]. - #[cfg(feature = "std")] - pub fn from_system_time(time: SystemTime) -> Result { - DateTime::try_from(time) - .map(Into::into) - .map_err(|_| Self::TAG.value_error()) - } - - /// Convert to [`SystemTime`]. - #[cfg(feature = "std")] - pub fn to_system_time(&self) -> SystemTime { - self.0.to_system_time() - } -} - -impl_any_conversions!(GeneralizedTime); - -impl<'a> DecodeValue<'a> for GeneralizedTime { - fn decode_value>(reader: &mut R, header: Header) -> Result { - if Self::LENGTH != usize::try_from(header.length)? { - return Err(Self::TAG.value_error()); - } - - let mut bytes = [0u8; Self::LENGTH]; - reader.read_into(&mut bytes)?; - - match bytes { - // RFC 5280 requires mandatory seconds and Z-normalized time zone - [y1, y2, y3, y4, mon1, mon2, day1, day2, hour1, hour2, min1, min2, sec1, sec2, b'Z'] => { - let year = u16::from(datetime::decode_decimal(Self::TAG, y1, y2)?) - .checked_mul(100) - .and_then(|y| { - y.checked_add(datetime::decode_decimal(Self::TAG, y3, y4).ok()?.into()) - }) - .ok_or(ErrorKind::DateTime)?; - let month = datetime::decode_decimal(Self::TAG, mon1, mon2)?; - let day = datetime::decode_decimal(Self::TAG, day1, day2)?; - let hour = datetime::decode_decimal(Self::TAG, hour1, hour2)?; - let minute = datetime::decode_decimal(Self::TAG, min1, min2)?; - let second = datetime::decode_decimal(Self::TAG, sec1, sec2)?; - - DateTime::new(year, month, day, hour, minute, second) - .map_err(|_| Self::TAG.value_error()) - .and_then(|dt| Self::from_unix_duration(dt.unix_duration())) - } - _ => Err(Self::TAG.value_error()), - } - } -} - -impl EncodeValue for GeneralizedTime { - fn value_len(&self) -> Result { - Self::LENGTH.try_into() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - let year_hi = u8::try_from(self.0.year() / 100)?; - let year_lo = u8::try_from(self.0.year() % 100)?; - - datetime::encode_decimal(writer, Self::TAG, year_hi)?; - datetime::encode_decimal(writer, Self::TAG, year_lo)?; - datetime::encode_decimal(writer, Self::TAG, self.0.month())?; - datetime::encode_decimal(writer, Self::TAG, self.0.day())?; - datetime::encode_decimal(writer, Self::TAG, self.0.hour())?; - datetime::encode_decimal(writer, Self::TAG, self.0.minutes())?; - datetime::encode_decimal(writer, Self::TAG, self.0.seconds())?; - writer.write_byte(b'Z') - } -} - -impl FixedTag for GeneralizedTime { - const TAG: Tag = Tag::GeneralizedTime; -} - -impl OrdIsValueOrd for GeneralizedTime {} - -impl From<&GeneralizedTime> for GeneralizedTime { - fn from(value: &GeneralizedTime) -> GeneralizedTime { - *value - } -} - -impl From for DateTime { - fn from(utc_time: GeneralizedTime) -> DateTime { - utc_time.0 - } -} - -impl From<&GeneralizedTime> for DateTime { - fn from(utc_time: &GeneralizedTime) -> DateTime { - utc_time.0 - } -} - -impl From for GeneralizedTime { - fn from(datetime: DateTime) -> Self { - Self::from_date_time(datetime) - } -} - -impl From<&DateTime> for GeneralizedTime { - fn from(datetime: &DateTime) -> Self { - Self::from_date_time(*datetime) - } -} - -impl<'a> DecodeValue<'a> for DateTime { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Ok(GeneralizedTime::decode_value(reader, header)?.into()) - } -} - -impl EncodeValue for DateTime { - fn value_len(&self) -> Result { - GeneralizedTime::from(self).value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - GeneralizedTime::from(self).encode_value(writer) - } -} - -impl FixedTag for DateTime { - const TAG: Tag = Tag::GeneralizedTime; -} - -impl OrdIsValueOrd for DateTime {} - -#[cfg(feature = "std")] -impl<'a> DecodeValue<'a> for SystemTime { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Ok(GeneralizedTime::decode_value(reader, header)?.into()) - } -} - -#[cfg(feature = "std")] -impl EncodeValue for SystemTime { - fn value_len(&self) -> Result { - GeneralizedTime::try_from(self)?.value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - GeneralizedTime::try_from(self)?.encode_value(writer) - } -} - -#[cfg(feature = "std")] -impl From for SystemTime { - fn from(time: GeneralizedTime) -> SystemTime { - time.to_system_time() - } -} - -#[cfg(feature = "std")] -impl From<&GeneralizedTime> for SystemTime { - fn from(time: &GeneralizedTime) -> SystemTime { - time.to_system_time() - } -} - -#[cfg(feature = "std")] -impl TryFrom for GeneralizedTime { - type Error = Error; - - fn try_from(time: SystemTime) -> Result { - GeneralizedTime::from_system_time(time) - } -} - -#[cfg(feature = "std")] -impl TryFrom<&SystemTime> for GeneralizedTime { - type Error = Error; - - fn try_from(time: &SystemTime) -> Result { - GeneralizedTime::from_system_time(*time) - } -} - -#[cfg(feature = "std")] -impl<'a> TryFrom> for SystemTime { - type Error = Error; - - fn try_from(any: AnyRef<'a>) -> Result { - GeneralizedTime::try_from(any).map(|s| s.to_system_time()) - } -} - -#[cfg(feature = "std")] -impl FixedTag for SystemTime { - const TAG: Tag = Tag::GeneralizedTime; -} - -#[cfg(feature = "std")] -impl OrdIsValueOrd for SystemTime {} - -#[cfg(feature = "time")] -impl<'a> DecodeValue<'a> for PrimitiveDateTime { - fn decode_value>(reader: &mut R, header: Header) -> Result { - GeneralizedTime::decode_value(reader, header)?.try_into() - } -} - -#[cfg(feature = "time")] -impl EncodeValue for PrimitiveDateTime { - fn value_len(&self) -> Result { - GeneralizedTime::try_from(self)?.value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - GeneralizedTime::try_from(self)?.encode_value(writer) - } -} - -#[cfg(feature = "time")] -impl FixedTag for PrimitiveDateTime { - const TAG: Tag = Tag::GeneralizedTime; -} - -#[cfg(feature = "time")] -impl OrdIsValueOrd for PrimitiveDateTime {} - -#[cfg(feature = "time")] -impl TryFrom for GeneralizedTime { - type Error = Error; - - fn try_from(time: PrimitiveDateTime) -> Result { - Ok(GeneralizedTime::from_date_time(DateTime::try_from(time)?)) - } -} - -#[cfg(feature = "time")] -impl TryFrom<&PrimitiveDateTime> for GeneralizedTime { - type Error = Error; - - fn try_from(time: &PrimitiveDateTime) -> Result { - Self::try_from(*time) - } -} - -#[cfg(feature = "time")] -impl TryFrom for PrimitiveDateTime { - type Error = Error; - - fn try_from(time: GeneralizedTime) -> Result { - time.to_date_time().try_into() - } -} - -#[cfg(test)] -mod tests { - use super::GeneralizedTime; - use crate::{Decode, Encode, SliceWriter}; - use hex_literal::hex; - - #[test] - fn round_trip() { - let example_bytes = hex!("18 0f 31 39 39 31 30 35 30 36 32 33 34 35 34 30 5a"); - let utc_time = GeneralizedTime::from_der(&example_bytes).unwrap(); - assert_eq!(utc_time.to_unix_duration().as_secs(), 673573540); - - let mut buf = [0u8; 128]; - let mut encoder = SliceWriter::new(&mut buf); - utc_time.encode(&mut encoder).unwrap(); - assert_eq!(example_bytes, encoder.finish().unwrap()); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/ia5_string.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/ia5_string.rs deleted file mode 100644 index 1b06dcef9dfc..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/ia5_string.rs +++ /dev/null @@ -1,195 +0,0 @@ -//! ASN.1 `IA5String` support. - -use crate::{asn1::AnyRef, FixedTag, Result, StrRef, Tag}; -use core::{fmt, ops::Deref}; - -macro_rules! impl_ia5_string { - ($type: ty) => { - impl_ia5_string!($type,); - }; - ($type: ty, $($li: lifetime)?) => { - impl_string_type!($type, $($li),*); - - impl<$($li),*> FixedTag for $type { - const TAG: Tag = Tag::Ia5String; - } - - impl<$($li),*> fmt::Debug for $type { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Ia5String({:?})", self.as_str()) - } - } - }; -} - -/// ASN.1 `IA5String` type. -/// -/// Supports the [International Alphabet No. 5 (IA5)] character encoding, i.e. -/// the lower 128 characters of the ASCII alphabet. (Note: IA5 is now -/// technically known as the International Reference Alphabet or IRA as -/// specified in the ITU-T's T.50 recommendation). -/// -/// For UTF-8, use [`Utf8StringRef`][`crate::asn1::Utf8StringRef`]. -/// -/// This is a zero-copy reference type which borrows from the input data. -/// -/// [International Alphabet No. 5 (IA5)]: https://en.wikipedia.org/wiki/T.50_%28standard%29 -#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)] -pub struct Ia5StringRef<'a> { - /// Inner value - inner: StrRef<'a>, -} - -impl<'a> Ia5StringRef<'a> { - /// Create a new `IA5String`. - pub fn new(input: &'a T) -> Result - where - T: AsRef<[u8]> + ?Sized, - { - let input = input.as_ref(); - - // Validate all characters are within IA5String's allowed set - if input.iter().any(|&c| c > 0x7F) { - return Err(Self::TAG.value_error()); - } - - StrRef::from_bytes(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } -} - -impl_ia5_string!(Ia5StringRef<'a>, 'a); - -impl<'a> Deref for Ia5StringRef<'a> { - type Target = StrRef<'a>; - - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl<'a> From<&Ia5StringRef<'a>> for Ia5StringRef<'a> { - fn from(value: &Ia5StringRef<'a>) -> Ia5StringRef<'a> { - *value - } -} - -impl<'a> From> for AnyRef<'a> { - fn from(internationalized_string: Ia5StringRef<'a>) -> AnyRef<'a> { - AnyRef::from_tag_and_value(Tag::Ia5String, internationalized_string.inner.into()) - } -} - -#[cfg(feature = "alloc")] -pub use self::allocation::Ia5String; - -#[cfg(feature = "alloc")] -mod allocation { - use super::Ia5StringRef; - use crate::{ - asn1::AnyRef, - referenced::{OwnedToRef, RefToOwned}, - Error, FixedTag, Result, StrOwned, Tag, - }; - use alloc::string::String; - use core::{fmt, ops::Deref}; - - /// ASN.1 `IA5String` type. - /// - /// Supports the [International Alphabet No. 5 (IA5)] character encoding, i.e. - /// the lower 128 characters of the ASCII alphabet. (Note: IA5 is now - /// technically known as the International Reference Alphabet or IRA as - /// specified in the ITU-T's T.50 recommendation). - /// - /// For UTF-8, use [`String`][`alloc::string::String`]. - /// - /// [International Alphabet No. 5 (IA5)]: https://en.wikipedia.org/wiki/T.50_%28standard%29 - #[derive(Clone, Eq, PartialEq, PartialOrd, Ord)] - pub struct Ia5String { - /// Inner value - inner: StrOwned, - } - - impl Ia5String { - /// Create a new `IA5String`. - pub fn new(input: &T) -> Result - where - T: AsRef<[u8]> + ?Sized, - { - let input = input.as_ref(); - Ia5StringRef::new(input)?; - - StrOwned::from_bytes(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } - } - - impl_ia5_string!(Ia5String); - - impl Deref for Ia5String { - type Target = StrOwned; - - fn deref(&self) -> &Self::Target { - &self.inner - } - } - - impl<'a> From> for Ia5String { - fn from(international_string: Ia5StringRef<'a>) -> Ia5String { - let inner = international_string.inner.into(); - Self { inner } - } - } - - impl<'a> From<&'a Ia5String> for AnyRef<'a> { - fn from(international_string: &'a Ia5String) -> AnyRef<'a> { - AnyRef::from_tag_and_value(Tag::Ia5String, (&international_string.inner).into()) - } - } - - impl<'a> RefToOwned<'a> for Ia5StringRef<'a> { - type Owned = Ia5String; - fn ref_to_owned(&self) -> Self::Owned { - Ia5String { - inner: self.inner.ref_to_owned(), - } - } - } - - impl OwnedToRef for Ia5String { - type Borrowed<'a> = Ia5StringRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - Ia5StringRef { - inner: self.inner.owned_to_ref(), - } - } - } - - impl TryFrom for Ia5String { - type Error = Error; - - fn try_from(input: String) -> Result { - Ia5StringRef::new(&input)?; - - StrOwned::new(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } - } -} - -#[cfg(test)] -mod tests { - use super::Ia5StringRef; - use crate::Decode; - use hex_literal::hex; - - #[test] - fn parse_bytes() { - let example_bytes = hex!("16 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d"); - let internationalized_string = Ia5StringRef::from_der(&example_bytes).unwrap(); - assert_eq!(internationalized_string.as_str(), "test1@rsa.com"); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer.rs deleted file mode 100644 index a6e913d66cf2..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer.rs +++ /dev/null @@ -1,161 +0,0 @@ -//! ASN.1 `INTEGER` support. - -pub(super) mod int; -pub(super) mod uint; - -use core::{cmp::Ordering, mem}; - -use crate::{EncodeValue, Result, SliceWriter}; - -/// Is the highest bit of the first byte in the slice set to `1`? (if present) -#[inline] -fn is_highest_bit_set(bytes: &[u8]) -> bool { - bytes - .first() - .map(|byte| byte & 0b10000000 != 0) - .unwrap_or(false) -} - -/// Compare two integer values -fn value_cmp(a: T, b: T) -> Result -where - T: Copy + EncodeValue + Sized, -{ - const MAX_INT_SIZE: usize = 16; - debug_assert!(mem::size_of::() <= MAX_INT_SIZE); - - let mut buf1 = [0u8; MAX_INT_SIZE]; - let mut encoder1 = SliceWriter::new(&mut buf1); - a.encode_value(&mut encoder1)?; - - let mut buf2 = [0u8; MAX_INT_SIZE]; - let mut encoder2 = SliceWriter::new(&mut buf2); - b.encode_value(&mut encoder2)?; - - Ok(encoder1.finish()?.cmp(encoder2.finish()?)) -} - -#[cfg(test)] -pub(crate) mod tests { - use crate::{Decode, Encode}; - - // Vectors from Section 5.7 of: - // https://luca.ntop.org/Teaching/Appunti/asn1.html - pub(crate) const I0_BYTES: &[u8] = &[0x02, 0x01, 0x00]; - pub(crate) const I127_BYTES: &[u8] = &[0x02, 0x01, 0x7F]; - pub(crate) const I128_BYTES: &[u8] = &[0x02, 0x02, 0x00, 0x80]; - pub(crate) const I256_BYTES: &[u8] = &[0x02, 0x02, 0x01, 0x00]; - pub(crate) const INEG128_BYTES: &[u8] = &[0x02, 0x01, 0x80]; - pub(crate) const INEG129_BYTES: &[u8] = &[0x02, 0x02, 0xFF, 0x7F]; - - // Additional vectors - pub(crate) const I255_BYTES: &[u8] = &[0x02, 0x02, 0x00, 0xFF]; - pub(crate) const I32767_BYTES: &[u8] = &[0x02, 0x02, 0x7F, 0xFF]; - pub(crate) const I65535_BYTES: &[u8] = &[0x02, 0x03, 0x00, 0xFF, 0xFF]; - pub(crate) const INEG32768_BYTES: &[u8] = &[0x02, 0x02, 0x80, 0x00]; - - #[test] - fn decode_i8() { - assert_eq!(0, i8::from_der(I0_BYTES).unwrap()); - assert_eq!(127, i8::from_der(I127_BYTES).unwrap()); - assert_eq!(-128, i8::from_der(INEG128_BYTES).unwrap()); - } - - #[test] - fn decode_i16() { - assert_eq!(0, i16::from_der(I0_BYTES).unwrap()); - assert_eq!(127, i16::from_der(I127_BYTES).unwrap()); - assert_eq!(128, i16::from_der(I128_BYTES).unwrap()); - assert_eq!(255, i16::from_der(I255_BYTES).unwrap()); - assert_eq!(256, i16::from_der(I256_BYTES).unwrap()); - assert_eq!(32767, i16::from_der(I32767_BYTES).unwrap()); - assert_eq!(-128, i16::from_der(INEG128_BYTES).unwrap()); - assert_eq!(-129, i16::from_der(INEG129_BYTES).unwrap()); - assert_eq!(-32768, i16::from_der(INEG32768_BYTES).unwrap()); - } - - #[test] - fn decode_u8() { - assert_eq!(0, u8::from_der(I0_BYTES).unwrap()); - assert_eq!(127, u8::from_der(I127_BYTES).unwrap()); - assert_eq!(255, u8::from_der(I255_BYTES).unwrap()); - } - - #[test] - fn decode_u16() { - assert_eq!(0, u16::from_der(I0_BYTES).unwrap()); - assert_eq!(127, u16::from_der(I127_BYTES).unwrap()); - assert_eq!(255, u16::from_der(I255_BYTES).unwrap()); - assert_eq!(256, u16::from_der(I256_BYTES).unwrap()); - assert_eq!(32767, u16::from_der(I32767_BYTES).unwrap()); - assert_eq!(65535, u16::from_der(I65535_BYTES).unwrap()); - } - - #[test] - fn encode_i8() { - let mut buffer = [0u8; 3]; - - assert_eq!(I0_BYTES, 0i8.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I127_BYTES, 127i8.encode_to_slice(&mut buffer).unwrap()); - - assert_eq!( - INEG128_BYTES, - (-128i8).encode_to_slice(&mut buffer).unwrap() - ); - } - - #[test] - fn encode_i16() { - let mut buffer = [0u8; 4]; - assert_eq!(I0_BYTES, 0i16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I127_BYTES, 127i16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I128_BYTES, 128i16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I255_BYTES, 255i16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I256_BYTES, 256i16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I32767_BYTES, 32767i16.encode_to_slice(&mut buffer).unwrap()); - - assert_eq!( - INEG128_BYTES, - (-128i16).encode_to_slice(&mut buffer).unwrap() - ); - - assert_eq!( - INEG129_BYTES, - (-129i16).encode_to_slice(&mut buffer).unwrap() - ); - - assert_eq!( - INEG32768_BYTES, - (-32768i16).encode_to_slice(&mut buffer).unwrap() - ); - } - - #[test] - fn encode_u8() { - let mut buffer = [0u8; 4]; - assert_eq!(I0_BYTES, 0u8.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I127_BYTES, 127u8.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I255_BYTES, 255u8.encode_to_slice(&mut buffer).unwrap()); - } - - #[test] - fn encode_u16() { - let mut buffer = [0u8; 5]; - assert_eq!(I0_BYTES, 0u16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I127_BYTES, 127u16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I128_BYTES, 128u16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I255_BYTES, 255u16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I256_BYTES, 256u16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I32767_BYTES, 32767u16.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(I65535_BYTES, 65535u16.encode_to_slice(&mut buffer).unwrap()); - } - - /// Integers must be encoded with a minimum number of octets - #[test] - fn reject_non_canonical() { - assert!(i8::from_der(&[0x02, 0x02, 0x00, 0x00]).is_err()); - assert!(i16::from_der(&[0x02, 0x02, 0x00, 0x00]).is_err()); - assert!(u8::from_der(&[0x02, 0x02, 0x00, 0x00]).is_err()); - assert!(u16::from_der(&[0x02, 0x02, 0x00, 0x00]).is_err()); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/int.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/int.rs deleted file mode 100644 index bccc5210c8fe..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/int.rs +++ /dev/null @@ -1,442 +0,0 @@ -//! Support for encoding signed integers - -use super::{is_highest_bit_set, uint, value_cmp}; -use crate::{ - ord::OrdIsValueOrd, AnyRef, BytesRef, DecodeValue, EncodeValue, Error, ErrorKind, FixedTag, - Header, Length, Reader, Result, Tag, ValueOrd, Writer, -}; -use core::cmp::Ordering; - -#[cfg(feature = "alloc")] -pub use allocating::Int; - -macro_rules! impl_encoding_traits { - ($($int:ty => $uint:ty),+) => { - $( - impl<'a> DecodeValue<'a> for $int { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let mut buf = [0u8; Self::BITS as usize / 8]; - let max_length = u32::from(header.length) as usize; - - if max_length > buf.len() { - return Err(Self::TAG.non_canonical_error()); - } - - let bytes = reader.read_into(&mut buf[..max_length])?; - - let result = if is_highest_bit_set(bytes) { - <$uint>::from_be_bytes(decode_to_array(bytes)?) as $int - } else { - Self::from_be_bytes(uint::decode_to_array(bytes)?) - }; - - // Ensure we compute the same encoded length as the original any value - if header.length != result.value_len()? { - return Err(Self::TAG.non_canonical_error()); - } - - Ok(result) - } - } - - impl EncodeValue for $int { - fn value_len(&self) -> Result { - if *self < 0 { - negative_encoded_len(&(*self as $uint).to_be_bytes()) - } else { - uint::encoded_len(&self.to_be_bytes()) - } - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - if *self < 0 { - encode_bytes(writer, &(*self as $uint).to_be_bytes()) - } else { - uint::encode_bytes(writer, &self.to_be_bytes()) - } - } - } - - impl FixedTag for $int { - const TAG: Tag = Tag::Integer; - } - - impl ValueOrd for $int { - fn value_cmp(&self, other: &Self) -> Result { - value_cmp(*self, *other) - } - } - - impl TryFrom> for $int { - type Error = Error; - - fn try_from(any: AnyRef<'_>) -> Result { - any.decode_as() - } - } - )+ - }; -} - -impl_encoding_traits!(i8 => u8, i16 => u16, i32 => u32, i64 => u64, i128 => u128); - -/// Signed arbitrary precision ASN.1 `INTEGER` reference type. -/// -/// Provides direct access to the underlying big endian bytes which comprise -/// an signed integer value. -/// -/// Intended for use cases like very large integers that are used in -/// cryptographic applications (e.g. keys, signatures). -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct IntRef<'a> { - /// Inner value - inner: BytesRef<'a>, -} - -impl<'a> IntRef<'a> { - /// Create a new [`IntRef`] from a byte slice. - pub fn new(bytes: &'a [u8]) -> Result { - let inner = BytesRef::new(strip_leading_ones(bytes)) - .map_err(|_| ErrorKind::Length { tag: Self::TAG })?; - - Ok(Self { inner }) - } - - /// Borrow the inner byte slice which contains the least significant bytes - /// of a big endian integer value with all leading ones stripped. - pub fn as_bytes(&self) -> &'a [u8] { - self.inner.as_slice() - } - - /// Get the length of this [`IntRef`] in bytes. - pub fn len(&self) -> Length { - self.inner.len() - } - - /// Is the inner byte slice empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } -} - -impl_any_conversions!(IntRef<'a>, 'a); - -impl<'a> DecodeValue<'a> for IntRef<'a> { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let bytes = BytesRef::decode_value(reader, header)?; - validate_canonical(bytes.as_slice())?; - - let result = Self::new(bytes.as_slice())?; - - // Ensure we compute the same encoded length as the original any value. - if result.value_len()? != header.length { - return Err(Self::TAG.non_canonical_error()); - } - - Ok(result) - } -} - -impl<'a> EncodeValue for IntRef<'a> { - fn value_len(&self) -> Result { - // Signed integers always hold their full encoded form. - Ok(self.inner.len()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_bytes()) - } -} - -impl<'a> From<&IntRef<'a>> for IntRef<'a> { - fn from(value: &IntRef<'a>) -> IntRef<'a> { - *value - } -} - -impl<'a> FixedTag for IntRef<'a> { - const TAG: Tag = Tag::Integer; -} - -impl<'a> OrdIsValueOrd for IntRef<'a> {} - -#[cfg(feature = "alloc")] -mod allocating { - use super::{strip_leading_ones, validate_canonical, IntRef}; - use crate::{ - asn1::Uint, - ord::OrdIsValueOrd, - referenced::{OwnedToRef, RefToOwned}, - BytesOwned, DecodeValue, EncodeValue, ErrorKind, FixedTag, Header, Length, Reader, Result, - Tag, Writer, - }; - use alloc::vec::Vec; - - /// Signed arbitrary precision ASN.1 `INTEGER` type. - /// - /// Provides heap-allocated storage for big endian bytes which comprise an - /// signed integer value. - /// - /// Intended for use cases like very large integers that are used in - /// cryptographic applications (e.g. keys, signatures). - #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] - pub struct Int { - /// Inner value - inner: BytesOwned, - } - - impl Int { - /// Create a new [`Int`] from a byte slice. - pub fn new(bytes: &[u8]) -> Result { - let inner = BytesOwned::new(strip_leading_ones(bytes)) - .map_err(|_| ErrorKind::Length { tag: Self::TAG })?; - - Ok(Self { inner }) - } - - /// Borrow the inner byte slice which contains the least significant bytes - /// of a big endian integer value with all leading ones stripped. - pub fn as_bytes(&self) -> &[u8] { - self.inner.as_slice() - } - - /// Get the length of this [`Int`] in bytes. - pub fn len(&self) -> Length { - self.inner.len() - } - - /// Is the inner byte slice empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - } - - impl_any_conversions!(Int); - - impl<'a> DecodeValue<'a> for Int { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let bytes = BytesOwned::decode_value(reader, header)?; - validate_canonical(bytes.as_slice())?; - - let result = Self::new(bytes.as_slice())?; - - // Ensure we compute the same encoded length as the original any value. - if result.value_len()? != header.length { - return Err(Self::TAG.non_canonical_error()); - } - - Ok(result) - } - } - - impl EncodeValue for Int { - fn value_len(&self) -> Result { - // Signed integers always hold their full encoded form. - Ok(self.inner.len()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_bytes()) - } - } - - impl<'a> From<&IntRef<'a>> for Int { - fn from(value: &IntRef<'a>) -> Int { - let inner = BytesOwned::new(value.as_bytes()).expect("Invalid Int"); - Int { inner } - } - } - - impl From for Int { - fn from(value: Uint) -> Self { - let mut inner: Vec = Vec::new(); - - // Add leading `0x00` byte if required - if value.value_len().expect("invalid Uint") > value.len() { - inner.push(0x00); - } - - inner.extend_from_slice(value.as_bytes()); - let inner = BytesOwned::new(inner).expect("invalid Uint"); - - Int { inner } - } - } - - impl FixedTag for Int { - const TAG: Tag = Tag::Integer; - } - - impl OrdIsValueOrd for Int {} - - impl<'a> RefToOwned<'a> for IntRef<'a> { - type Owned = Int; - fn ref_to_owned(&self) -> Self::Owned { - let inner = self.inner.ref_to_owned(); - - Int { inner } - } - } - - impl OwnedToRef for Int { - type Borrowed<'a> = IntRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - let inner = self.inner.owned_to_ref(); - - IntRef { inner } - } - } -} - -/// Ensure `INTEGER` is canonically encoded. -fn validate_canonical(bytes: &[u8]) -> Result<()> { - // The `INTEGER` type always encodes a signed value and we're decoding - // as signed here, so we allow a zero extension or sign extension byte, - // but only as permitted under DER canonicalization. - match bytes { - [] => Err(Tag::Integer.non_canonical_error()), - [0x00, byte, ..] if *byte < 0x80 => Err(Tag::Integer.non_canonical_error()), - [0xFF, byte, ..] if *byte >= 0x80 => Err(Tag::Integer.non_canonical_error()), - _ => Ok(()), - } -} - -/// Decode an signed integer of the specified size. -/// -/// Returns a byte array of the requested size containing a big endian integer. -fn decode_to_array(bytes: &[u8]) -> Result<[u8; N]> { - match N.checked_sub(bytes.len()) { - Some(offset) => { - let mut output = [0xFFu8; N]; - output[offset..].copy_from_slice(bytes); - Ok(output) - } - None => { - let expected_len = Length::try_from(N)?; - let actual_len = Length::try_from(bytes.len())?; - - Err(ErrorKind::Incomplete { - expected_len, - actual_len, - } - .into()) - } - } -} - -/// Encode the given big endian bytes representing an integer as ASN.1 DER. -fn encode_bytes(writer: &mut W, bytes: &[u8]) -> Result<()> -where - W: Writer + ?Sized, -{ - writer.write(strip_leading_ones(bytes)) -} - -/// Get the encoded length for the given **negative** integer serialized as bytes. -#[inline] -fn negative_encoded_len(bytes: &[u8]) -> Result { - Length::try_from(strip_leading_ones(bytes).len()) -} - -/// Strip the leading all-ones bytes from the given byte slice. -pub(crate) fn strip_leading_ones(mut bytes: &[u8]) -> &[u8] { - while let Some((byte, rest)) = bytes.split_first() { - if *byte == 0xFF && is_highest_bit_set(rest) { - bytes = rest; - continue; - } - - break; - } - - bytes -} - -#[cfg(test)] -mod tests { - use super::{validate_canonical, IntRef}; - use crate::{asn1::integer::tests::*, Decode, Encode, SliceWriter}; - - #[test] - fn validate_canonical_ok() { - assert_eq!(validate_canonical(&[0x00]), Ok(())); - assert_eq!(validate_canonical(&[0x01]), Ok(())); - assert_eq!(validate_canonical(&[0x00, 0x80]), Ok(())); - assert_eq!(validate_canonical(&[0xFF, 0x00]), Ok(())); - } - - #[test] - fn validate_canonical_err() { - // Empty integers are always non-canonical. - assert!(validate_canonical(&[]).is_err()); - - // Positives with excessive zero extension are non-canonical. - assert!(validate_canonical(&[0x00, 0x00]).is_err()); - - // Negatives with excessive sign extension are non-canonical. - assert!(validate_canonical(&[0xFF, 0x80]).is_err()); - } - - #[test] - fn decode_intref() { - // Positive numbers decode, but have zero extensions as necessary - // (to distinguish them from negative representations). - assert_eq!(&[0], IntRef::from_der(I0_BYTES).unwrap().as_bytes()); - assert_eq!(&[127], IntRef::from_der(I127_BYTES).unwrap().as_bytes()); - assert_eq!(&[0, 128], IntRef::from_der(I128_BYTES).unwrap().as_bytes()); - assert_eq!(&[0, 255], IntRef::from_der(I255_BYTES).unwrap().as_bytes()); - - assert_eq!( - &[0x01, 0x00], - IntRef::from_der(I256_BYTES).unwrap().as_bytes() - ); - - assert_eq!( - &[0x7F, 0xFF], - IntRef::from_der(I32767_BYTES).unwrap().as_bytes() - ); - - // Negative integers decode. - assert_eq!(&[128], IntRef::from_der(INEG128_BYTES).unwrap().as_bytes()); - assert_eq!( - &[255, 127], - IntRef::from_der(INEG129_BYTES).unwrap().as_bytes() - ); - assert_eq!( - &[128, 0], - IntRef::from_der(INEG32768_BYTES).unwrap().as_bytes() - ); - } - - #[test] - fn encode_intref() { - for &example in &[ - I0_BYTES, - I127_BYTES, - I128_BYTES, - I255_BYTES, - I256_BYTES, - I32767_BYTES, - ] { - let uint = IntRef::from_der(example).unwrap(); - - let mut buf = [0u8; 128]; - let mut encoder = SliceWriter::new(&mut buf); - uint.encode(&mut encoder).unwrap(); - - let result = encoder.finish().unwrap(); - assert_eq!(example, result); - } - - for &example in &[INEG128_BYTES, INEG129_BYTES, INEG32768_BYTES] { - let uint = IntRef::from_der(example).unwrap(); - - let mut buf = [0u8; 128]; - let mut encoder = SliceWriter::new(&mut buf); - uint.encode(&mut encoder).unwrap(); - - let result = encoder.finish().unwrap(); - assert_eq!(example, result); - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/uint.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/uint.rs deleted file mode 100644 index 95c6297c2bb8..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/uint.rs +++ /dev/null @@ -1,428 +0,0 @@ -//! Unsigned integer decoders/encoders. - -use super::value_cmp; -use crate::{ - ord::OrdIsValueOrd, AnyRef, BytesRef, DecodeValue, EncodeValue, Error, ErrorKind, FixedTag, - Header, Length, Reader, Result, Tag, ValueOrd, Writer, -}; -use core::cmp::Ordering; - -#[cfg(feature = "alloc")] -pub use allocating::Uint; - -macro_rules! impl_encoding_traits { - ($($uint:ty),+) => { - $( - impl<'a> DecodeValue<'a> for $uint { - fn decode_value>(reader: &mut R, header: Header) -> Result { - // Integers always encodes as a signed value, unsigned gets a leading 0x00 that - // needs to be stripped off. We need to provide room for it. - const UNSIGNED_HEADROOM: usize = 1; - - let mut buf = [0u8; (Self::BITS as usize / 8) + UNSIGNED_HEADROOM]; - let max_length = u32::from(header.length) as usize; - - if max_length > buf.len() { - return Err(Self::TAG.non_canonical_error()); - } - - let bytes = reader.read_into(&mut buf[..max_length])?; - - let result = Self::from_be_bytes(decode_to_array(bytes)?); - - // Ensure we compute the same encoded length as the original any value - if header.length != result.value_len()? { - return Err(Self::TAG.non_canonical_error()); - } - - Ok(result) - } - } - - impl EncodeValue for $uint { - fn value_len(&self) -> Result { - encoded_len(&self.to_be_bytes()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - encode_bytes(writer, &self.to_be_bytes()) - } - } - - impl FixedTag for $uint { - const TAG: Tag = Tag::Integer; - } - - impl ValueOrd for $uint { - fn value_cmp(&self, other: &Self) -> Result { - value_cmp(*self, *other) - } - } - - impl TryFrom> for $uint { - type Error = Error; - - fn try_from(any: AnyRef<'_>) -> Result { - any.decode_as() - } - } - )+ - }; -} - -impl_encoding_traits!(u8, u16, u32, u64, u128); - -/// Unsigned arbitrary precision ASN.1 `INTEGER` reference type. -/// -/// Provides direct access to the underlying big endian bytes which comprise an -/// unsigned integer value. -/// -/// Intended for use cases like very large integers that are used in -/// cryptographic applications (e.g. keys, signatures). -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct UintRef<'a> { - /// Inner value - inner: BytesRef<'a>, -} - -impl<'a> UintRef<'a> { - /// Create a new [`UintRef`] from a byte slice. - pub fn new(bytes: &'a [u8]) -> Result { - let inner = BytesRef::new(strip_leading_zeroes(bytes)) - .map_err(|_| ErrorKind::Length { tag: Self::TAG })?; - - Ok(Self { inner }) - } - - /// Borrow the inner byte slice which contains the least significant bytes - /// of a big endian integer value with all leading zeros stripped. - pub fn as_bytes(&self) -> &'a [u8] { - self.inner.as_slice() - } - - /// Get the length of this [`UintRef`] in bytes. - pub fn len(&self) -> Length { - self.inner.len() - } - - /// Is the inner byte slice empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } -} - -impl_any_conversions!(UintRef<'a>, 'a); - -impl<'a> DecodeValue<'a> for UintRef<'a> { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let bytes = BytesRef::decode_value(reader, header)?.as_slice(); - let result = Self::new(decode_to_slice(bytes)?)?; - - // Ensure we compute the same encoded length as the original any value. - if result.value_len()? != header.length { - return Err(Self::TAG.non_canonical_error()); - } - - Ok(result) - } -} - -impl<'a> EncodeValue for UintRef<'a> { - fn value_len(&self) -> Result { - encoded_len(self.inner.as_slice()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - // Add leading `0x00` byte if required - if self.value_len()? > self.len() { - writer.write_byte(0)?; - } - - writer.write(self.as_bytes()) - } -} - -impl<'a> From<&UintRef<'a>> for UintRef<'a> { - fn from(value: &UintRef<'a>) -> UintRef<'a> { - *value - } -} - -impl<'a> FixedTag for UintRef<'a> { - const TAG: Tag = Tag::Integer; -} - -impl<'a> OrdIsValueOrd for UintRef<'a> {} - -#[cfg(feature = "alloc")] -mod allocating { - use super::{decode_to_slice, encoded_len, strip_leading_zeroes, UintRef}; - use crate::{ - ord::OrdIsValueOrd, - referenced::{OwnedToRef, RefToOwned}, - BytesOwned, DecodeValue, EncodeValue, ErrorKind, FixedTag, Header, Length, Reader, Result, - Tag, Writer, - }; - - /// Unsigned arbitrary precision ASN.1 `INTEGER` type. - /// - /// Provides heap-allocated storage for big endian bytes which comprise an - /// unsigned integer value. - /// - /// Intended for use cases like very large integers that are used in - /// cryptographic applications (e.g. keys, signatures). - #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] - pub struct Uint { - /// Inner value - inner: BytesOwned, - } - - impl Uint { - /// Create a new [`Uint`] from a byte slice. - pub fn new(bytes: &[u8]) -> Result { - let inner = BytesOwned::new(strip_leading_zeroes(bytes)) - .map_err(|_| ErrorKind::Length { tag: Self::TAG })?; - - Ok(Self { inner }) - } - - /// Borrow the inner byte slice which contains the least significant bytes - /// of a big endian integer value with all leading zeros stripped. - pub fn as_bytes(&self) -> &[u8] { - self.inner.as_slice() - } - - /// Get the length of this [`Uint`] in bytes. - pub fn len(&self) -> Length { - self.inner.len() - } - - /// Is the inner byte slice empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - } - - impl_any_conversions!(Uint); - - impl<'a> DecodeValue<'a> for Uint { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let bytes = BytesOwned::decode_value(reader, header)?; - let result = Self::new(decode_to_slice(bytes.as_slice())?)?; - - // Ensure we compute the same encoded length as the original any value. - if result.value_len()? != header.length { - return Err(Self::TAG.non_canonical_error()); - } - - Ok(result) - } - } - - impl EncodeValue for Uint { - fn value_len(&self) -> Result { - encoded_len(self.inner.as_slice()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - // Add leading `0x00` byte if required - if self.value_len()? > self.len() { - writer.write_byte(0)?; - } - - writer.write(self.as_bytes()) - } - } - - impl<'a> From<&UintRef<'a>> for Uint { - fn from(value: &UintRef<'a>) -> Uint { - let inner = BytesOwned::new(value.as_bytes()).expect("Invalid Uint"); - Uint { inner } - } - } - - impl FixedTag for Uint { - const TAG: Tag = Tag::Integer; - } - - impl OrdIsValueOrd for Uint {} - - impl<'a> RefToOwned<'a> for UintRef<'a> { - type Owned = Uint; - fn ref_to_owned(&self) -> Self::Owned { - let inner = self.inner.ref_to_owned(); - - Uint { inner } - } - } - - impl OwnedToRef for Uint { - type Borrowed<'a> = UintRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - let inner = self.inner.owned_to_ref(); - - UintRef { inner } - } - } -} - -/// Decode an unsigned integer into a big endian byte slice with all leading -/// zeroes removed. -/// -/// Returns a byte array of the requested size containing a big endian integer. -pub(crate) fn decode_to_slice(bytes: &[u8]) -> Result<&[u8]> { - // The `INTEGER` type always encodes a signed value, so for unsigned - // values the leading `0x00` byte may need to be removed. - // - // We also disallow a leading byte which would overflow a signed ASN.1 - // integer (since we're decoding an unsigned integer). - // We expect all such cases to have a leading `0x00` byte. - match bytes { - [] => Err(Tag::Integer.non_canonical_error()), - [0] => Ok(bytes), - [0, byte, ..] if *byte < 0x80 => Err(Tag::Integer.non_canonical_error()), - [0, rest @ ..] => Ok(rest), - [byte, ..] if *byte >= 0x80 => Err(Tag::Integer.value_error()), - _ => Ok(bytes), - } -} - -/// Decode an unsigned integer into a byte array of the requested size -/// containing a big endian integer. -pub(super) fn decode_to_array(bytes: &[u8]) -> Result<[u8; N]> { - let input = decode_to_slice(bytes)?; - - // Compute number of leading zeroes to add - let num_zeroes = N - .checked_sub(input.len()) - .ok_or_else(|| Tag::Integer.length_error())?; - - // Copy input into `N`-sized output buffer with leading zeroes - let mut output = [0u8; N]; - output[num_zeroes..].copy_from_slice(input); - Ok(output) -} - -/// Encode the given big endian bytes representing an integer as ASN.1 DER. -pub(crate) fn encode_bytes(encoder: &mut W, bytes: &[u8]) -> Result<()> -where - W: Writer + ?Sized, -{ - let bytes = strip_leading_zeroes(bytes); - - if needs_leading_zero(bytes) { - encoder.write_byte(0)?; - } - - encoder.write(bytes) -} - -/// Get the encoded length for the given unsigned integer serialized as bytes. -#[inline] -pub(crate) fn encoded_len(bytes: &[u8]) -> Result { - let bytes = strip_leading_zeroes(bytes); - Length::try_from(bytes.len())? + u8::from(needs_leading_zero(bytes)) -} - -/// Strip the leading zeroes from the given byte slice -pub(crate) fn strip_leading_zeroes(mut bytes: &[u8]) -> &[u8] { - while let Some((byte, rest)) = bytes.split_first() { - if *byte == 0 && !rest.is_empty() { - bytes = rest; - } else { - break; - } - } - - bytes -} - -/// Does the given integer need a leading zero? -fn needs_leading_zero(bytes: &[u8]) -> bool { - matches!(bytes.first(), Some(byte) if *byte >= 0x80) -} - -#[cfg(test)] -mod tests { - use super::{decode_to_array, UintRef}; - use crate::{asn1::integer::tests::*, AnyRef, Decode, Encode, ErrorKind, SliceWriter, Tag}; - - #[test] - fn decode_to_array_no_leading_zero() { - let arr = decode_to_array::<4>(&[1, 2]).unwrap(); - assert_eq!(arr, [0, 0, 1, 2]); - } - - #[test] - fn decode_to_array_leading_zero() { - let arr = decode_to_array::<4>(&[0x00, 0xFF, 0xFE]).unwrap(); - assert_eq!(arr, [0x00, 0x00, 0xFF, 0xFE]); - } - - #[test] - fn decode_to_array_extra_zero() { - let err = decode_to_array::<4>(&[0, 1, 2]).err().unwrap(); - assert_eq!(err.kind(), ErrorKind::Noncanonical { tag: Tag::Integer }); - } - - #[test] - fn decode_to_array_missing_zero() { - // We're decoding an unsigned integer, but this value would be signed - let err = decode_to_array::<4>(&[0xFF, 0xFE]).err().unwrap(); - assert_eq!(err.kind(), ErrorKind::Value { tag: Tag::Integer }); - } - - #[test] - fn decode_to_array_oversized_input() { - let err = decode_to_array::<1>(&[1, 2, 3]).err().unwrap(); - assert_eq!(err.kind(), ErrorKind::Length { tag: Tag::Integer }); - } - - #[test] - fn decode_uintref() { - assert_eq!(&[0], UintRef::from_der(I0_BYTES).unwrap().as_bytes()); - assert_eq!(&[127], UintRef::from_der(I127_BYTES).unwrap().as_bytes()); - assert_eq!(&[128], UintRef::from_der(I128_BYTES).unwrap().as_bytes()); - assert_eq!(&[255], UintRef::from_der(I255_BYTES).unwrap().as_bytes()); - - assert_eq!( - &[0x01, 0x00], - UintRef::from_der(I256_BYTES).unwrap().as_bytes() - ); - - assert_eq!( - &[0x7F, 0xFF], - UintRef::from_der(I32767_BYTES).unwrap().as_bytes() - ); - } - - #[test] - fn encode_uintref() { - for &example in &[ - I0_BYTES, - I127_BYTES, - I128_BYTES, - I255_BYTES, - I256_BYTES, - I32767_BYTES, - ] { - let uint = UintRef::from_der(example).unwrap(); - - let mut buf = [0u8; 128]; - let mut encoder = SliceWriter::new(&mut buf); - uint.encode(&mut encoder).unwrap(); - - let result = encoder.finish().unwrap(); - assert_eq!(example, result); - } - } - - #[test] - fn reject_oversize_without_extra_zero() { - let err = UintRef::try_from(AnyRef::new(Tag::Integer, &[0x81]).unwrap()) - .err() - .unwrap(); - - assert_eq!(err.kind(), ErrorKind::Value { tag: Tag::Integer }); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/internal_macros.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/internal_macros.rs deleted file mode 100644 index 10ad99d23b9a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/internal_macros.rs +++ /dev/null @@ -1,75 +0,0 @@ -macro_rules! impl_any_conversions { - ($type: ty) => { - impl_any_conversions!($type, ); - }; - ($type: ty, $($li: lifetime)?) => { - impl<'__der: $($li),*, $($li),*> TryFrom<$crate::AnyRef<'__der>> for $type { - type Error = $crate::Error; - - fn try_from(any: $crate::AnyRef<'__der>) -> Result<$type> { - any.decode_as() - } - } - - #[cfg(feature = "alloc")] - impl<'__der: $($li),*, $($li),*> TryFrom<&'__der $crate::Any> for $type { - type Error = $crate::Error; - - fn try_from(any: &'__der $crate::Any) -> Result<$type> { - any.decode_as() - } - } - }; -} - -macro_rules! impl_string_type { - ($type: ty, $($li: lifetime)?) => { - impl_any_conversions!($type, $($li),*); - - mod __impl_string { - use super::*; - - use crate::{ - ord::OrdIsValueOrd, BytesRef, DecodeValue, EncodeValue, Header, Length, Reader, - Result, Writer, - }; - use core::{fmt, str}; - - impl<$($li),*> AsRef for $type { - fn as_ref(&self) -> &str { - self.as_str() - } - } - - impl<$($li),*> AsRef<[u8]> for $type { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } - } - - impl<'__der: $($li),*, $($li),*> DecodeValue<'__der> for $type { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Self::new(BytesRef::decode_value(reader, header)?.as_slice()) - } - } - - impl<$($li),*> EncodeValue for $type { - fn value_len(&self) -> Result { - self.inner.value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - self.inner.encode_value(writer) - } - } - - impl<$($li),*> OrdIsValueOrd for $type {} - - impl<$($li),*> fmt::Display for $type { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.as_str()) - } - } - } - }; -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/null.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/null.rs deleted file mode 100644 index 7c1e2058a1ea..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/null.rs +++ /dev/null @@ -1,102 +0,0 @@ -//! ASN.1 `NULL` support. - -use crate::{ - asn1::AnyRef, ord::OrdIsValueOrd, BytesRef, DecodeValue, EncodeValue, Error, ErrorKind, - FixedTag, Header, Length, Reader, Result, Tag, Writer, -}; - -/// ASN.1 `NULL` type. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct Null; - -impl_any_conversions!(Null); - -impl<'a> DecodeValue<'a> for Null { - fn decode_value>(reader: &mut R, header: Header) -> Result { - if header.length.is_zero() { - Ok(Null) - } else { - Err(reader.error(ErrorKind::Length { tag: Self::TAG })) - } - } -} - -impl EncodeValue for Null { - fn value_len(&self) -> Result { - Ok(Length::ZERO) - } - - fn encode_value(&self, _writer: &mut impl Writer) -> Result<()> { - Ok(()) - } -} - -impl FixedTag for Null { - const TAG: Tag = Tag::Null; -} - -impl OrdIsValueOrd for Null {} - -impl<'a> From for AnyRef<'a> { - fn from(_: Null) -> AnyRef<'a> { - AnyRef::from_tag_and_value(Tag::Null, BytesRef::default()) - } -} - -impl TryFrom> for () { - type Error = Error; - - fn try_from(any: AnyRef<'_>) -> Result<()> { - Null::try_from(any).map(|_| ()) - } -} - -impl<'a> From<()> for AnyRef<'a> { - fn from(_: ()) -> AnyRef<'a> { - Null.into() - } -} - -impl<'a> DecodeValue<'a> for () { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Null::decode_value(reader, header)?; - Ok(()) - } -} - -impl EncodeValue for () { - fn value_len(&self) -> Result { - Ok(Length::ZERO) - } - - fn encode_value(&self, _writer: &mut impl Writer) -> Result<()> { - Ok(()) - } -} - -impl FixedTag for () { - const TAG: Tag = Tag::Null; -} - -#[cfg(test)] -mod tests { - use super::Null; - use crate::{Decode, Encode}; - - #[test] - fn decode() { - Null::from_der(&[0x05, 0x00]).unwrap(); - } - - #[test] - fn encode() { - let mut buffer = [0u8; 2]; - assert_eq!(&[0x05, 0x00], Null.encode_to_slice(&mut buffer).unwrap()); - assert_eq!(&[0x05, 0x00], ().encode_to_slice(&mut buffer).unwrap()); - } - - #[test] - fn reject_non_canonical() { - assert!(Null::from_der(&[0x05, 0x81, 0x00]).is_err()); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/octet_string.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/octet_string.rs deleted file mode 100644 index 53d8ecb6a5a6..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/octet_string.rs +++ /dev/null @@ -1,257 +0,0 @@ -//! ASN.1 `OCTET STRING` support. - -use crate::{ - asn1::AnyRef, ord::OrdIsValueOrd, BytesRef, Decode, DecodeValue, EncodeValue, ErrorKind, - FixedTag, Header, Length, Reader, Result, Tag, Writer, -}; - -/// ASN.1 `OCTET STRING` type: borrowed form. -/// -/// Octet strings represent contiguous sequences of octets, a.k.a. bytes. -/// -/// This is a zero-copy reference type which borrows from the input data. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct OctetStringRef<'a> { - /// Inner value - inner: BytesRef<'a>, -} - -impl<'a> OctetStringRef<'a> { - /// Create a new ASN.1 `OCTET STRING` from a byte slice. - pub fn new(slice: &'a [u8]) -> Result { - BytesRef::new(slice) - .map(|inner| Self { inner }) - .map_err(|_| ErrorKind::Length { tag: Self::TAG }.into()) - } - - /// Borrow the inner byte slice. - pub fn as_bytes(&self) -> &'a [u8] { - self.inner.as_slice() - } - - /// Get the length of the inner byte slice. - pub fn len(&self) -> Length { - self.inner.len() - } - - /// Is the inner byte slice empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - /// Parse `T` from this `OCTET STRING`'s contents. - pub fn decode_into>(&self) -> Result { - Decode::from_der(self.as_bytes()) - } -} - -impl_any_conversions!(OctetStringRef<'a>, 'a); - -impl AsRef<[u8]> for OctetStringRef<'_> { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } -} - -impl<'a> DecodeValue<'a> for OctetStringRef<'a> { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let inner = BytesRef::decode_value(reader, header)?; - Ok(Self { inner }) - } -} - -impl EncodeValue for OctetStringRef<'_> { - fn value_len(&self) -> Result { - self.inner.value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - self.inner.encode_value(writer) - } -} - -impl FixedTag for OctetStringRef<'_> { - const TAG: Tag = Tag::OctetString; -} - -impl OrdIsValueOrd for OctetStringRef<'_> {} - -impl<'a> From<&OctetStringRef<'a>> for OctetStringRef<'a> { - fn from(value: &OctetStringRef<'a>) -> OctetStringRef<'a> { - *value - } -} - -impl<'a> From> for AnyRef<'a> { - fn from(octet_string: OctetStringRef<'a>) -> AnyRef<'a> { - AnyRef::from_tag_and_value(Tag::OctetString, octet_string.inner) - } -} - -impl<'a> From> for &'a [u8] { - fn from(octet_string: OctetStringRef<'a>) -> &'a [u8] { - octet_string.as_bytes() - } -} - -#[cfg(feature = "alloc")] -pub use self::allocating::OctetString; - -#[cfg(feature = "alloc")] -mod allocating { - use super::*; - use crate::referenced::*; - use alloc::vec::Vec; - - /// ASN.1 `OCTET STRING` type: owned form.. - /// - /// Octet strings represent contiguous sequences of octets, a.k.a. bytes. - /// - /// This type provides the same functionality as [`OctetStringRef`] but owns - /// the backing data. - #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] - pub struct OctetString { - /// Bitstring represented as a slice of bytes. - pub(super) inner: Vec, - } - - impl OctetString { - /// Create a new ASN.1 `OCTET STRING`. - pub fn new(bytes: impl Into>) -> Result { - let inner = bytes.into(); - - // Ensure the bytes parse successfully as an `OctetStringRef` - OctetStringRef::new(&inner)?; - - Ok(Self { inner }) - } - - /// Borrow the inner byte slice. - pub fn as_bytes(&self) -> &[u8] { - self.inner.as_slice() - } - - /// Take ownership of the octet string. - pub fn into_bytes(self) -> Vec { - self.inner - } - - /// Get the length of the inner byte slice. - pub fn len(&self) -> Length { - self.value_len().expect("invalid OCTET STRING length") - } - - /// Is the inner byte slice empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - } - - impl_any_conversions!(OctetString); - - impl AsRef<[u8]> for OctetString { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } - } - - impl<'a> DecodeValue<'a> for OctetString { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Self::new(reader.read_vec(header.length)?) - } - } - - impl EncodeValue for OctetString { - fn value_len(&self) -> Result { - self.inner.len().try_into() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(&self.inner) - } - } - - impl FixedTag for OctetString { - const TAG: Tag = Tag::OctetString; - } - - impl<'a> From<&'a OctetString> for OctetStringRef<'a> { - fn from(octet_string: &'a OctetString) -> OctetStringRef<'a> { - // Ensured to parse successfully in constructor - OctetStringRef::new(&octet_string.inner).expect("invalid OCTET STRING") - } - } - - impl OrdIsValueOrd for OctetString {} - - impl<'a> RefToOwned<'a> for OctetStringRef<'a> { - type Owned = OctetString; - fn ref_to_owned(&self) -> Self::Owned { - OctetString { - inner: Vec::from(self.inner.as_slice()), - } - } - } - - impl OwnedToRef for OctetString { - type Borrowed<'a> = OctetStringRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - self.into() - } - } - - // Implement by hand because the derive would create invalid values. - // Use the constructor to create a valid value. - #[cfg(feature = "arbitrary")] - impl<'a> arbitrary::Arbitrary<'a> for OctetString { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - Self::new(Vec::arbitrary(u)?).map_err(|_| arbitrary::Error::IncorrectFormat) - } - - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and(u8::size_hint(depth), Vec::::size_hint(depth)) - } - } -} - -#[cfg(feature = "bytes")] -mod bytes { - use super::OctetString; - use crate::{DecodeValue, EncodeValue, FixedTag, Header, Length, Reader, Result, Tag, Writer}; - use bytes::Bytes; - - impl<'a> DecodeValue<'a> for Bytes { - fn decode_value>(reader: &mut R, header: Header) -> Result { - OctetString::decode_value(reader, header).map(|octet_string| octet_string.inner.into()) - } - } - - impl EncodeValue for Bytes { - fn value_len(&self) -> Result { - self.len().try_into() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_ref()) - } - } - - impl FixedTag for Bytes { - const TAG: Tag = Tag::OctetString; - } -} - -#[cfg(test)] -mod tests { - use crate::asn1::{OctetStringRef, PrintableStringRef}; - - #[test] - fn octet_string_decode_into() { - // PrintableString "hi" - let der = b"\x13\x02\x68\x69"; - let oct = OctetStringRef::new(der).unwrap(); - - let res = oct.decode_into::>().unwrap(); - assert_eq!(AsRef::::as_ref(&res), "hi"); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/oid.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/oid.rs deleted file mode 100644 index 3daa452b2fed..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/oid.rs +++ /dev/null @@ -1,100 +0,0 @@ -//! ASN.1 `OBJECT IDENTIFIER` - -use crate::{ - asn1::AnyRef, ord::OrdIsValueOrd, DecodeValue, EncodeValue, Error, FixedTag, Header, Length, - Reader, Result, Tag, Tagged, Writer, -}; -use const_oid::ObjectIdentifier; - -#[cfg(feature = "alloc")] -use super::Any; - -impl<'a> DecodeValue<'a> for ObjectIdentifier { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let mut buf = [0u8; ObjectIdentifier::MAX_SIZE]; - let slice = buf - .get_mut(..header.length.try_into()?) - .ok_or_else(|| Self::TAG.length_error())?; - - let actual_len = reader.read_into(slice)?.len(); - debug_assert_eq!(actual_len, header.length.try_into()?); - Ok(Self::from_bytes(slice)?) - } -} - -impl EncodeValue for ObjectIdentifier { - fn value_len(&self) -> Result { - Length::try_from(self.as_bytes().len()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_bytes()) - } -} - -impl FixedTag for ObjectIdentifier { - const TAG: Tag = Tag::ObjectIdentifier; -} - -impl OrdIsValueOrd for ObjectIdentifier {} - -impl<'a> From<&'a ObjectIdentifier> for AnyRef<'a> { - fn from(oid: &'a ObjectIdentifier) -> AnyRef<'a> { - // Note: ensuring an infallible conversion is possible relies on the - // invariant that `const_oid::MAX_LEN <= Length::max()`. - // - // The `length()` test below ensures this is the case. - let value = oid - .as_bytes() - .try_into() - .expect("OID length invariant violated"); - - AnyRef::from_tag_and_value(Tag::ObjectIdentifier, value) - } -} - -#[cfg(feature = "alloc")] -impl From for Any { - fn from(oid: ObjectIdentifier) -> Any { - AnyRef::from(&oid).into() - } -} - -impl TryFrom> for ObjectIdentifier { - type Error = Error; - - fn try_from(any: AnyRef<'_>) -> Result { - any.tag().assert_eq(Tag::ObjectIdentifier)?; - Ok(ObjectIdentifier::from_bytes(any.value())?) - } -} - -#[cfg(test)] -mod tests { - use super::ObjectIdentifier; - use crate::{Decode, Encode, Length}; - - const EXAMPLE_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549"); - const EXAMPLE_OID_BYTES: &[u8; 8] = &[0x06, 0x06, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d]; - - #[test] - fn decode() { - let oid = ObjectIdentifier::from_der(EXAMPLE_OID_BYTES).unwrap(); - assert_eq!(EXAMPLE_OID, oid); - } - - #[test] - fn encode() { - let mut buffer = [0u8; 8]; - assert_eq!( - EXAMPLE_OID_BYTES, - EXAMPLE_OID.encode_to_slice(&mut buffer).unwrap() - ); - } - - #[test] - fn length() { - // Ensure an infallible `From` conversion to `Any` will never panic - assert!(ObjectIdentifier::MAX_SIZE <= Length::MAX.try_into().unwrap()); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/optional.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/optional.rs deleted file mode 100644 index ecda4f8ecd68..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/optional.rs +++ /dev/null @@ -1,66 +0,0 @@ -//! ASN.1 `OPTIONAL` as mapped to Rust's `Option` type - -use crate::{Choice, Decode, DerOrd, Encode, Length, Reader, Result, Tag, Writer}; -use core::cmp::Ordering; - -impl<'a, T> Decode<'a> for Option -where - T: Choice<'a>, // NOTE: all `Decode + Tagged` types receive a blanket `Choice` impl -{ - fn decode>(reader: &mut R) -> Result> { - if let Some(byte) = reader.peek_byte() { - if T::can_decode(Tag::try_from(byte)?) { - return T::decode(reader).map(Some); - } - } - - Ok(None) - } -} - -impl DerOrd for Option -where - T: DerOrd, -{ - fn der_cmp(&self, other: &Self) -> Result { - match self { - Some(a) => match other { - Some(b) => a.der_cmp(b), - None => Ok(Ordering::Greater), - }, - None => Ok(Ordering::Less), - } - } -} - -impl Encode for Option -where - T: Encode, -{ - fn encoded_len(&self) -> Result { - (&self).encoded_len() - } - - fn encode(&self, writer: &mut impl Writer) -> Result<()> { - (&self).encode(writer) - } -} - -impl Encode for &Option -where - T: Encode, -{ - fn encoded_len(&self) -> Result { - match self { - Some(encodable) => encodable.encoded_len(), - None => Ok(0u8.into()), - } - } - - fn encode(&self, encoder: &mut impl Writer) -> Result<()> { - match self { - Some(encodable) => encodable.encode(encoder), - None => Ok(()), - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/printable_string.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/printable_string.rs deleted file mode 100644 index d2e51d7da2d2..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/printable_string.rs +++ /dev/null @@ -1,252 +0,0 @@ -//! ASN.1 `PrintableString` support. - -use crate::{asn1::AnyRef, FixedTag, Result, StrRef, Tag}; -use core::{fmt, ops::Deref}; - -macro_rules! impl_printable_string { - ($type: ty) => { - impl_printable_string!($type,); - }; - ($type: ty, $($li: lifetime)?) => { - impl_string_type!($type, $($li),*); - - impl<$($li),*> FixedTag for $type { - const TAG: Tag = Tag::PrintableString; - } - - impl<$($li),*> fmt::Debug for $type { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "PrintableString({:?})", self.as_str()) - } - } - }; -} - -/// ASN.1 `PrintableString` type. -/// -/// Supports a subset the ASCII character set (described below). -/// -/// For UTF-8, use [`Utf8StringRef`][`crate::asn1::Utf8StringRef`] instead. -/// For the full ASCII character set, use -/// [`Ia5StringRef`][`crate::asn1::Ia5StringRef`]. -/// -/// This is a zero-copy reference type which borrows from the input data. -/// -/// # Supported characters -/// -/// The following ASCII characters/ranges are supported: -/// -/// - `A..Z` -/// - `a..z` -/// - `0..9` -/// - "` `" (i.e. space) -/// - `\` -/// - `(` -/// - `)` -/// - `+` -/// - `,` -/// - `-` -/// - `.` -/// - `/` -/// - `:` -/// - `=` -/// - `?` -#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)] -pub struct PrintableStringRef<'a> { - /// Inner value - inner: StrRef<'a>, -} - -impl<'a> PrintableStringRef<'a> { - /// Create a new ASN.1 `PrintableString`. - pub fn new(input: &'a T) -> Result - where - T: AsRef<[u8]> + ?Sized, - { - let input = input.as_ref(); - - // Validate all characters are within PrintableString's allowed set - for &c in input.iter() { - match c { - b'A'..=b'Z' - | b'a'..=b'z' - | b'0'..=b'9' - | b' ' - | b'\'' - | b'(' - | b')' - | b'+' - | b',' - | b'-' - | b'.' - | b'/' - | b':' - | b'=' - | b'?' => (), - _ => return Err(Self::TAG.value_error()), - } - } - - StrRef::from_bytes(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } -} - -impl_printable_string!(PrintableStringRef<'a>, 'a); - -impl<'a> Deref for PrintableStringRef<'a> { - type Target = StrRef<'a>; - - fn deref(&self) -> &Self::Target { - &self.inner - } -} -impl<'a> From<&PrintableStringRef<'a>> for PrintableStringRef<'a> { - fn from(value: &PrintableStringRef<'a>) -> PrintableStringRef<'a> { - *value - } -} - -impl<'a> From> for AnyRef<'a> { - fn from(printable_string: PrintableStringRef<'a>) -> AnyRef<'a> { - AnyRef::from_tag_and_value(Tag::PrintableString, printable_string.inner.into()) - } -} - -#[cfg(feature = "alloc")] -pub use self::allocation::PrintableString; - -#[cfg(feature = "alloc")] -mod allocation { - use super::PrintableStringRef; - - use crate::{ - asn1::AnyRef, - referenced::{OwnedToRef, RefToOwned}, - BytesRef, Error, FixedTag, Result, StrOwned, Tag, - }; - use alloc::string::String; - use core::{fmt, ops::Deref}; - - /// ASN.1 `PrintableString` type. - /// - /// Supports a subset the ASCII character set (described below). - /// - /// For UTF-8, use [`Utf8StringRef`][`crate::asn1::Utf8StringRef`] instead. - /// For the full ASCII character set, use - /// [`Ia5StringRef`][`crate::asn1::Ia5StringRef`]. - /// - /// # Supported characters - /// - /// The following ASCII characters/ranges are supported: - /// - /// - `A..Z` - /// - `a..z` - /// - `0..9` - /// - "` `" (i.e. space) - /// - `\` - /// - `(` - /// - `)` - /// - `+` - /// - `,` - /// - `-` - /// - `.` - /// - `/` - /// - `:` - /// - `=` - /// - `?` - #[derive(Clone, Eq, PartialEq, PartialOrd, Ord)] - pub struct PrintableString { - /// Inner value - inner: StrOwned, - } - - impl PrintableString { - /// Create a new ASN.1 `PrintableString`. - pub fn new(input: &T) -> Result - where - T: AsRef<[u8]> + ?Sized, - { - let input = input.as_ref(); - PrintableStringRef::new(input)?; - - StrOwned::from_bytes(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } - } - - impl_printable_string!(PrintableString); - - impl Deref for PrintableString { - type Target = StrOwned; - - fn deref(&self) -> &Self::Target { - &self.inner - } - } - - impl<'a> From> for PrintableString { - fn from(value: PrintableStringRef<'a>) -> PrintableString { - let inner = - StrOwned::from_bytes(value.inner.as_bytes()).expect("Invalid PrintableString"); - Self { inner } - } - } - - impl<'a> From<&'a PrintableString> for AnyRef<'a> { - fn from(printable_string: &'a PrintableString) -> AnyRef<'a> { - AnyRef::from_tag_and_value( - Tag::PrintableString, - BytesRef::new(printable_string.inner.as_bytes()).expect("Invalid PrintableString"), - ) - } - } - - impl<'a> RefToOwned<'a> for PrintableStringRef<'a> { - type Owned = PrintableString; - fn ref_to_owned(&self) -> Self::Owned { - PrintableString { - inner: self.inner.ref_to_owned(), - } - } - } - - impl OwnedToRef for PrintableString { - type Borrowed<'a> = PrintableStringRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - PrintableStringRef { - inner: self.inner.owned_to_ref(), - } - } - } - - impl TryFrom for PrintableString { - type Error = Error; - - fn try_from(input: String) -> Result { - PrintableStringRef::new(&input)?; - - StrOwned::new(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } - } -} - -#[cfg(test)] -mod tests { - use super::PrintableStringRef; - use crate::Decode; - - #[test] - fn parse_bytes() { - let example_bytes = &[ - 0x13, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x65, 0x72, 0x20, 0x31, - ]; - - let printable_string = PrintableStringRef::from_der(example_bytes).unwrap(); - assert_eq!(printable_string.as_str(), "Test User 1"); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/real.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/real.rs deleted file mode 100644 index b9f2e67f5222..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/real.rs +++ /dev/null @@ -1,990 +0,0 @@ -//! ASN.1 `REAL` support. - -// TODO(tarcieri): checked arithmetic -#![allow( - clippy::cast_lossless, - clippy::cast_sign_loss, - clippy::integer_arithmetic -)] - -use crate::{ - BytesRef, DecodeValue, EncodeValue, FixedTag, Header, Length, Reader, Result, StrRef, Tag, - Writer, -}; - -use super::integer::uint::strip_leading_zeroes; - -impl<'a> DecodeValue<'a> for f64 { - fn decode_value>(reader: &mut R, header: Header) -> Result { - let bytes = BytesRef::decode_value(reader, header)?.as_slice(); - - if header.length == Length::ZERO { - Ok(0.0) - } else if is_nth_bit_one::<7>(bytes) { - // Binary encoding from section 8.5.7 applies - let sign: u64 = u64::from(is_nth_bit_one::<6>(bytes)); - - // Section 8.5.7.2: Check the base -- the DER specs say that only base 2 should be supported in DER - let base = mnth_bits_to_u8::<5, 4>(bytes); - - if base != 0 { - // Real related error: base is not DER compliant (base encoded in enum) - return Err(Tag::Real.value_error()); - } - - // Section 8.5.7.3 - let scaling_factor = mnth_bits_to_u8::<3, 2>(bytes); - - // Section 8.5.7.4 - let mantissa_start; - let exponent = match mnth_bits_to_u8::<1, 0>(bytes) { - 0 => { - mantissa_start = 2; - let ebytes = (i16::from_be_bytes([0x0, bytes[1]])).to_be_bytes(); - u64::from_be_bytes([0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ebytes[0], ebytes[1]]) - } - 1 => { - mantissa_start = 3; - let ebytes = (i16::from_be_bytes([bytes[1], bytes[2]])).to_be_bytes(); - u64::from_be_bytes([0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ebytes[0], ebytes[1]]) - } - _ => { - // Real related error: encoded exponent cannot be represented on an IEEE-754 double - return Err(Tag::Real.value_error()); - } - }; - // Section 8.5.7.5: Read the remaining bytes for the mantissa - let mut n_bytes = [0x0; 8]; - for (pos, byte) in bytes[mantissa_start..].iter().rev().enumerate() { - n_bytes[7 - pos] = *byte; - } - let n = u64::from_be_bytes(n_bytes); - // Multiply byt 2^F corresponds to just a left shift - let mantissa = n << scaling_factor; - // Create the f64 - Ok(encode_f64(sign, exponent, mantissa)) - } else if is_nth_bit_one::<6>(bytes) { - // This either a special value, or it's the value minus zero is encoded, section 8.5.9 applies - match mnth_bits_to_u8::<1, 0>(bytes) { - 0 => Ok(f64::INFINITY), - 1 => Ok(f64::NEG_INFINITY), - 2 => Ok(f64::NAN), - 3 => Ok(-0.0_f64), - _ => Err(Tag::Real.value_error()), - } - } else { - let astr = StrRef::from_bytes(&bytes[1..])?; - match astr.inner.parse::() { - Ok(val) => Ok(val), - // Real related error: encoding not supported or malformed - Err(_) => Err(Tag::Real.value_error()), - } - } - } -} - -impl EncodeValue for f64 { - fn value_len(&self) -> Result { - if self.is_sign_positive() && (*self) < f64::MIN_POSITIVE { - // Zero: positive yet smaller than the minimum positive number - Ok(Length::ZERO) - } else if self.is_nan() - || self.is_infinite() - || (self.is_sign_negative() && -self < f64::MIN_POSITIVE) - { - // NaN, infinite (positive or negative), or negative zero (negative but its negative is less than the min positive number) - Ok(Length::ONE) - } else { - // The length is that of the first octets plus those needed for the exponent plus those needed for the mantissa - let (_sign, exponent, mantissa) = decode_f64(*self); - - let exponent_len = if exponent == 0 { - // Section 8.5.7.4: there must be at least one octet for exponent encoding - // But, if the exponent is zero, it'll be skipped, so we make sure force it to 1 - Length::ONE - } else { - let ebytes = exponent.to_be_bytes(); - Length::try_from(strip_leading_zeroes(&ebytes).len())? - }; - - let mantissa_len = if mantissa == 0 { - Length::ONE - } else { - let mbytes = mantissa.to_be_bytes(); - Length::try_from(strip_leading_zeroes(&mbytes).len())? - }; - - exponent_len + mantissa_len + Length::ONE - } - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - // Check if special value - // Encode zero first, if it's zero - // Special value from section 8.5.9 if non zero - if self.is_nan() - || self.is_infinite() - || (self.is_sign_negative() && -self < f64::MIN_POSITIVE) - || (self.is_sign_positive() && (*self) < f64::MIN_POSITIVE) - { - if self.is_sign_positive() && (*self) < f64::MIN_POSITIVE { - // Zero - return Ok(()); - } else if self.is_nan() { - // Not a number - writer.write_byte(0b0100_0010)?; - } else if self.is_infinite() { - if self.is_sign_negative() { - // Negative infinity - writer.write_byte(0b0100_0001)?; - } else { - // Plus infinity - writer.write_byte(0b0100_0000)?; - } - } else { - // Minus zero - writer.write_byte(0b0100_0011)?; - } - } else { - // Always use binary encoding, set bit 8 to 1 - let mut first_byte = 0b1000_0000; - - if self.is_sign_negative() { - // Section 8.5.7.1: set bit 7 to 1 if negative - first_byte |= 0b0100_0000; - } - - // Bits 6 and 5 are set to 0 to specify that binary encoding is used - // - // NOTE: the scaling factor is only used to align the implicit point of the mantissa. - // This is unnecessary in DER because the base is 2, and therefore necessarily aligned. - // Therefore, we do not modify the mantissa in anyway after this function call, which - // already adds the implicit one of the IEEE 754 representation. - let (_sign, exponent, mantissa) = decode_f64(*self); - - // Encode the exponent as two's complement on 16 bits and remove the bias - let exponent_bytes = exponent.to_be_bytes(); - let ebytes = strip_leading_zeroes(&exponent_bytes); - - match ebytes.len() { - 0 | 1 => {} - 2 => first_byte |= 0b0000_0001, - 3 => first_byte |= 0b0000_0010, - _ => { - // TODO: support multi octet exponent encoding? - return Err(Tag::Real.value_error()); - } - } - - writer.write_byte(first_byte)?; - - // Encode both bytes or just the last one, handled by encode_bytes directly - // Rust already encodes the data as two's complement, so no further processing is needed - writer.write(ebytes)?; - - // Now, encode the mantissa as unsigned binary number - let mantissa_bytes = mantissa.to_be_bytes(); - let mbytes = strip_leading_zeroes(&mantissa_bytes); - writer.write(mbytes)?; - } - - Ok(()) - } -} - -impl FixedTag for f64 { - const TAG: Tag = Tag::Real; -} - -/// Is the N-th bit 1 in the first octet? -/// NOTE: this function is zero indexed -pub(crate) fn is_nth_bit_one(bytes: &[u8]) -> bool { - if N < 8 { - bytes - .first() - .map(|byte| byte & (1 << N) != 0) - .unwrap_or(false) - } else { - false - } -} - -/// Convert bits M, N into a u8, in the first octet only -pub(crate) fn mnth_bits_to_u8(bytes: &[u8]) -> u8 { - let bit_m = is_nth_bit_one::(bytes); - let bit_n = is_nth_bit_one::(bytes); - (bit_m as u8) << 1 | bit_n as u8 -} - -/// Decode an f64 as its sign, exponent, and mantissa in u64 and in that order, using bit shifts and masks. -/// Note: this function **removes** the 1023 bias from the exponent and adds the implicit 1 -#[allow(clippy::cast_possible_truncation)] -pub(crate) fn decode_f64(f: f64) -> (u64, u64, u64) { - let bits = f.to_bits(); - let sign = bits >> 63; - let exponent = bits >> 52 & 0x7ff; - let exponent_bytes_no_bias = (exponent as i16 - 1023).to_be_bytes(); - let exponent_no_bias = u64::from_be_bytes([ - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - exponent_bytes_no_bias[0], - exponent_bytes_no_bias[1], - ]); - let mantissa = bits & 0xfffffffffffff; - (sign, exponent_no_bias, mantissa + 1) -} - -/// Encode an f64 from its sign, exponent (**without** the 1023 bias), and (mantissa - 1) using bit shifts as received by ASN1 -pub(crate) fn encode_f64(sign: u64, exponent: u64, mantissa: u64) -> f64 { - // Add the bias to the exponent - let exponent_with_bias = - (i16::from_be_bytes([exponent.to_be_bytes()[6], exponent.to_be_bytes()[7]]) + 1023) as u64; - let bits = sign << 63 | exponent_with_bias << 52 | (mantissa - 1); - f64::from_bits(bits) -} - -#[cfg(test)] -mod tests { - use crate::{Decode, Encode}; - - #[test] - fn decode_subnormal() { - assert!(f64::from_der(&[0x09, 0x01, 0b0100_0010]).unwrap().is_nan()); - let plus_infty = f64::from_der(&[0x09, 0x01, 0b0100_0000]).unwrap(); - assert!(plus_infty.is_infinite() && plus_infty.is_sign_positive()); - let neg_infty = f64::from_der(&[0x09, 0x01, 0b0100_0001]).unwrap(); - assert!(neg_infty.is_infinite() && neg_infty.is_sign_negative()); - let neg_zero = f64::from_der(&[0x09, 0x01, 0b0100_0011]).unwrap(); - assert!(neg_zero.is_sign_negative() && neg_zero.abs() < f64::EPSILON); - } - - #[test] - fn encode_subnormal() { - // All subnormal fit in three bytes - let mut buffer = [0u8; 3]; - assert_eq!( - &[0x09, 0x01, 0b0100_0010], - f64::NAN.encode_to_slice(&mut buffer).unwrap() - ); - assert_eq!( - &[0x09, 0x01, 0b0100_0000], - f64::INFINITY.encode_to_slice(&mut buffer).unwrap() - ); - assert_eq!( - &[0x09, 0x01, 0b0100_0001], - f64::NEG_INFINITY.encode_to_slice(&mut buffer).unwrap() - ); - assert_eq!( - &[0x09, 0x01, 0b0100_0011], - (-0.0_f64).encode_to_slice(&mut buffer).unwrap() - ); - } - - #[test] - fn encdec_normal() { - // The comments correspond to the decoded value from the ASN.1 playground when the bytes are inputed. - { - // rec1value R ::= 0 - let val = 0.0; - let expected = &[0x09, 0x0]; - let mut buffer = [0u8; 2]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec1value R ::= { mantissa 1, base 2, exponent 0 } - let val = 1.0; - let expected = &[0x09, 0x03, 0x80, 0x00, 0x01]; - let mut buffer = [0u8; 5]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec1value R ::= { mantissa -1, base 2, exponent 0 } - let val = -1.0; - let expected = &[0x09, 0x03, 0xc0, 0x00, 0x01]; - let mut buffer = [0u8; 5]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec1value R ::= { mantissa -1, base 2, exponent 1 } - let val = -1.0000000000000002; - let expected = &[0x09, 0x03, 0xc0, 0x00, 0x02]; - let mut buffer = [0u8; 5]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec1value R ::= { mantissa 1, base 2, exponent -1022 } - // NOTE: f64::MIN_EXP == -1021 so the exponent decoded by ASN.1 is what we expect - let val = f64::MIN_POSITIVE; - let expected = &[0x09, 0x04, 0x81, 0xfc, 0x02, 0x01]; - let mut buffer = [0u8; 7]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec4value R ::= { mantissa 1, base 2, exponent 3 } - let val = 1.0000000000000016; - let expected = &[0x09, 0x03, 0x80, 0x00, 0x08]; - let mut buffer = [0u8; 5]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec5value R ::= { mantissa 4222124650659841, base 2, exponent 4 } - let val = 31.0; - let expected = &[ - 0x9, 0x9, 0x80, 0x04, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - ]; - let mut buffer = [0u8; 11]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - } - - #[test] - fn encdec_irrationals() { - { - let val = core::f64::consts::PI; - let expected = &[ - 0x09, 0x09, 0x80, 0x01, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x19, - ]; - let mut buffer = [0u8; 11]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = core::f64::consts::E; - let expected = &[ - 0x09, 0x09, 0x80, 0x01, 0x05, 0xbf, 0x0a, 0x8b, 0x14, 0x57, 0x6a, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - { - let val = core::f64::consts::LN_2; - let expected = &[ - 0x09, 0x0a, 0x81, 0xff, 0xff, 0x6, 0x2e, 0x42, 0xfe, 0xfa, 0x39, 0xf0, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - } - - #[test] - fn encdec_reasonable_f64() { - // Tests the encoding and decoding of reals with some arbitrary numbers - { - // rec1value R ::= { mantissa 2414341043715239, base 2, exponent 21 } - let val = 3221417.1584163485; - let expected = &[ - 0x9, 0x9, 0x80, 0x15, 0x8, 0x93, 0xd4, 0x94, 0x46, 0xfc, 0xa7, - ]; - let mut buffer = [0u8; 11]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec1value R ::= { mantissa 2671155248072715, base 2, exponent 23 } - let val = 13364022.365665454; - let expected = &[ - 0x09, 0x09, 0x80, 0x17, 0x09, 0x7d, 0x66, 0xcb, 0xb3, 0x88, 0x0b, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec1value R ::= { mantissa -4386812962460287, base 2, exponent 14 } - let val = -32343.132588105735; - let expected = &[ - 0x09, 0x09, 0xc0, 0x0e, 0x0f, 0x95, 0xc8, 0x7c, 0x52, 0xd2, 0x7f, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = -27084.866751869475; - let expected = &[ - 0x09, 0x09, 0xc0, 0x0e, 0x0a, 0x73, 0x37, 0x78, 0xdc, 0xd5, 0x4a, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - // rec1value R ::= { mantissa -4372913134428149, base 2, exponent 7 } - let val = -252.28566647111404; - let expected = &[ - 0x09, 0x09, 0xc0, 0x07, 0x0f, 0x89, 0x24, 0x2e, 0x02, 0xdf, 0xf5, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = -14.399709612928548; - let expected = &[ - 0x09, 0x09, 0xc0, 0x03, 0x0c, 0xcc, 0xa6, 0xbd, 0x06, 0xd9, 0x92, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = -0.08340570261832964; - let expected = &[ - 0x09, 0x0a, 0xc1, 0xff, 0xfc, 0x05, 0x5a, 0x13, 0x7d, 0x0b, 0xae, 0x3d, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = 0.00536851453803701; - let expected = &[ - 0x09, 0x0a, 0x81, 0xff, 0xf8, 0x05, 0xfd, 0x4b, 0xa5, 0xe7, 0x4c, 0x93, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = 0.00045183525648866433; - let expected = &[ - 0x09, 0x0a, 0x81, 0xff, 0xf4, 0x0d, 0x9c, 0x89, 0xa6, 0x59, 0x33, 0x39, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = 0.000033869092002682955; - let expected = &[ - 0x09, 0x0a, 0x81, 0xff, 0xf1, 0x01, 0xc1, 0xd5, 0x23, 0xd5, 0x54, 0x7c, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = 0.0000011770891033600088; - let expected = &[ - 0x09, 0x0a, 0x81, 0xff, 0xec, 0x03, 0xbf, 0x8f, 0x27, 0xf4, 0x62, 0x56, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = 0.00000005549514041997082; - let expected = &[ - 0x09, 0x0a, 0x81, 0xff, 0xe7, 0x0d, 0xcb, 0x31, 0xab, 0x6e, 0xb8, 0xd7, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = 0.0000000012707044685547803; - let expected = &[ - 0x09, 0x0a, 0x81, 0xff, 0xe2, 0x05, 0xd4, 0x9e, 0x0a, 0xf2, 0xff, 0x1f, - ]; - let mut buffer = [0u8; 12]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - - { - let val = 0.00000000002969611878378562; - let expected = &[ - 0x09, 0x09, 0x81, 0xff, 0xdd, 0x53, 0x5b, 0x6f, 0x97, 0xee, 0xb6, - ]; - let mut buffer = [0u8; 11]; - let encoded = val.encode_to_slice(&mut buffer).unwrap(); - assert_eq!( - expected, encoded, - "invalid encoding of {}:\ngot {:x?}\nwant: {:x?}", - val, encoded, expected - ); - let decoded = f64::from_der(encoded).unwrap(); - assert!( - (decoded - val).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - val, - decoded - ); - } - } - - #[test] - fn reject_non_canonical() { - assert!(f64::from_der(&[0x09, 0x81, 0x00]).is_err()); - } - - #[test] - fn encdec_f64() { - use super::{decode_f64, encode_f64}; - // Test that the extraction and recreation works - for val in [ - 1.0, - 0.1, - -0.1, - -1.0, - 0.0, - f64::MIN_POSITIVE, - f64::MAX, - f64::MIN, - 3.1415, - 951.2357864, - -3.1415, - -951.2357864, - ] { - let (s, e, m) = decode_f64(val); - let val2 = encode_f64(s, e, m); - assert!( - (val - val2).abs() < f64::EPSILON, - "fail - want {}\tgot {}", - val, - val2 - ); - } - } - - #[test] - fn validation_cases() { - // Caveat: these test cases are validated on the ASN.1 playground: https://asn1.io/asn1playground/ . - // The test case consists in inputing the bytes in the "decode" field and checking that the decoded - // value corresponds to the one encoded here. - // This tool encodes _all_ values that are non-zero in the ISO 6093 NR3 representation. - // This does not seem to perfectly adhere to the ITU specifications, Special Cases section. - // The implementation of this crate correctly supports decoding such values. It will, however, - // systematically encode REALs in their base 2 form, with a scaling factor where needed to - // ensure that the mantissa is either odd or zero (as per section 11.3.1). - - // Positive trivial numbers - { - let expect = 10.0; - let testcase = &[0x09, 0x05, 0x03, 0x31, 0x2E, 0x45, 0x31]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = 100.0; - let testcase = &[0x09, 0x05, 0x03, 0x31, 0x2E, 0x45, 0x32]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = 101.0; - let testcase = &[0x09, 0x08, 0x03, 0x31, 0x30, 0x31, 0x2E, 0x45, 0x2B, 0x30]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = 101.0; - let testcase = &[0x09, 0x08, 0x03, 0x31, 0x30, 0x31, 0x2E, 0x45, 0x2B, 0x30]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = 0.0; - let testcase = &[0x09, 0x00]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = 951.2357864; - let testcase = &[ - 0x09, 0x0F, 0x03, 0x39, 0x35, 0x31, 0x32, 0x33, 0x35, 0x37, 0x38, 0x36, 0x34, 0x2E, - 0x45, 0x2D, 0x37, - ]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - // Negative trivial numbers - { - let expect = -10.0; - let testcase = &[0x09, 0x06, 0x03, 0x2D, 0x31, 0x2E, 0x45, 0x31]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = -100.0; - let testcase = &[0x09, 0x06, 0x03, 0x2D, 0x31, 0x2E, 0x45, 0x32]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = -101.0; - let testcase = &[ - 0x09, 0x09, 0x03, 0x2D, 0x31, 0x30, 0x31, 0x2E, 0x45, 0x2B, 0x30, - ]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = -0.5; - let testcase = &[0x09, 0x07, 0x03, 0x2D, 0x35, 0x2E, 0x45, 0x2D, 0x31]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - let expect = -0.0; - let testcase = &[0x09, 0x03, 0x01, 0x2D, 0x30]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - { - // Test NR3 decoding - let expect = -951.2357864; - let testcase = &[ - 0x09, 0x10, 0x03, 0x2D, 0x39, 0x35, 0x31, 0x32, 0x33, 0x35, 0x37, 0x38, 0x36, 0x34, - 0x2E, 0x45, 0x2D, 0x37, - ]; - let decoded = f64::from_der(testcase).unwrap(); - assert!( - (decoded - expect).abs() < f64::EPSILON, - "wanted: {}\tgot: {}", - expect, - decoded - ); - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence.rs deleted file mode 100644 index ad4a5d52e5a2..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence.rs +++ /dev/null @@ -1,53 +0,0 @@ -//! The [`Sequence`] trait simplifies writing decoders/encoders which map ASN.1 -//! `SEQUENCE`s to Rust structs. - -use crate::{ - BytesRef, DecodeValue, EncodeValue, FixedTag, Header, Length, Reader, Result, Tag, Writer, -}; - -#[cfg(feature = "alloc")] -use alloc::boxed::Box; - -/// Marker trait for ASN.1 `SEQUENCE`s. -/// -/// This is mainly used for custom derive. -pub trait Sequence<'a>: DecodeValue<'a> + EncodeValue {} - -impl<'a, S> FixedTag for S -where - S: Sequence<'a>, -{ - const TAG: Tag = Tag::Sequence; -} - -#[cfg(feature = "alloc")] -impl<'a, T> Sequence<'a> for Box where T: Sequence<'a> {} - -/// The [`SequenceRef`] type provides raw access to the octets which comprise a -/// DER-encoded `SEQUENCE`. -/// -/// This is a zero-copy reference type which borrows from the input data. -pub struct SequenceRef<'a> { - /// Body of the `SEQUENCE`. - body: BytesRef<'a>, -} - -impl<'a> DecodeValue<'a> for SequenceRef<'a> { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Ok(Self { - body: BytesRef::decode_value(reader, header)?, - }) - } -} - -impl EncodeValue for SequenceRef<'_> { - fn value_len(&self) -> Result { - Ok(self.body.len()) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - self.body.encode_value(writer) - } -} - -impl<'a> Sequence<'a> for SequenceRef<'a> {} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence_of.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence_of.rs deleted file mode 100644 index befb0298f829..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence_of.rs +++ /dev/null @@ -1,230 +0,0 @@ -//! ASN.1 `SEQUENCE OF` support. - -use crate::{ - arrayvec, ord::iter_cmp, ArrayVec, Decode, DecodeValue, DerOrd, Encode, EncodeValue, FixedTag, - Header, Length, Reader, Result, Tag, ValueOrd, Writer, -}; -use core::cmp::Ordering; - -#[cfg(feature = "alloc")] -use alloc::vec::Vec; - -/// ASN.1 `SEQUENCE OF` backed by an array. -/// -/// This type implements an append-only `SEQUENCE OF` type which is stack-based -/// and does not depend on `alloc` support. -// TODO(tarcieri): use `ArrayVec` when/if it's merged into `core` -// See: https://github.com/rust-lang/rfcs/pull/2990 -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct SequenceOf { - inner: ArrayVec, -} - -impl SequenceOf { - /// Create a new [`SequenceOf`]. - pub fn new() -> Self { - Self { - inner: ArrayVec::new(), - } - } - - /// Add an element to this [`SequenceOf`]. - pub fn add(&mut self, element: T) -> Result<()> { - self.inner.push(element) - } - - /// Get an element of this [`SequenceOf`]. - pub fn get(&self, index: usize) -> Option<&T> { - self.inner.get(index) - } - - /// Iterate over the elements in this [`SequenceOf`]. - pub fn iter(&self) -> SequenceOfIter<'_, T> { - SequenceOfIter { - inner: self.inner.iter(), - } - } - - /// Is this [`SequenceOf`] empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - /// Number of elements in this [`SequenceOf`]. - pub fn len(&self) -> usize { - self.inner.len() - } -} - -impl Default for SequenceOf { - fn default() -> Self { - Self::new() - } -} - -impl<'a, T, const N: usize> DecodeValue<'a> for SequenceOf -where - T: Decode<'a>, -{ - fn decode_value>(reader: &mut R, header: Header) -> Result { - reader.read_nested(header.length, |reader| { - let mut sequence_of = Self::new(); - - while !reader.is_finished() { - sequence_of.add(T::decode(reader)?)?; - } - - Ok(sequence_of) - }) - } -} - -impl EncodeValue for SequenceOf -where - T: Encode, -{ - fn value_len(&self) -> Result { - self.iter() - .fold(Ok(Length::ZERO), |len, elem| len + elem.encoded_len()?) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - for elem in self.iter() { - elem.encode(writer)?; - } - - Ok(()) - } -} - -impl FixedTag for SequenceOf { - const TAG: Tag = Tag::Sequence; -} - -impl ValueOrd for SequenceOf -where - T: DerOrd, -{ - fn value_cmp(&self, other: &Self) -> Result { - iter_cmp(self.iter(), other.iter()) - } -} - -/// Iterator over the elements of an [`SequenceOf`]. -#[derive(Clone, Debug)] -pub struct SequenceOfIter<'a, T> { - /// Inner iterator. - inner: arrayvec::Iter<'a, T>, -} - -impl<'a, T> Iterator for SequenceOfIter<'a, T> { - type Item = &'a T; - - fn next(&mut self) -> Option<&'a T> { - self.inner.next() - } -} - -impl<'a, T> ExactSizeIterator for SequenceOfIter<'a, T> {} - -impl<'a, T, const N: usize> DecodeValue<'a> for [T; N] -where - T: Decode<'a>, -{ - fn decode_value>(reader: &mut R, header: Header) -> Result { - let sequence_of = SequenceOf::::decode_value(reader, header)?; - - // TODO(tarcieri): use `[T; N]::try_map` instead of `expect` when stable - if sequence_of.inner.len() == N { - Ok(sequence_of - .inner - .into_array() - .map(|elem| elem.expect("arrayvec length mismatch"))) - } else { - Err(Self::TAG.length_error()) - } - } -} - -impl EncodeValue for [T; N] -where - T: Encode, -{ - fn value_len(&self) -> Result { - self.iter() - .fold(Ok(Length::ZERO), |len, elem| len + elem.encoded_len()?) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - for elem in self { - elem.encode(writer)?; - } - - Ok(()) - } -} - -impl FixedTag for [T; N] { - const TAG: Tag = Tag::Sequence; -} - -impl ValueOrd for [T; N] -where - T: DerOrd, -{ - fn value_cmp(&self, other: &Self) -> Result { - iter_cmp(self.iter(), other.iter()) - } -} - -#[cfg(feature = "alloc")] -impl<'a, T> DecodeValue<'a> for Vec -where - T: Decode<'a>, -{ - fn decode_value>(reader: &mut R, header: Header) -> Result { - reader.read_nested(header.length, |reader| { - let mut sequence_of = Self::new(); - - while !reader.is_finished() { - sequence_of.push(T::decode(reader)?); - } - - Ok(sequence_of) - }) - } -} - -#[cfg(feature = "alloc")] -impl EncodeValue for Vec -where - T: Encode, -{ - fn value_len(&self) -> Result { - self.iter() - .fold(Ok(Length::ZERO), |len, elem| len + elem.encoded_len()?) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - for elem in self { - elem.encode(writer)?; - } - - Ok(()) - } -} - -#[cfg(feature = "alloc")] -impl FixedTag for Vec { - const TAG: Tag = Tag::Sequence; -} - -#[cfg(feature = "alloc")] -impl ValueOrd for Vec -where - T: DerOrd, -{ - fn value_cmp(&self, other: &Self) -> Result { - iter_cmp(self.iter(), other.iter()) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/set_of.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/set_of.rs deleted file mode 100644 index ff0131242024..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/set_of.rs +++ /dev/null @@ -1,539 +0,0 @@ -//! ASN.1 `SET OF` support. -//! -//! # Ordering Notes -//! -//! Some DER serializer implementations fail to properly sort elements of a -//! `SET OF`. This is technically non-canonical, but occurs frequently -//! enough that most DER decoders tolerate it. Unfortunately because -//! of that, we must also follow suit. -//! -//! However, all types in this module sort elements of a set at decode-time, -//! ensuring they'll be in the proper order if reserialized. - -use crate::{ - arrayvec, ord::iter_cmp, ArrayVec, Decode, DecodeValue, DerOrd, Encode, EncodeValue, Error, - ErrorKind, FixedTag, Header, Length, Reader, Result, Tag, ValueOrd, Writer, -}; -use core::cmp::Ordering; - -#[cfg(feature = "alloc")] -use {alloc::vec::Vec, core::slice}; - -/// ASN.1 `SET OF` backed by an array. -/// -/// This type implements an append-only `SET OF` type which is stack-based -/// and does not depend on `alloc` support. -// TODO(tarcieri): use `ArrayVec` when/if it's merged into `core` -// See: https://github.com/rust-lang/rfcs/pull/2990 -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct SetOf -where - T: DerOrd, -{ - inner: ArrayVec, -} - -impl SetOf -where - T: DerOrd, -{ - /// Create a new [`SetOf`]. - pub fn new() -> Self { - Self { - inner: ArrayVec::default(), - } - } - - /// Add an item to this [`SetOf`]. - /// - /// Items MUST be added in lexicographical order according to the - /// [`DerOrd`] impl on `T`. - #[deprecated(since = "0.7.6", note = "use `insert` or `insert_ordered` instead")] - pub fn add(&mut self, new_elem: T) -> Result<()> { - self.insert_ordered(new_elem) - } - - /// Insert an item into this [`SetOf`]. - pub fn insert(&mut self, item: T) -> Result<()> { - self.inner.push(item)?; - der_sort(self.inner.as_mut()) - } - - /// Insert an item into this [`SetOf`]. - /// - /// Items MUST be added in lexicographical order according to the - /// [`DerOrd`] impl on `T`. - pub fn insert_ordered(&mut self, item: T) -> Result<()> { - // Ensure set elements are lexicographically ordered - if let Some(last) = self.inner.last() { - check_der_ordering(last, &item)?; - } - - self.inner.push(item) - } - - /// Get the nth element from this [`SetOf`]. - pub fn get(&self, index: usize) -> Option<&T> { - self.inner.get(index) - } - - /// Iterate over the elements of this [`SetOf`]. - pub fn iter(&self) -> SetOfIter<'_, T> { - SetOfIter { - inner: self.inner.iter(), - } - } - - /// Is this [`SetOf`] empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - /// Number of elements in this [`SetOf`]. - pub fn len(&self) -> usize { - self.inner.len() - } -} - -impl Default for SetOf -where - T: DerOrd, -{ - fn default() -> Self { - Self::new() - } -} - -impl<'a, T, const N: usize> DecodeValue<'a> for SetOf -where - T: Decode<'a> + DerOrd, -{ - fn decode_value>(reader: &mut R, header: Header) -> Result { - reader.read_nested(header.length, |reader| { - let mut result = Self::new(); - - while !reader.is_finished() { - result.inner.push(T::decode(reader)?)?; - } - - der_sort(result.inner.as_mut())?; - validate(result.inner.as_ref())?; - Ok(result) - }) - } -} - -impl<'a, T, const N: usize> EncodeValue for SetOf -where - T: 'a + Decode<'a> + Encode + DerOrd, -{ - fn value_len(&self) -> Result { - self.iter() - .fold(Ok(Length::ZERO), |len, elem| len + elem.encoded_len()?) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - for elem in self.iter() { - elem.encode(writer)?; - } - - Ok(()) - } -} - -impl<'a, T, const N: usize> FixedTag for SetOf -where - T: Decode<'a> + DerOrd, -{ - const TAG: Tag = Tag::Set; -} - -impl TryFrom<[T; N]> for SetOf -where - T: DerOrd, -{ - type Error = Error; - - fn try_from(mut arr: [T; N]) -> Result> { - der_sort(&mut arr)?; - - let mut result = SetOf::new(); - - for elem in arr { - result.insert_ordered(elem)?; - } - - Ok(result) - } -} - -impl ValueOrd for SetOf -where - T: DerOrd, -{ - fn value_cmp(&self, other: &Self) -> Result { - iter_cmp(self.iter(), other.iter()) - } -} - -/// Iterator over the elements of an [`SetOf`]. -#[derive(Clone, Debug)] -pub struct SetOfIter<'a, T> { - /// Inner iterator. - inner: arrayvec::Iter<'a, T>, -} - -impl<'a, T> Iterator for SetOfIter<'a, T> { - type Item = &'a T; - - fn next(&mut self) -> Option<&'a T> { - self.inner.next() - } -} - -impl<'a, T> ExactSizeIterator for SetOfIter<'a, T> {} - -/// ASN.1 `SET OF` backed by a [`Vec`]. -/// -/// This type implements an append-only `SET OF` type which is heap-backed -/// and depends on `alloc` support. -#[cfg(feature = "alloc")] -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct SetOfVec -where - T: DerOrd, -{ - inner: Vec, -} - -#[cfg(feature = "alloc")] -impl Default for SetOfVec { - fn default() -> Self { - Self { - inner: Default::default(), - } - } -} - -#[cfg(feature = "alloc")] -impl SetOfVec -where - T: DerOrd, -{ - /// Create a new [`SetOfVec`]. - pub fn new() -> Self { - Self { - inner: Vec::default(), - } - } - - /// Create a new [`SetOfVec`] from the given iterator. - /// - /// Note: this is an inherent method instead of an impl of the - /// [`FromIterator`] trait in order to be fallible. - #[allow(clippy::should_implement_trait)] - pub fn from_iter(iter: I) -> Result - where - I: IntoIterator, - { - Vec::from_iter(iter).try_into() - } - - /// Add an element to this [`SetOfVec`]. - /// - /// Items MUST be added in lexicographical order according to the - /// [`DerOrd`] impl on `T`. - #[deprecated(since = "0.7.6", note = "use `insert` or `insert_ordered` instead")] - pub fn add(&mut self, item: T) -> Result<()> { - self.insert_ordered(item) - } - - /// Extend a [`SetOfVec`] using an iterator. - /// - /// Note: this is an inherent method instead of an impl of the - /// [`Extend`] trait in order to be fallible. - pub fn extend(&mut self, iter: I) -> Result<()> - where - I: IntoIterator, - { - self.inner.extend(iter); - der_sort(&mut self.inner) - } - - /// Insert an item into this [`SetOfVec`]. Must be unique. - pub fn insert(&mut self, item: T) -> Result<()> { - self.inner.push(item); - der_sort(&mut self.inner) - } - - /// Insert an item into this [`SetOfVec`]. Must be unique. - /// - /// Items MUST be added in lexicographical order according to the - /// [`DerOrd`] impl on `T`. - pub fn insert_ordered(&mut self, item: T) -> Result<()> { - // Ensure set elements are lexicographically ordered - if let Some(last) = self.inner.last() { - check_der_ordering(last, &item)?; - } - - self.inner.push(item); - Ok(()) - } - - /// Borrow the elements of this [`SetOfVec`] as a slice. - pub fn as_slice(&self) -> &[T] { - self.inner.as_slice() - } - - /// Get the nth element from this [`SetOfVec`]. - pub fn get(&self, index: usize) -> Option<&T> { - self.inner.get(index) - } - - /// Convert this [`SetOfVec`] into the inner [`Vec`]. - pub fn into_vec(self) -> Vec { - self.inner - } - - /// Iterate over the elements of this [`SetOfVec`]. - pub fn iter(&self) -> slice::Iter<'_, T> { - self.inner.iter() - } - - /// Is this [`SetOfVec`] empty? - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - /// Number of elements in this [`SetOfVec`]. - pub fn len(&self) -> usize { - self.inner.len() - } -} - -#[cfg(feature = "alloc")] -impl AsRef<[T]> for SetOfVec -where - T: DerOrd, -{ - fn as_ref(&self) -> &[T] { - self.as_slice() - } -} - -#[cfg(feature = "alloc")] -impl<'a, T> DecodeValue<'a> for SetOfVec -where - T: Decode<'a> + DerOrd, -{ - fn decode_value>(reader: &mut R, header: Header) -> Result { - reader.read_nested(header.length, |reader| { - let mut inner = Vec::new(); - - while !reader.is_finished() { - inner.push(T::decode(reader)?); - } - - der_sort(inner.as_mut())?; - validate(inner.as_ref())?; - Ok(Self { inner }) - }) - } -} - -#[cfg(feature = "alloc")] -impl<'a, T> EncodeValue for SetOfVec -where - T: 'a + Decode<'a> + Encode + DerOrd, -{ - fn value_len(&self) -> Result { - self.iter() - .fold(Ok(Length::ZERO), |len, elem| len + elem.encoded_len()?) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - for elem in self.iter() { - elem.encode(writer)?; - } - - Ok(()) - } -} - -#[cfg(feature = "alloc")] -impl FixedTag for SetOfVec -where - T: DerOrd, -{ - const TAG: Tag = Tag::Set; -} - -#[cfg(feature = "alloc")] -impl From> for Vec -where - T: DerOrd, -{ - fn from(set: SetOfVec) -> Vec { - set.into_vec() - } -} - -#[cfg(feature = "alloc")] -impl TryFrom> for SetOfVec -where - T: DerOrd, -{ - type Error = Error; - - fn try_from(mut vec: Vec) -> Result> { - der_sort(vec.as_mut_slice())?; - Ok(SetOfVec { inner: vec }) - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<[T; N]> for SetOfVec -where - T: DerOrd, -{ - type Error = Error; - - fn try_from(arr: [T; N]) -> Result> { - Vec::from(arr).try_into() - } -} - -#[cfg(feature = "alloc")] -impl ValueOrd for SetOfVec -where - T: DerOrd, -{ - fn value_cmp(&self, other: &Self) -> Result { - iter_cmp(self.iter(), other.iter()) - } -} - -// Implement by hand because the derive would create invalid values. -// Use the conversion from Vec to create a valid value. -#[cfg(feature = "arbitrary")] -impl<'a, T> arbitrary::Arbitrary<'a> for SetOfVec -where - T: DerOrd + arbitrary::Arbitrary<'a>, -{ - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - Self::try_from( - u.arbitrary_iter()? - .collect::, _>>()?, - ) - .map_err(|_| arbitrary::Error::IncorrectFormat) - } - - fn size_hint(_depth: usize) -> (usize, Option) { - (0, None) - } -} - -/// Ensure set elements are lexicographically ordered using [`DerOrd`]. -fn check_der_ordering(a: &T, b: &T) -> Result<()> { - match a.der_cmp(b)? { - Ordering::Less => Ok(()), - Ordering::Equal => Err(ErrorKind::SetDuplicate.into()), - Ordering::Greater => Err(ErrorKind::SetOrdering.into()), - } -} - -/// Sort a mut slice according to its [`DerOrd`], returning any errors which -/// might occur during the comparison. -/// -/// The algorithm is insertion sort, which should perform well when the input -/// is mostly sorted to begin with. -/// -/// This function is used rather than Rust's built-in `[T]::sort_by` in order -/// to support heapless `no_std` targets as well as to enable bubbling up -/// sorting errors. -#[allow(clippy::integer_arithmetic)] -fn der_sort(slice: &mut [T]) -> Result<()> { - for i in 0..slice.len() { - let mut j = i; - - while j > 0 { - match slice[j - 1].der_cmp(&slice[j])? { - Ordering::Less => break, - Ordering::Equal => return Err(ErrorKind::SetDuplicate.into()), - Ordering::Greater => { - slice.swap(j - 1, j); - j -= 1; - } - } - } - } - - Ok(()) -} - -/// Validate the elements of a `SET OF`, ensuring that they are all in order -/// and that there are no duplicates. -fn validate(slice: &[T]) -> Result<()> { - if let Some(len) = slice.len().checked_sub(1) { - for i in 0..len { - let j = i.checked_add(1).ok_or(ErrorKind::Overflow)?; - - match slice.get(i..=j) { - Some([a, b]) => { - if a.der_cmp(b)? != Ordering::Less { - return Err(ErrorKind::SetOrdering.into()); - } - } - _ => return Err(Tag::Set.value_error()), - } - } - } - - Ok(()) -} - -#[cfg(test)] -mod tests { - use super::SetOf; - #[cfg(feature = "alloc")] - use super::SetOfVec; - use crate::ErrorKind; - - #[test] - fn setof_tryfrom_array() { - let arr = [3u16, 2, 1, 65535, 0]; - let set = SetOf::try_from(arr).unwrap(); - assert!(set.iter().copied().eq([0, 1, 2, 3, 65535])); - } - - #[test] - fn setof_tryfrom_array_reject_duplicates() { - let arr = [1u16, 1]; - let err = SetOf::try_from(arr).err().unwrap(); - assert_eq!(err.kind(), ErrorKind::SetDuplicate); - } - - #[cfg(feature = "alloc")] - #[test] - fn setofvec_tryfrom_array() { - let arr = [3u16, 2, 1, 65535, 0]; - let set = SetOfVec::try_from(arr).unwrap(); - assert_eq!(set.as_ref(), &[0, 1, 2, 3, 65535]); - } - - #[cfg(feature = "alloc")] - #[test] - fn setofvec_tryfrom_vec() { - let vec = vec![3u16, 2, 1, 65535, 0]; - let set = SetOfVec::try_from(vec).unwrap(); - assert_eq!(set.as_ref(), &[0, 1, 2, 3, 65535]); - } - - #[cfg(feature = "alloc")] - #[test] - fn setofvec_tryfrom_vec_reject_duplicates() { - let vec = vec![1u16, 1]; - let err = SetOfVec::try_from(vec).err().unwrap(); - assert_eq!(err.kind(), ErrorKind::SetDuplicate); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/teletex_string.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/teletex_string.rs deleted file mode 100644 index 337c071e5e65..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/teletex_string.rs +++ /dev/null @@ -1,217 +0,0 @@ -//! ASN.1 `TeletexString` support. -//! -use crate::{asn1::AnyRef, FixedTag, Result, StrRef, Tag}; -use core::{fmt, ops::Deref}; - -macro_rules! impl_teletex_string { - ($type: ty) => { - impl_teletex_string!($type,); - }; - ($type: ty, $($li: lifetime)?) => { - impl_string_type!($type, $($li),*); - - impl<$($li),*> FixedTag for $type { - const TAG: Tag = Tag::TeletexString; - } - - impl<$($li),*> fmt::Debug for $type { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "TeletexString({:?})", self.as_str()) - } - } - }; -} - -/// ASN.1 `TeletexString` type. -/// -/// Supports a subset the ASCII character set (described below). -/// -/// For UTF-8, use [`Utf8StringRef`][`crate::asn1::Utf8StringRef`] instead. -/// For the full ASCII character set, use -/// [`Ia5StringRef`][`crate::asn1::Ia5StringRef`]. -/// -/// This is a zero-copy reference type which borrows from the input data. -/// -/// # Supported characters -/// -/// The standard defines a complex character set allowed in this type. However, quoting the ASN.1 -/// mailing list, "a sizable volume of software in the world treats TeletexString (T61String) as a -/// simple 8-bit string with mostly Windows Latin 1 (superset of iso-8859-1) encoding". -/// -#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)] -pub struct TeletexStringRef<'a> { - /// Inner value - inner: StrRef<'a>, -} - -impl<'a> TeletexStringRef<'a> { - /// Create a new ASN.1 `TeletexString`. - pub fn new(input: &'a T) -> Result - where - T: AsRef<[u8]> + ?Sized, - { - let input = input.as_ref(); - - // FIXME: support higher part of the charset - if input.iter().any(|&c| c > 0x7F) { - return Err(Self::TAG.value_error()); - } - - StrRef::from_bytes(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } -} - -impl_teletex_string!(TeletexStringRef<'a>, 'a); - -impl<'a> Deref for TeletexStringRef<'a> { - type Target = StrRef<'a>; - - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl<'a> From<&TeletexStringRef<'a>> for TeletexStringRef<'a> { - fn from(value: &TeletexStringRef<'a>) -> TeletexStringRef<'a> { - *value - } -} - -impl<'a> From> for AnyRef<'a> { - fn from(teletex_string: TeletexStringRef<'a>) -> AnyRef<'a> { - AnyRef::from_tag_and_value(Tag::TeletexString, teletex_string.inner.into()) - } -} - -#[cfg(feature = "alloc")] -pub use self::allocation::TeletexString; - -#[cfg(feature = "alloc")] -mod allocation { - use super::TeletexStringRef; - - use crate::{ - asn1::AnyRef, - referenced::{OwnedToRef, RefToOwned}, - BytesRef, Error, FixedTag, Result, StrOwned, Tag, - }; - use alloc::string::String; - use core::{fmt, ops::Deref}; - - /// ASN.1 `TeletexString` type. - /// - /// Supports a subset the ASCII character set (described below). - /// - /// For UTF-8, use [`Utf8StringRef`][`crate::asn1::Utf8StringRef`] instead. - /// For the full ASCII character set, use - /// [`Ia5StringRef`][`crate::asn1::Ia5StringRef`]. - /// - /// # Supported characters - /// - /// The standard defines a complex character set allowed in this type. However, quoting the ASN.1 - /// mailing list, "a sizable volume of software in the world treats TeletexString (T61String) as a - /// simple 8-bit string with mostly Windows Latin 1 (superset of iso-8859-1) encoding". - /// - #[derive(Clone, Eq, PartialEq, PartialOrd, Ord)] - pub struct TeletexString { - /// Inner value - inner: StrOwned, - } - - impl TeletexString { - /// Create a new ASN.1 `TeletexString`. - pub fn new(input: &T) -> Result - where - T: AsRef<[u8]> + ?Sized, - { - let input = input.as_ref(); - - TeletexStringRef::new(input)?; - - StrOwned::from_bytes(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } - } - - impl_teletex_string!(TeletexString); - - impl Deref for TeletexString { - type Target = StrOwned; - - fn deref(&self) -> &Self::Target { - &self.inner - } - } - - impl<'a> From> for TeletexString { - fn from(value: TeletexStringRef<'a>) -> TeletexString { - let inner = - StrOwned::from_bytes(value.inner.as_bytes()).expect("Invalid TeletexString"); - Self { inner } - } - } - - impl<'a> From<&'a TeletexString> for AnyRef<'a> { - fn from(teletex_string: &'a TeletexString) -> AnyRef<'a> { - AnyRef::from_tag_and_value( - Tag::TeletexString, - BytesRef::new(teletex_string.inner.as_bytes()).expect("Invalid TeletexString"), - ) - } - } - - impl<'a> RefToOwned<'a> for TeletexStringRef<'a> { - type Owned = TeletexString; - fn ref_to_owned(&self) -> Self::Owned { - TeletexString { - inner: self.inner.ref_to_owned(), - } - } - } - - impl OwnedToRef for TeletexString { - type Borrowed<'a> = TeletexStringRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - TeletexStringRef { - inner: self.inner.owned_to_ref(), - } - } - } - - impl TryFrom for TeletexString { - type Error = Error; - - fn try_from(input: String) -> Result { - TeletexStringRef::new(&input)?; - - StrOwned::new(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } - } -} - -#[cfg(test)] -mod tests { - use super::TeletexStringRef; - use crate::Decode; - use crate::SliceWriter; - - #[test] - fn parse_bytes() { - let example_bytes = &[ - 0x14, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x65, 0x72, 0x20, 0x31, - ]; - - let teletex_string = TeletexStringRef::from_der(example_bytes).unwrap(); - assert_eq!(teletex_string.as_str(), "Test User 1"); - let mut out = [0_u8; 30]; - let mut writer = SliceWriter::new(&mut out); - writer.encode(&teletex_string).unwrap(); - let encoded = writer.finish().unwrap(); - assert_eq!(encoded, example_bytes); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utc_time.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utc_time.rs deleted file mode 100644 index 9f2f1713bf8b..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utc_time.rs +++ /dev/null @@ -1,242 +0,0 @@ -//! ASN.1 `UTCTime` support. - -use crate::{ - datetime::{self, DateTime}, - ord::OrdIsValueOrd, - DecodeValue, EncodeValue, Error, ErrorKind, FixedTag, Header, Length, Reader, Result, Tag, - Writer, -}; -use core::time::Duration; - -#[cfg(feature = "std")] -use std::time::SystemTime; - -/// ASN.1 `UTCTime` type. -/// -/// This type implements the validity requirements specified in -/// [RFC 5280 Section 4.1.2.5.1][1], namely: -/// -/// > For the purposes of this profile, UTCTime values MUST be expressed in -/// > Greenwich Mean Time (Zulu) and MUST include seconds (i.e., times are -/// > `YYMMDDHHMMSSZ`), even where the number of seconds is zero. Conforming -/// > systems MUST interpret the year field (`YY`) as follows: -/// > -/// > - Where `YY` is greater than or equal to 50, the year SHALL be -/// > interpreted as `19YY`; and -/// > - Where `YY` is less than 50, the year SHALL be interpreted as `20YY`. -/// -/// Note: Due to common operations working on `UNIX_EPOCH` [`UtcTime`]s are -/// only supported for the years 1970-2049. -/// -/// [1]: https://tools.ietf.org/html/rfc5280#section-4.1.2.5.1 -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct UtcTime(DateTime); - -impl UtcTime { - /// Length of an RFC 5280-flavored ASN.1 DER-encoded [`UtcTime`]. - pub const LENGTH: usize = 13; - - /// Maximum year that can be represented as a `UTCTime`. - pub const MAX_YEAR: u16 = 2049; - - /// Create a [`UtcTime`] from a [`DateTime`]. - pub fn from_date_time(datetime: DateTime) -> Result { - if datetime.year() <= UtcTime::MAX_YEAR { - Ok(Self(datetime)) - } else { - Err(Self::TAG.value_error()) - } - } - - /// Convert this [`UtcTime`] into a [`DateTime`]. - pub fn to_date_time(&self) -> DateTime { - self.0 - } - - /// Create a new [`UtcTime`] given a [`Duration`] since `UNIX_EPOCH` - /// (a.k.a. "Unix time") - pub fn from_unix_duration(unix_duration: Duration) -> Result { - DateTime::from_unix_duration(unix_duration)?.try_into() - } - - /// Get the duration of this timestamp since `UNIX_EPOCH`. - pub fn to_unix_duration(&self) -> Duration { - self.0.unix_duration() - } - - /// Instantiate from [`SystemTime`]. - #[cfg(feature = "std")] - pub fn from_system_time(time: SystemTime) -> Result { - DateTime::try_from(time) - .map_err(|_| Self::TAG.value_error())? - .try_into() - } - - /// Convert to [`SystemTime`]. - #[cfg(feature = "std")] - pub fn to_system_time(&self) -> SystemTime { - self.0.to_system_time() - } -} - -impl_any_conversions!(UtcTime); - -impl<'a> DecodeValue<'a> for UtcTime { - fn decode_value>(reader: &mut R, header: Header) -> Result { - if Self::LENGTH != usize::try_from(header.length)? { - return Err(Self::TAG.value_error()); - } - - let mut bytes = [0u8; Self::LENGTH]; - reader.read_into(&mut bytes)?; - - match bytes { - // RFC 5280 requires mandatory seconds and Z-normalized time zone - [year1, year2, mon1, mon2, day1, day2, hour1, hour2, min1, min2, sec1, sec2, b'Z'] => { - let year = u16::from(datetime::decode_decimal(Self::TAG, year1, year2)?); - let month = datetime::decode_decimal(Self::TAG, mon1, mon2)?; - let day = datetime::decode_decimal(Self::TAG, day1, day2)?; - let hour = datetime::decode_decimal(Self::TAG, hour1, hour2)?; - let minute = datetime::decode_decimal(Self::TAG, min1, min2)?; - let second = datetime::decode_decimal(Self::TAG, sec1, sec2)?; - - // RFC 5280 rules for interpreting the year - let year = if year >= 50 { - year.checked_add(1900) - } else { - year.checked_add(2000) - } - .ok_or(ErrorKind::DateTime)?; - - DateTime::new(year, month, day, hour, minute, second) - .map_err(|_| Self::TAG.value_error()) - .and_then(|dt| Self::from_unix_duration(dt.unix_duration())) - } - _ => Err(Self::TAG.value_error()), - } - } -} - -impl EncodeValue for UtcTime { - fn value_len(&self) -> Result { - Self::LENGTH.try_into() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - let year = match self.0.year() { - y @ 1950..=1999 => y.checked_sub(1900), - y @ 2000..=2049 => y.checked_sub(2000), - _ => return Err(Self::TAG.value_error()), - } - .and_then(|y| u8::try_from(y).ok()) - .ok_or(ErrorKind::DateTime)?; - - datetime::encode_decimal(writer, Self::TAG, year)?; - datetime::encode_decimal(writer, Self::TAG, self.0.month())?; - datetime::encode_decimal(writer, Self::TAG, self.0.day())?; - datetime::encode_decimal(writer, Self::TAG, self.0.hour())?; - datetime::encode_decimal(writer, Self::TAG, self.0.minutes())?; - datetime::encode_decimal(writer, Self::TAG, self.0.seconds())?; - writer.write_byte(b'Z') - } -} - -impl FixedTag for UtcTime { - const TAG: Tag = Tag::UtcTime; -} - -impl OrdIsValueOrd for UtcTime {} - -impl From<&UtcTime> for UtcTime { - fn from(value: &UtcTime) -> UtcTime { - *value - } -} - -impl From for DateTime { - fn from(utc_time: UtcTime) -> DateTime { - utc_time.0 - } -} - -impl From<&UtcTime> for DateTime { - fn from(utc_time: &UtcTime) -> DateTime { - utc_time.0 - } -} - -impl TryFrom for UtcTime { - type Error = Error; - - fn try_from(datetime: DateTime) -> Result { - Self::from_date_time(datetime) - } -} - -impl TryFrom<&DateTime> for UtcTime { - type Error = Error; - - fn try_from(datetime: &DateTime) -> Result { - Self::from_date_time(*datetime) - } -} - -#[cfg(feature = "std")] -impl From for SystemTime { - fn from(utc_time: UtcTime) -> SystemTime { - utc_time.to_system_time() - } -} - -// Implement by hand because the derive would create invalid values. -// Use the conversion from DateTime to create a valid value. -// The DateTime type has a way bigger range of valid years than UtcTime, -// so the DateTime year is mapped into a valid range to throw away less inputs. -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for UtcTime { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - const MIN_YEAR: u16 = 1970; - const VALID_YEAR_COUNT: u16 = UtcTime::MAX_YEAR - MIN_YEAR + 1; - const AVERAGE_SECONDS_IN_YEAR: u64 = 31_556_952; - - let datetime = DateTime::arbitrary(u)?; - let year = datetime.year(); - let duration = datetime.unix_duration(); - - // Clamp the year into a valid range to not throw away too much input - let valid_year = (year.saturating_sub(MIN_YEAR)) - .rem_euclid(VALID_YEAR_COUNT) - .saturating_add(MIN_YEAR); - let year_to_remove = year.saturating_sub(valid_year); - let valid_duration = duration - - Duration::from_secs( - u64::from(year_to_remove).saturating_mul(AVERAGE_SECONDS_IN_YEAR), - ); - - Self::from_date_time(DateTime::from_unix_duration(valid_duration).expect("supported range")) - .map_err(|_| arbitrary::Error::IncorrectFormat) - } - - fn size_hint(depth: usize) -> (usize, Option) { - DateTime::size_hint(depth) - } -} - -#[cfg(test)] -mod tests { - use super::UtcTime; - use crate::{Decode, Encode, SliceWriter}; - use hex_literal::hex; - - #[test] - fn round_trip_vector() { - let example_bytes = hex!("17 0d 39 31 30 35 30 36 32 33 34 35 34 30 5a"); - let utc_time = UtcTime::from_der(&example_bytes).unwrap(); - assert_eq!(utc_time.to_unix_duration().as_secs(), 673573540); - - let mut buf = [0u8; 128]; - let mut encoder = SliceWriter::new(&mut buf); - utc_time.encode(&mut encoder).unwrap(); - assert_eq!(example_bytes, encoder.finish().unwrap()); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utf8_string.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utf8_string.rs deleted file mode 100644 index 6018750a01fe..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utf8_string.rs +++ /dev/null @@ -1,164 +0,0 @@ -//! ASN.1 `UTF8String` support. - -use crate::{ - asn1::AnyRef, ord::OrdIsValueOrd, EncodeValue, Error, FixedTag, Length, Result, StrRef, Tag, - Writer, -}; -use core::{fmt, ops::Deref, str}; - -#[cfg(feature = "alloc")] -use { - crate::{DecodeValue, Header, Reader}, - alloc::{borrow::ToOwned, string::String}, -}; - -/// ASN.1 `UTF8String` type. -/// -/// Supports the full UTF-8 encoding. -/// -/// Note that the [`Decode`][`crate::Decode`] and [`Encode`][`crate::Encode`] -/// traits are impl'd for Rust's [`str`][`prim@str`] primitive, which -/// decodes/encodes as a [`Utf8StringRef`]. -/// -/// You are free to use [`str`][`prim@str`] instead of this type, however it's -/// still provided for explicitness in cases where it might be ambiguous with -/// other ASN.1 string encodings such as -/// [`PrintableStringRef`][`crate::asn1::PrintableStringRef`]. -/// -/// This is a zero-copy reference type which borrows from the input data. -#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)] -pub struct Utf8StringRef<'a> { - /// Inner value - inner: StrRef<'a>, -} - -impl<'a> Utf8StringRef<'a> { - /// Create a new ASN.1 `UTF8String`. - pub fn new(input: &'a T) -> Result - where - T: AsRef<[u8]> + ?Sized, - { - StrRef::from_bytes(input.as_ref()).map(|inner| Self { inner }) - } -} - -impl_string_type!(Utf8StringRef<'a>, 'a); - -impl<'a> Deref for Utf8StringRef<'a> { - type Target = StrRef<'a>; - - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl FixedTag for Utf8StringRef<'_> { - const TAG: Tag = Tag::Utf8String; -} - -impl<'a> From<&Utf8StringRef<'a>> for Utf8StringRef<'a> { - fn from(value: &Utf8StringRef<'a>) -> Utf8StringRef<'a> { - *value - } -} - -impl<'a> From> for AnyRef<'a> { - fn from(utf_string: Utf8StringRef<'a>) -> AnyRef<'a> { - AnyRef::from_tag_and_value(Tag::Utf8String, utf_string.inner.into()) - } -} - -impl<'a> fmt::Debug for Utf8StringRef<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Utf8String({:?})", self.as_str()) - } -} - -impl<'a> TryFrom> for &'a str { - type Error = Error; - - fn try_from(any: AnyRef<'a>) -> Result<&'a str> { - Utf8StringRef::try_from(any).map(|s| s.as_str()) - } -} - -impl EncodeValue for str { - fn value_len(&self) -> Result { - Utf8StringRef::new(self)?.value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - Utf8StringRef::new(self)?.encode_value(writer) - } -} - -impl FixedTag for str { - const TAG: Tag = Tag::Utf8String; -} - -impl OrdIsValueOrd for str {} - -#[cfg(feature = "alloc")] -impl<'a> From> for String { - fn from(s: Utf8StringRef<'a>) -> String { - s.as_str().to_owned() - } -} - -#[cfg(feature = "alloc")] -impl<'a> TryFrom> for String { - type Error = Error; - - fn try_from(any: AnyRef<'a>) -> Result { - Utf8StringRef::try_from(any).map(|s| s.as_str().to_owned()) - } -} - -#[cfg(feature = "alloc")] -impl<'a> DecodeValue<'a> for String { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Ok(String::from_utf8(reader.read_vec(header.length)?)?) - } -} - -#[cfg(feature = "alloc")] -impl EncodeValue for String { - fn value_len(&self) -> Result { - Utf8StringRef::new(self)?.value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - Utf8StringRef::new(self)?.encode_value(writer) - } -} - -#[cfg(feature = "alloc")] -impl FixedTag for String { - const TAG: Tag = Tag::Utf8String; -} - -#[cfg(feature = "alloc")] -impl OrdIsValueOrd for String {} - -#[cfg(test)] -mod tests { - use super::Utf8StringRef; - use crate::Decode; - - #[test] - fn parse_ascii_bytes() { - let example_bytes = &[ - 0x0c, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x65, 0x72, 0x20, 0x31, - ]; - - let utf8_string = Utf8StringRef::from_der(example_bytes).unwrap(); - assert_eq!(utf8_string.as_str(), "Test User 1"); - } - - #[test] - fn parse_utf8_bytes() { - let example_bytes = &[0x0c, 0x06, 0x48, 0x65, 0x6c, 0x6c, 0xc3, 0xb3]; - let utf8_string = Utf8StringRef::from_der(example_bytes).unwrap(); - assert_eq!(utf8_string.as_str(), "Helló"); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/videotex_string.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/videotex_string.rs deleted file mode 100644 index 55b1a49cf712..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/videotex_string.rs +++ /dev/null @@ -1,98 +0,0 @@ -//! ASN.1 `VideotexString` support. - -use crate::{asn1::AnyRef, FixedTag, Result, StrRef, Tag}; -use core::{fmt, ops::Deref}; - -/// ASN.1 `VideotexString` type. -/// -/// Supports a subset the ASCII character set (described below). -/// -/// For UTF-8, use [`Utf8StringRef`][`crate::asn1::Utf8StringRef`] instead. -/// For the full ASCII character set, use -/// [`Ia5StringRef`][`crate::asn1::Ia5StringRef`]. -/// -/// This is a zero-copy reference type which borrows from the input data. -/// -/// # Supported characters -/// -/// For the practical purposes VideotexString is treated as IA5string, disallowing non-ASCII chars. -/// -#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)] -pub struct VideotexStringRef<'a> { - /// Inner value - inner: StrRef<'a>, -} - -impl<'a> VideotexStringRef<'a> { - /// Create a new ASN.1 `VideotexString`. - pub fn new(input: &'a T) -> Result - where - T: AsRef<[u8]> + ?Sized, - { - let input = input.as_ref(); - - // Validate all characters are within VideotexString's allowed set - // FIXME: treat as if it were IA5String - if input.iter().any(|&c| c > 0x7F) { - return Err(Self::TAG.value_error()); - } - - StrRef::from_bytes(input) - .map(|inner| Self { inner }) - .map_err(|_| Self::TAG.value_error()) - } -} - -impl_string_type!(VideotexStringRef<'a>, 'a); - -impl<'a> Deref for VideotexStringRef<'a> { - type Target = StrRef<'a>; - - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl FixedTag for VideotexStringRef<'_> { - const TAG: Tag = Tag::VideotexString; -} - -impl<'a> From<&VideotexStringRef<'a>> for VideotexStringRef<'a> { - fn from(value: &VideotexStringRef<'a>) -> VideotexStringRef<'a> { - *value - } -} - -impl<'a> From> for AnyRef<'a> { - fn from(printable_string: VideotexStringRef<'a>) -> AnyRef<'a> { - AnyRef::from_tag_and_value(Tag::VideotexString, printable_string.inner.into()) - } -} - -impl<'a> From> for &'a [u8] { - fn from(printable_string: VideotexStringRef<'a>) -> &'a [u8] { - printable_string.as_bytes() - } -} - -impl<'a> fmt::Debug for VideotexStringRef<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "VideotexString({:?})", self.as_str()) - } -} - -#[cfg(test)] -mod tests { - use super::VideotexStringRef; - use crate::Decode; - - #[test] - fn parse_bytes() { - let example_bytes = &[ - 0x15, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x65, 0x72, 0x20, 0x31, - ]; - - let printable_string = VideotexStringRef::from_der(example_bytes).unwrap(); - assert_eq!(printable_string.as_str(), "Test User 1"); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_owned.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_owned.rs deleted file mode 100644 index b5e928e3b875..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_owned.rs +++ /dev/null @@ -1,162 +0,0 @@ -//! Common handling for types backed by byte allocation with enforcement of a -//! library-level length limitation i.e. `Length::max()`. - -use crate::{ - referenced::OwnedToRef, BytesRef, DecodeValue, DerOrd, EncodeValue, Error, Header, Length, - Reader, Result, StrRef, Writer, -}; -use alloc::{boxed::Box, vec::Vec}; -use core::cmp::Ordering; - -/// Byte slice newtype which respects the `Length::max()` limit. -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub(crate) struct BytesOwned { - /// Precomputed `Length` (avoids possible panicking conversions) - length: Length, - - /// Inner value - inner: Box<[u8]>, -} - -impl BytesOwned { - /// Create a new [`BytesOwned`], ensuring that the provided `slice` value - /// is shorter than `Length::max()`. - pub fn new(data: impl Into>) -> Result { - let inner: Box<[u8]> = data.into(); - - Ok(Self { - length: Length::try_from(inner.len())?, - inner, - }) - } - - /// Borrow the inner byte slice - pub fn as_slice(&self) -> &[u8] { - &self.inner - } - - /// Get the [`Length`] of this [`BytesRef`] - pub fn len(&self) -> Length { - self.length - } - - /// Is this [`BytesOwned`] empty? - pub fn is_empty(&self) -> bool { - self.len() == Length::ZERO - } -} - -impl AsRef<[u8]> for BytesOwned { - fn as_ref(&self) -> &[u8] { - self.as_slice() - } -} - -impl<'a> DecodeValue<'a> for BytesOwned { - fn decode_value>(reader: &mut R, header: Header) -> Result { - reader.read_vec(header.length).and_then(Self::new) - } -} - -impl EncodeValue for BytesOwned { - fn value_len(&self) -> Result { - Ok(self.length) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_ref()) - } -} - -impl Default for BytesOwned { - fn default() -> Self { - Self { - length: Length::ZERO, - inner: Box::new([]), - } - } -} - -impl DerOrd for BytesOwned { - fn der_cmp(&self, other: &Self) -> Result { - Ok(self.as_slice().cmp(other.as_slice())) - } -} - -impl From for Box<[u8]> { - fn from(bytes: BytesOwned) -> Box<[u8]> { - bytes.inner - } -} - -impl From> for BytesOwned { - fn from(s: StrRef<'_>) -> BytesOwned { - let bytes = s.as_bytes(); - debug_assert_eq!(bytes.len(), usize::try_from(s.length).expect("overflow")); - - BytesOwned { - inner: Box::from(bytes), - length: s.length, - } - } -} - -impl OwnedToRef for BytesOwned { - type Borrowed<'a> = BytesRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - BytesRef { - length: self.length, - inner: self.inner.as_ref(), - } - } -} - -impl From> for BytesOwned { - fn from(s: BytesRef<'_>) -> BytesOwned { - BytesOwned { - length: s.length, - inner: Box::from(s.inner), - } - } -} - -impl TryFrom<&[u8]> for BytesOwned { - type Error = Error; - - fn try_from(bytes: &[u8]) -> Result { - Self::new(bytes) - } -} - -impl TryFrom> for BytesOwned { - type Error = Error; - - fn try_from(bytes: Box<[u8]>) -> Result { - Self::new(bytes) - } -} - -impl TryFrom> for BytesOwned { - type Error = Error; - - fn try_from(bytes: Vec) -> Result { - Self::new(bytes) - } -} - -// Implement by hand because the derive would create invalid values. -// Make sure the length and the inner.len matches. -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for BytesOwned { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - let length = u.arbitrary()?; - Ok(Self { - length, - inner: Box::from(u.bytes(u32::from(length) as usize)?), - }) - } - - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and(Length::size_hint(depth), (0, None)) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_ref.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_ref.rs deleted file mode 100644 index 2cee4076ed15..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_ref.rs +++ /dev/null @@ -1,152 +0,0 @@ -//! Common handling for types backed by byte slices with enforcement of a -//! library-level length limitation i.e. `Length::max()`. - -use crate::{ - DecodeValue, DerOrd, EncodeValue, Error, Header, Length, Reader, Result, StrRef, Writer, -}; -use core::cmp::Ordering; - -#[cfg(feature = "alloc")] -use crate::StrOwned; - -/// Byte slice newtype which respects the `Length::max()` limit. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub(crate) struct BytesRef<'a> { - /// Precomputed `Length` (avoids possible panicking conversions) - pub length: Length, - - /// Inner value - pub inner: &'a [u8], -} - -impl<'a> BytesRef<'a> { - /// Constant value representing an empty byte slice. - pub const EMPTY: Self = Self { - length: Length::ZERO, - inner: &[], - }; - - /// Create a new [`BytesRef`], ensuring that the provided `slice` value - /// is shorter than `Length::max()`. - pub fn new(slice: &'a [u8]) -> Result { - Ok(Self { - length: Length::try_from(slice.len())?, - inner: slice, - }) - } - - /// Borrow the inner byte slice - pub fn as_slice(&self) -> &'a [u8] { - self.inner - } - - /// Get the [`Length`] of this [`BytesRef`] - pub fn len(self) -> Length { - self.length - } - - /// Is this [`BytesRef`] empty? - pub fn is_empty(self) -> bool { - self.len() == Length::ZERO - } -} - -impl AsRef<[u8]> for BytesRef<'_> { - fn as_ref(&self) -> &[u8] { - self.as_slice() - } -} - -impl<'a> DecodeValue<'a> for BytesRef<'a> { - fn decode_value>(reader: &mut R, header: Header) -> Result { - reader.read_slice(header.length).and_then(Self::new) - } -} - -impl EncodeValue for BytesRef<'_> { - fn value_len(&self) -> Result { - Ok(self.length) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_ref()) - } -} - -impl Default for BytesRef<'_> { - fn default() -> Self { - Self { - length: Length::ZERO, - inner: &[], - } - } -} - -impl DerOrd for BytesRef<'_> { - fn der_cmp(&self, other: &Self) -> Result { - Ok(self.as_slice().cmp(other.as_slice())) - } -} - -impl<'a> From> for BytesRef<'a> { - fn from(s: StrRef<'a>) -> BytesRef<'a> { - let bytes = s.as_bytes(); - debug_assert_eq!(bytes.len(), usize::try_from(s.length).expect("overflow")); - - BytesRef { - inner: bytes, - length: s.length, - } - } -} - -#[cfg(feature = "alloc")] -impl<'a> From<&'a StrOwned> for BytesRef<'a> { - fn from(s: &'a StrOwned) -> BytesRef<'a> { - let bytes = s.as_bytes(); - debug_assert_eq!(bytes.len(), usize::try_from(s.length).expect("overflow")); - - BytesRef { - inner: bytes, - length: s.length, - } - } -} - -impl<'a> TryFrom<&'a [u8]> for BytesRef<'a> { - type Error = Error; - - fn try_from(slice: &'a [u8]) -> Result { - Self::new(slice) - } -} - -// Implement by hand because the derive would create invalid values. -// Make sure the length and the inner.len matches. -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for BytesRef<'a> { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - let length = u.arbitrary()?; - Ok(Self { - length, - inner: u.bytes(u32::from(length) as usize)?, - }) - } - - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and(Length::size_hint(depth), (0, None)) - } -} - -#[cfg(feature = "alloc")] -mod allocating { - use super::BytesRef; - use crate::{referenced::RefToOwned, BytesOwned}; - - impl<'a> RefToOwned<'a> for BytesRef<'a> { - type Owned = BytesOwned; - fn ref_to_owned(&self) -> Self::Owned { - BytesOwned::from(*self) - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/datetime.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/datetime.rs deleted file mode 100644 index fd09b6855dd7..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/datetime.rs +++ /dev/null @@ -1,447 +0,0 @@ -//! Date and time functionality shared between various ASN.1 types -//! (e.g. `GeneralizedTime`, `UTCTime`) - -// Adapted from the `humantime` crate. -// Copyright (c) 2016 The humantime Developers -// Released under the MIT OR Apache 2.0 licenses - -use crate::{Error, ErrorKind, Result, Tag, Writer}; -use core::{fmt, str::FromStr, time::Duration}; - -#[cfg(feature = "std")] -use std::time::{SystemTime, UNIX_EPOCH}; - -#[cfg(feature = "time")] -use time::PrimitiveDateTime; - -/// Minimum year allowed in [`DateTime`] values. -const MIN_YEAR: u16 = 1970; - -/// Maximum duration since `UNIX_EPOCH` which can be represented as a -/// [`DateTime`] (non-inclusive). -/// -/// This corresponds to: 9999-12-31T23:59:59Z -const MAX_UNIX_DURATION: Duration = Duration::from_secs(253_402_300_799); - -/// Date-and-time type shared by multiple ASN.1 types -/// (e.g. `GeneralizedTime`, `UTCTime`). -/// -/// Following conventions from RFC 5280, this type is always Z-normalized -/// (i.e. represents a UTC time). However, it isn't named "UTC time" in order -/// to prevent confusion with ASN.1 `UTCTime`. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct DateTime { - /// Full year (e.g. 2000). - /// - /// Must be >=1970 to permit positive conversions to Unix time. - year: u16, - - /// Month (1-12) - month: u8, - - /// Day of the month (1-31) - day: u8, - - /// Hour (0-23) - hour: u8, - - /// Minutes (0-59) - minutes: u8, - - /// Seconds (0-59) - seconds: u8, - - /// [`Duration`] since the Unix epoch. - unix_duration: Duration, -} - -impl DateTime { - /// This is the maximum date represented by the [`DateTime`] - /// This corresponds to: 9999-12-31T23:59:59Z - pub const INFINITY: DateTime = DateTime { - year: 9999, - month: 12, - day: 31, - hour: 23, - minutes: 59, - seconds: 59, - unix_duration: MAX_UNIX_DURATION, - }; - - /// Create a new [`DateTime`] from the given UTC time components. - // TODO(tarcieri): checked arithmetic - #[allow(clippy::integer_arithmetic)] - pub fn new(year: u16, month: u8, day: u8, hour: u8, minutes: u8, seconds: u8) -> Result { - // Basic validation of the components. - if year < MIN_YEAR - || !(1..=12).contains(&month) - || !(1..=31).contains(&day) - || !(0..=23).contains(&hour) - || !(0..=59).contains(&minutes) - || !(0..=59).contains(&seconds) - { - return Err(ErrorKind::DateTime.into()); - } - - let leap_years = - ((year - 1) - 1968) / 4 - ((year - 1) - 1900) / 100 + ((year - 1) - 1600) / 400; - - let is_leap_year = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); - - let (mut ydays, mdays): (u16, u8) = match month { - 1 => (0, 31), - 2 if is_leap_year => (31, 29), - 2 => (31, 28), - 3 => (59, 31), - 4 => (90, 30), - 5 => (120, 31), - 6 => (151, 30), - 7 => (181, 31), - 8 => (212, 31), - 9 => (243, 30), - 10 => (273, 31), - 11 => (304, 30), - 12 => (334, 31), - _ => return Err(ErrorKind::DateTime.into()), - }; - - if day > mdays || day == 0 { - return Err(ErrorKind::DateTime.into()); - } - - ydays += u16::from(day) - 1; - - if is_leap_year && month > 2 { - ydays += 1; - } - - let days = u64::from(year - 1970) * 365 + u64::from(leap_years) + u64::from(ydays); - let time = u64::from(seconds) + (u64::from(minutes) * 60) + (u64::from(hour) * 3600); - let unix_duration = Duration::from_secs(time + days * 86400); - - if unix_duration > MAX_UNIX_DURATION { - return Err(ErrorKind::DateTime.into()); - } - - Ok(Self { - year, - month, - day, - hour, - minutes, - seconds, - unix_duration, - }) - } - - /// Compute a [`DateTime`] from the given [`Duration`] since the `UNIX_EPOCH`. - /// - /// Returns `None` if the value is outside the supported date range. - // TODO(tarcieri): checked arithmetic - #[allow(clippy::integer_arithmetic)] - pub fn from_unix_duration(unix_duration: Duration) -> Result { - if unix_duration > MAX_UNIX_DURATION { - return Err(ErrorKind::DateTime.into()); - } - - let secs_since_epoch = unix_duration.as_secs(); - - /// 2000-03-01 (mod 400 year, immediately after Feb 29) - const LEAPOCH: i64 = 11017; - const DAYS_PER_400Y: i64 = 365 * 400 + 97; - const DAYS_PER_100Y: i64 = 365 * 100 + 24; - const DAYS_PER_4Y: i64 = 365 * 4 + 1; - - let days = i64::try_from(secs_since_epoch / 86400)? - LEAPOCH; - let secs_of_day = secs_since_epoch % 86400; - - let mut qc_cycles = days / DAYS_PER_400Y; - let mut remdays = days % DAYS_PER_400Y; - - if remdays < 0 { - remdays += DAYS_PER_400Y; - qc_cycles -= 1; - } - - let mut c_cycles = remdays / DAYS_PER_100Y; - if c_cycles == 4 { - c_cycles -= 1; - } - remdays -= c_cycles * DAYS_PER_100Y; - - let mut q_cycles = remdays / DAYS_PER_4Y; - if q_cycles == 25 { - q_cycles -= 1; - } - remdays -= q_cycles * DAYS_PER_4Y; - - let mut remyears = remdays / 365; - if remyears == 4 { - remyears -= 1; - } - remdays -= remyears * 365; - - let mut year = 2000 + remyears + 4 * q_cycles + 100 * c_cycles + 400 * qc_cycles; - - let months = [31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29]; - let mut mon = 0; - for mon_len in months.iter() { - mon += 1; - if remdays < *mon_len { - break; - } - remdays -= *mon_len; - } - let mday = remdays + 1; - let mon = if mon + 2 > 12 { - year += 1; - mon - 10 - } else { - mon + 2 - }; - - let second = secs_of_day % 60; - let mins_of_day = secs_of_day / 60; - let minute = mins_of_day % 60; - let hour = mins_of_day / 60; - - Self::new( - year.try_into()?, - mon, - mday.try_into()?, - hour.try_into()?, - minute.try_into()?, - second.try_into()?, - ) - } - - /// Get the year. - pub fn year(&self) -> u16 { - self.year - } - - /// Get the month. - pub fn month(&self) -> u8 { - self.month - } - - /// Get the day. - pub fn day(&self) -> u8 { - self.day - } - - /// Get the hour. - pub fn hour(&self) -> u8 { - self.hour - } - - /// Get the minutes. - pub fn minutes(&self) -> u8 { - self.minutes - } - - /// Get the seconds. - pub fn seconds(&self) -> u8 { - self.seconds - } - - /// Compute [`Duration`] since `UNIX_EPOCH` from the given calendar date. - pub fn unix_duration(&self) -> Duration { - self.unix_duration - } - - /// Instantiate from [`SystemTime`]. - #[cfg(feature = "std")] - pub fn from_system_time(time: SystemTime) -> Result { - time.duration_since(UNIX_EPOCH) - .map_err(|_| ErrorKind::DateTime.into()) - .and_then(Self::from_unix_duration) - } - - /// Convert to [`SystemTime`]. - #[cfg(feature = "std")] - pub fn to_system_time(&self) -> SystemTime { - UNIX_EPOCH + self.unix_duration() - } -} - -impl FromStr for DateTime { - type Err = Error; - - fn from_str(s: &str) -> Result { - match *s.as_bytes() { - [year1, year2, year3, year4, b'-', month1, month2, b'-', day1, day2, b'T', hour1, hour2, b':', min1, min2, b':', sec1, sec2, b'Z'] => - { - let tag = Tag::GeneralizedTime; - let year = decode_year(&[year1, year2, year3, year4])?; - let month = decode_decimal(tag, month1, month2).map_err(|_| ErrorKind::DateTime)?; - let day = decode_decimal(tag, day1, day2).map_err(|_| ErrorKind::DateTime)?; - let hour = decode_decimal(tag, hour1, hour2).map_err(|_| ErrorKind::DateTime)?; - let minutes = decode_decimal(tag, min1, min2).map_err(|_| ErrorKind::DateTime)?; - let seconds = decode_decimal(tag, sec1, sec2).map_err(|_| ErrorKind::DateTime)?; - Self::new(year, month, day, hour, minutes, seconds) - } - _ => Err(ErrorKind::DateTime.into()), - } - } -} - -impl fmt::Display for DateTime { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "{:02}-{:02}-{:02}T{:02}:{:02}:{:02}Z", - self.year, self.month, self.day, self.hour, self.minutes, self.seconds - ) - } -} - -#[cfg(feature = "std")] -impl From for SystemTime { - fn from(time: DateTime) -> SystemTime { - time.to_system_time() - } -} - -#[cfg(feature = "std")] -impl From<&DateTime> for SystemTime { - fn from(time: &DateTime) -> SystemTime { - time.to_system_time() - } -} - -#[cfg(feature = "std")] -impl TryFrom for DateTime { - type Error = Error; - - fn try_from(time: SystemTime) -> Result { - DateTime::from_system_time(time) - } -} - -#[cfg(feature = "std")] -impl TryFrom<&SystemTime> for DateTime { - type Error = Error; - - fn try_from(time: &SystemTime) -> Result { - DateTime::from_system_time(*time) - } -} - -#[cfg(feature = "time")] -impl TryFrom for PrimitiveDateTime { - type Error = Error; - - fn try_from(time: DateTime) -> Result { - let month = time.month().try_into()?; - let date = time::Date::from_calendar_date(i32::from(time.year()), month, time.day())?; - let time = time::Time::from_hms(time.hour(), time.minutes(), time.seconds())?; - - Ok(PrimitiveDateTime::new(date, time)) - } -} - -#[cfg(feature = "time")] -impl TryFrom for DateTime { - type Error = Error; - - fn try_from(time: PrimitiveDateTime) -> Result { - DateTime::new( - time.year().try_into().map_err(|_| ErrorKind::DateTime)?, - time.month().into(), - time.day(), - time.hour(), - time.minute(), - time.second(), - ) - } -} - -// Implement by hand because the derive would create invalid values. -// Use the conversion from Duration to create a valid value. -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for DateTime { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - Self::from_unix_duration(Duration::new( - u.int_in_range(0..=MAX_UNIX_DURATION.as_secs().saturating_sub(1))?, - u.int_in_range(0..=999_999_999)?, - )) - .map_err(|_| arbitrary::Error::IncorrectFormat) - } - - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and(u64::size_hint(depth), u32::size_hint(depth)) - } -} - -/// Decode 2-digit decimal value -// TODO(tarcieri): checked arithmetic -#[allow(clippy::integer_arithmetic)] -pub(crate) fn decode_decimal(tag: Tag, hi: u8, lo: u8) -> Result { - if hi.is_ascii_digit() && lo.is_ascii_digit() { - Ok((hi - b'0') * 10 + (lo - b'0')) - } else { - Err(tag.value_error()) - } -} - -/// Encode 2-digit decimal value -pub(crate) fn encode_decimal(writer: &mut W, tag: Tag, value: u8) -> Result<()> -where - W: Writer + ?Sized, -{ - let hi_val = value / 10; - - if hi_val >= 10 { - return Err(tag.value_error()); - } - - writer.write_byte(b'0'.checked_add(hi_val).ok_or(ErrorKind::Overflow)?)?; - writer.write_byte(b'0'.checked_add(value % 10).ok_or(ErrorKind::Overflow)?) -} - -/// Decode 4-digit year. -// TODO(tarcieri): checked arithmetic -#[allow(clippy::integer_arithmetic)] -fn decode_year(year: &[u8; 4]) -> Result { - let tag = Tag::GeneralizedTime; - let hi = decode_decimal(tag, year[0], year[1]).map_err(|_| ErrorKind::DateTime)?; - let lo = decode_decimal(tag, year[2], year[3]).map_err(|_| ErrorKind::DateTime)?; - Ok(u16::from(hi) * 100 + u16::from(lo)) -} - -#[cfg(test)] -mod tests { - use super::DateTime; - - /// Ensure a day is OK - fn is_date_valid(year: u16, month: u8, day: u8, hour: u8, minute: u8, second: u8) -> bool { - DateTime::new(year, month, day, hour, minute, second).is_ok() - } - - #[test] - fn feb_leap_year_handling() { - assert!(is_date_valid(2000, 2, 29, 0, 0, 0)); - assert!(!is_date_valid(2001, 2, 29, 0, 0, 0)); - assert!(!is_date_valid(2100, 2, 29, 0, 0, 0)); - } - - #[test] - fn from_str() { - let datetime = "2001-01-02T12:13:14Z".parse::().unwrap(); - assert_eq!(datetime.year(), 2001); - assert_eq!(datetime.month(), 1); - assert_eq!(datetime.day(), 2); - assert_eq!(datetime.hour(), 12); - assert_eq!(datetime.minutes(), 13); - assert_eq!(datetime.seconds(), 14); - } - - #[cfg(feature = "alloc")] - #[test] - fn display() { - use alloc::string::ToString; - let datetime = DateTime::new(2001, 01, 02, 12, 13, 14).unwrap(); - assert_eq!(&datetime.to_string(), "2001-01-02T12:13:14Z"); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/decode.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/decode.rs deleted file mode 100644 index fe53341b3e7a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/decode.rs +++ /dev/null @@ -1,99 +0,0 @@ -//! Trait definition for [`Decode`]. - -use crate::{FixedTag, Header, Reader, Result, SliceReader}; -use core::marker::PhantomData; - -#[cfg(feature = "pem")] -use crate::{pem::PemLabel, PemReader}; - -#[cfg(doc)] -use crate::{Length, Tag}; - -#[cfg(feature = "alloc")] -use alloc::boxed::Box; - -/// Decoding trait. -/// -/// This trait provides the core abstraction upon which all decoding operations -/// are based. -pub trait Decode<'a>: Sized { - /// Attempt to decode this message using the provided decoder. - fn decode>(decoder: &mut R) -> Result; - - /// Parse `Self` from the provided DER-encoded byte slice. - fn from_der(bytes: &'a [u8]) -> Result { - let mut reader = SliceReader::new(bytes)?; - let result = Self::decode(&mut reader)?; - reader.finish(result) - } -} - -impl<'a, T> Decode<'a> for T -where - T: DecodeValue<'a> + FixedTag, -{ - fn decode>(reader: &mut R) -> Result { - let header = Header::decode(reader)?; - header.tag.assert_eq(T::TAG)?; - T::decode_value(reader, header) - } -} - -/// Dummy implementation for [`PhantomData`] which allows deriving -/// implementations on structs with phantom fields. -impl<'a, T> Decode<'a> for PhantomData -where - T: ?Sized, -{ - fn decode>(_reader: &mut R) -> Result> { - Ok(PhantomData) - } -} - -/// Marker trait for data structures that can be decoded from DER without -/// borrowing any data from the decoder. -/// -/// This is primarily useful for trait bounds on functions which require that -/// no data is borrowed from the decoder, for example a PEM decoder which needs -/// to first decode data from Base64. -/// -/// This trait is inspired by the [`DeserializeOwned` trait from `serde`](https://docs.rs/serde/latest/serde/de/trait.DeserializeOwned.html). -pub trait DecodeOwned: for<'a> Decode<'a> {} - -impl DecodeOwned for T where T: for<'a> Decode<'a> {} - -/// PEM decoding trait. -/// -/// This trait is automatically impl'd for any type which impls both -/// [`DecodeOwned`] and [`PemLabel`]. -#[cfg(feature = "pem")] -pub trait DecodePem: DecodeOwned + PemLabel { - /// Try to decode this type from PEM. - fn from_pem(pem: impl AsRef<[u8]>) -> Result; -} - -#[cfg(feature = "pem")] -impl DecodePem for T { - fn from_pem(pem: impl AsRef<[u8]>) -> Result { - let mut reader = PemReader::new(pem.as_ref())?; - Self::validate_pem_label(reader.type_label())?; - T::decode(&mut reader) - } -} - -/// Decode the value part of a Tag-Length-Value encoded field, sans the [`Tag`] -/// and [`Length`]. -pub trait DecodeValue<'a>: Sized { - /// Attempt to decode this message using the provided [`Reader`]. - fn decode_value>(reader: &mut R, header: Header) -> Result; -} - -#[cfg(feature = "alloc")] -impl<'a, T> DecodeValue<'a> for Box -where - T: DecodeValue<'a>, -{ - fn decode_value>(reader: &mut R, header: Header) -> Result { - Ok(Box::new(T::decode_value(reader, header)?)) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/document.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/document.rs deleted file mode 100644 index 78355a67a8df..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/document.rs +++ /dev/null @@ -1,354 +0,0 @@ -//! ASN.1 DER-encoded documents stored on the heap. - -use crate::{Decode, Encode, Error, FixedTag, Length, Reader, Result, SliceReader, Tag, Writer}; -use alloc::vec::Vec; -use core::fmt::{self, Debug}; - -#[cfg(feature = "pem")] -use {crate::pem, alloc::string::String}; - -#[cfg(feature = "std")] -use std::{fs, path::Path}; - -#[cfg(all(feature = "pem", feature = "std"))] -use alloc::borrow::ToOwned; - -#[cfg(feature = "zeroize")] -use zeroize::{Zeroize, ZeroizeOnDrop, Zeroizing}; - -/// ASN.1 DER-encoded document. -/// -/// This type wraps an encoded ASN.1 DER message. The document checked to -/// ensure it contains a valid DER-encoded `SEQUENCE`. -/// -/// It implements common functionality related to encoding/decoding such -/// documents, such as PEM encapsulation as well as reading/writing documents -/// from/to the filesystem. -/// -/// The [`SecretDocument`] provides a wrapper for this type with additional -/// hardening applied. -#[derive(Clone, Eq, PartialEq)] -pub struct Document { - /// ASN.1 DER encoded bytes. - der_bytes: Vec, - - /// Length of this document. - length: Length, -} - -impl Document { - /// Get the ASN.1 DER-encoded bytes of this document. - pub fn as_bytes(&self) -> &[u8] { - self.der_bytes.as_slice() - } - - /// Convert to a [`SecretDocument`]. - #[cfg(feature = "zeroize")] - pub fn into_secret(self) -> SecretDocument { - SecretDocument(self) - } - - /// Convert to an ASN.1 DER-encoded byte vector. - pub fn into_vec(self) -> Vec { - self.der_bytes - } - - /// Return an ASN.1 DER-encoded byte vector. - pub fn to_vec(&self) -> Vec { - self.der_bytes.clone() - } - - /// Get the length of the encoded ASN.1 DER in bytes. - pub fn len(&self) -> Length { - self.length - } - - /// Try to decode the inner ASN.1 DER message contained in this - /// [`Document`] as the given type. - pub fn decode_msg<'a, T: Decode<'a>>(&'a self) -> Result { - T::from_der(self.as_bytes()) - } - - /// Encode the provided type as ASN.1 DER, storing the resulting encoded DER - /// as a [`Document`]. - pub fn encode_msg(msg: &T) -> Result { - msg.to_der()?.try_into() - } - - /// Decode ASN.1 DER document from PEM. - /// - /// Returns the PEM label and decoded [`Document`] on success. - #[cfg(feature = "pem")] - pub fn from_pem(pem: &str) -> Result<(&str, Self)> { - let (label, der_bytes) = pem::decode_vec(pem.as_bytes())?; - Ok((label, der_bytes.try_into()?)) - } - - /// Encode ASN.1 DER document as a PEM string with encapsulation boundaries - /// containing the provided PEM type `label` (e.g. `CERTIFICATE`). - #[cfg(feature = "pem")] - pub fn to_pem(&self, label: &'static str, line_ending: pem::LineEnding) -> Result { - Ok(pem::encode_string(label, line_ending, self.as_bytes())?) - } - - /// Read ASN.1 DER document from a file. - #[cfg(feature = "std")] - pub fn read_der_file(path: impl AsRef) -> Result { - fs::read(path)?.try_into() - } - - /// Write ASN.1 DER document to a file. - #[cfg(feature = "std")] - pub fn write_der_file(&self, path: impl AsRef) -> Result<()> { - Ok(fs::write(path, self.as_bytes())?) - } - - /// Read PEM-encoded ASN.1 DER document from a file. - #[cfg(all(feature = "pem", feature = "std"))] - pub fn read_pem_file(path: impl AsRef) -> Result<(String, Self)> { - Self::from_pem(&fs::read_to_string(path)?).map(|(label, doc)| (label.to_owned(), doc)) - } - - /// Write PEM-encoded ASN.1 DER document to a file. - #[cfg(all(feature = "pem", feature = "std"))] - pub fn write_pem_file( - &self, - path: impl AsRef, - label: &'static str, - line_ending: pem::LineEnding, - ) -> Result<()> { - let pem = self.to_pem(label, line_ending)?; - Ok(fs::write(path, pem.as_bytes())?) - } -} - -impl AsRef<[u8]> for Document { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } -} - -impl Debug for Document { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("Document(")?; - - for byte in self.as_bytes() { - write!(f, "{:02X}", byte)?; - } - - f.write_str(")") - } -} - -impl<'a> Decode<'a> for Document { - fn decode>(reader: &mut R) -> Result { - let header = reader.peek_header()?; - let length = (header.encoded_len()? + header.length)?; - let bytes = reader.read_slice(length)?; - - Ok(Self { - der_bytes: bytes.into(), - length, - }) - } -} - -impl Encode for Document { - fn encoded_len(&self) -> Result { - Ok(self.len()) - } - - fn encode(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_bytes()) - } -} - -impl FixedTag for Document { - const TAG: Tag = Tag::Sequence; -} - -impl TryFrom<&[u8]> for Document { - type Error = Error; - - fn try_from(der_bytes: &[u8]) -> Result { - Self::from_der(der_bytes) - } -} - -impl TryFrom> for Document { - type Error = Error; - - fn try_from(der_bytes: Vec) -> Result { - let mut decoder = SliceReader::new(&der_bytes)?; - decode_sequence(&mut decoder)?; - decoder.finish(())?; - - let length = der_bytes.len().try_into()?; - Ok(Self { der_bytes, length }) - } -} - -/// Secret [`Document`] type. -/// -/// Useful for formats which represent potentially secret data, such as -/// cryptographic keys. -/// -/// This type provides additional hardening such as ensuring that the contents -/// are zeroized-on-drop, and also using more restrictive file permissions when -/// writing files to disk. -#[cfg(feature = "zeroize")] -#[derive(Clone)] -pub struct SecretDocument(Document); - -#[cfg(feature = "zeroize")] -impl SecretDocument { - /// Borrow the inner serialized bytes of this document. - pub fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() - } - - /// Return an allocated ASN.1 DER serialization as a byte vector. - pub fn to_bytes(&self) -> Zeroizing> { - Zeroizing::new(self.0.to_vec()) - } - - /// Get the length of the encoded ASN.1 DER in bytes. - pub fn len(&self) -> Length { - self.0.len() - } - - /// Try to decode the inner ASN.1 DER message as the given type. - pub fn decode_msg<'a, T: Decode<'a>>(&'a self) -> Result { - self.0.decode_msg() - } - - /// Encode the provided type as ASN.1 DER. - pub fn encode_msg(msg: &T) -> Result { - Document::encode_msg(msg).map(Self) - } - - /// Decode ASN.1 DER document from PEM. - #[cfg(feature = "pem")] - pub fn from_pem(pem: &str) -> Result<(&str, Self)> { - Document::from_pem(pem).map(|(label, doc)| (label, Self(doc))) - } - - /// Encode ASN.1 DER document as a PEM string. - #[cfg(feature = "pem")] - pub fn to_pem( - &self, - label: &'static str, - line_ending: pem::LineEnding, - ) -> Result> { - self.0.to_pem(label, line_ending).map(Zeroizing::new) - } - - /// Read ASN.1 DER document from a file. - #[cfg(feature = "std")] - pub fn read_der_file(path: impl AsRef) -> Result { - Document::read_der_file(path).map(Self) - } - - /// Write ASN.1 DER document to a file. - #[cfg(feature = "std")] - pub fn write_der_file(&self, path: impl AsRef) -> Result<()> { - write_secret_file(path, self.as_bytes()) - } - - /// Read PEM-encoded ASN.1 DER document from a file. - #[cfg(all(feature = "pem", feature = "std"))] - pub fn read_pem_file(path: impl AsRef) -> Result<(String, Self)> { - Document::read_pem_file(path).map(|(label, doc)| (label, Self(doc))) - } - - /// Write PEM-encoded ASN.1 DER document to a file. - #[cfg(all(feature = "pem", feature = "std"))] - pub fn write_pem_file( - &self, - path: impl AsRef, - label: &'static str, - line_ending: pem::LineEnding, - ) -> Result<()> { - write_secret_file(path, self.to_pem(label, line_ending)?.as_bytes()) - } -} -#[cfg(feature = "zeroize")] -impl Debug for SecretDocument { - fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt.debug_struct("SecretDocument").finish_non_exhaustive() - } -} - -#[cfg(feature = "zeroize")] -impl Drop for SecretDocument { - fn drop(&mut self) { - self.0.der_bytes.zeroize(); - } -} - -#[cfg(feature = "zeroize")] -impl From for SecretDocument { - fn from(doc: Document) -> SecretDocument { - SecretDocument(doc) - } -} - -#[cfg(feature = "zeroize")] -impl TryFrom<&[u8]> for SecretDocument { - type Error = Error; - - fn try_from(der_bytes: &[u8]) -> Result { - Document::try_from(der_bytes).map(Self) - } -} - -#[cfg(feature = "zeroize")] -impl TryFrom> for SecretDocument { - type Error = Error; - - fn try_from(der_bytes: Vec) -> Result { - Document::try_from(der_bytes).map(Self) - } -} - -#[cfg(feature = "zeroize")] -impl ZeroizeOnDrop for SecretDocument {} - -/// Attempt to decode a ASN.1 `SEQUENCE` from the given decoder, returning the -/// entire sequence including the header. -fn decode_sequence<'a>(decoder: &mut SliceReader<'a>) -> Result<&'a [u8]> { - let header = decoder.peek_header()?; - header.tag.assert_eq(Tag::Sequence)?; - - let len = (header.encoded_len()? + header.length)?; - decoder.read_slice(len) -} - -/// Write a file containing secret data to the filesystem, restricting the -/// file permissions so it's only readable by the owner -#[cfg(all(unix, feature = "std", feature = "zeroize"))] -fn write_secret_file(path: impl AsRef, data: &[u8]) -> Result<()> { - use std::{io::Write, os::unix::fs::OpenOptionsExt}; - - /// File permissions for secret data - #[cfg(unix)] - const SECRET_FILE_PERMS: u32 = 0o600; - - fs::OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .mode(SECRET_FILE_PERMS) - .open(path) - .and_then(|mut file| file.write_all(data))?; - - Ok(()) -} - -/// Write a file containing secret data to the filesystem -// TODO(tarcieri): permissions hardening on Windows -#[cfg(all(not(unix), feature = "std", feature = "zeroize"))] -fn write_secret_file(path: impl AsRef, data: &[u8]) -> Result<()> { - fs::write(path, data)?; - Ok(()) -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode.rs deleted file mode 100644 index 28d7cba77e06..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode.rs +++ /dev/null @@ -1,158 +0,0 @@ -//! Trait definition for [`Encode`]. - -use crate::{Header, Length, Result, SliceWriter, Tagged, Writer}; -use core::marker::PhantomData; - -#[cfg(feature = "alloc")] -use {alloc::boxed::Box, alloc::vec::Vec, core::iter}; - -#[cfg(feature = "pem")] -use { - crate::PemWriter, - alloc::string::String, - pem_rfc7468::{self as pem, LineEnding, PemLabel}, -}; - -#[cfg(any(feature = "alloc", feature = "pem"))] -use crate::ErrorKind; - -#[cfg(doc)] -use crate::Tag; - -/// Encoding trait. -pub trait Encode { - /// Compute the length of this value in bytes when encoded as ASN.1 DER. - fn encoded_len(&self) -> Result; - - /// Encode this value as ASN.1 DER using the provided [`Writer`]. - fn encode(&self, encoder: &mut impl Writer) -> Result<()>; - - /// Encode this value to the provided byte slice, returning a sub-slice - /// containing the encoded message. - fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]> { - let mut writer = SliceWriter::new(buf); - self.encode(&mut writer)?; - writer.finish() - } - - /// Encode this message as ASN.1 DER, appending it to the provided - /// byte vector. - #[cfg(feature = "alloc")] - fn encode_to_vec(&self, buf: &mut Vec) -> Result { - let expected_len = usize::try_from(self.encoded_len()?)?; - buf.reserve(expected_len); - buf.extend(iter::repeat(0).take(expected_len)); - - let mut writer = SliceWriter::new(buf); - self.encode(&mut writer)?; - let actual_len = writer.finish()?.len(); - - if expected_len != actual_len { - return Err(ErrorKind::Incomplete { - expected_len: expected_len.try_into()?, - actual_len: actual_len.try_into()?, - } - .into()); - } - - actual_len.try_into() - } - - /// Encode this type as DER, returning a byte vector. - #[cfg(feature = "alloc")] - fn to_der(&self) -> Result> { - let mut buf = Vec::new(); - self.encode_to_vec(&mut buf)?; - Ok(buf) - } -} - -impl Encode for T -where - T: EncodeValue + Tagged, -{ - /// Compute the length of this value in bytes when encoded as ASN.1 DER. - fn encoded_len(&self) -> Result { - self.value_len().and_then(|len| len.for_tlv()) - } - - /// Encode this value as ASN.1 DER using the provided [`Writer`]. - fn encode(&self, writer: &mut impl Writer) -> Result<()> { - self.header()?.encode(writer)?; - self.encode_value(writer) - } -} - -/// Dummy implementation for [`PhantomData`] which allows deriving -/// implementations on structs with phantom fields. -impl Encode for PhantomData -where - T: ?Sized, -{ - fn encoded_len(&self) -> Result { - Ok(Length::ZERO) - } - - fn encode(&self, _writer: &mut impl Writer) -> Result<()> { - Ok(()) - } -} - -/// PEM encoding trait. -/// -/// This trait is automatically impl'd for any type which impls both -/// [`Encode`] and [`PemLabel`]. -#[cfg(feature = "pem")] -pub trait EncodePem: Encode + PemLabel { - /// Try to encode this type as PEM. - fn to_pem(&self, line_ending: LineEnding) -> Result; -} - -#[cfg(feature = "pem")] -impl EncodePem for T { - fn to_pem(&self, line_ending: LineEnding) -> Result { - let der_len = usize::try_from(self.encoded_len()?)?; - let pem_len = pem::encapsulated_len(Self::PEM_LABEL, line_ending, der_len)?; - - let mut buf = vec![0u8; pem_len]; - let mut writer = PemWriter::new(Self::PEM_LABEL, line_ending, &mut buf)?; - self.encode(&mut writer)?; - - let actual_len = writer.finish()?; - buf.truncate(actual_len); - Ok(String::from_utf8(buf)?) - } -} - -/// Encode the value part of a Tag-Length-Value encoded field, sans the [`Tag`] -/// and [`Length`]. -pub trait EncodeValue { - /// Get the [`Header`] used to encode this value. - fn header(&self) -> Result
- where - Self: Tagged, - { - Header::new(self.tag(), self.value_len()?) - } - - /// Compute the length of this value (sans [`Tag`]+[`Length`] header) when - /// encoded as ASN.1 DER. - fn value_len(&self) -> Result; - - /// Encode value (sans [`Tag`]+[`Length`] header) as ASN.1 DER using the - /// provided [`Writer`]. - fn encode_value(&self, encoder: &mut impl Writer) -> Result<()>; -} - -#[cfg(feature = "alloc")] -impl EncodeValue for Box -where - T: EncodeValue, -{ - fn value_len(&self) -> Result { - T::value_len(self) - } - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - T::encode_value(self, writer) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode_ref.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode_ref.rs deleted file mode 100644 index 8a60a933fca0..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode_ref.rs +++ /dev/null @@ -1,71 +0,0 @@ -//! Wrapper object for encoding reference types. -// TODO(tarcieri): replace with blanket impls of `Encode(Value)` for reference types? - -use crate::{Encode, EncodeValue, Length, Result, Tag, Tagged, ValueOrd, Writer}; -use core::cmp::Ordering; - -/// Reference encoder: wrapper type which impls `Encode` for any reference to a -/// type which impls the same. -pub struct EncodeRef<'a, T>(pub &'a T); - -impl<'a, T> AsRef for EncodeRef<'a, T> { - fn as_ref(&self) -> &T { - self.0 - } -} - -impl<'a, T> Encode for EncodeRef<'a, T> -where - T: Encode, -{ - fn encoded_len(&self) -> Result { - self.0.encoded_len() - } - - fn encode(&self, writer: &mut impl Writer) -> Result<()> { - self.0.encode(writer) - } -} - -/// Reference value encoder: wrapper type which impls `EncodeValue` and `Tagged` -/// for any reference type which impls the same. -/// -/// By virtue of the blanket impl, this type also impls `Encode`. -pub struct EncodeValueRef<'a, T>(pub &'a T); - -impl<'a, T> AsRef for EncodeValueRef<'a, T> { - fn as_ref(&self) -> &T { - self.0 - } -} - -impl<'a, T> EncodeValue for EncodeValueRef<'a, T> -where - T: EncodeValue, -{ - fn value_len(&self) -> Result { - self.0.value_len() - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - self.0.encode_value(writer) - } -} - -impl<'a, T> Tagged for EncodeValueRef<'a, T> -where - T: Tagged, -{ - fn tag(&self) -> Tag { - self.0.tag() - } -} - -impl<'a, T> ValueOrd for EncodeValueRef<'a, T> -where - T: ValueOrd, -{ - fn value_cmp(&self, other: &Self) -> Result { - self.0.value_cmp(other.0) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/error.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/error.rs deleted file mode 100644 index 902863d4986b..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/error.rs +++ /dev/null @@ -1,369 +0,0 @@ -//! Error types. - -pub use core::str::Utf8Error; - -use crate::{Length, Tag}; -use core::{convert::Infallible, fmt, num::TryFromIntError}; - -#[cfg(feature = "oid")] -use crate::asn1::ObjectIdentifier; - -#[cfg(feature = "pem")] -use crate::pem; - -/// Result type. -pub type Result = core::result::Result; - -/// Error type. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Error { - /// Kind of error. - kind: ErrorKind, - - /// Position inside of message where error occurred. - position: Option, -} - -impl Error { - /// Create a new [`Error`]. - pub fn new(kind: ErrorKind, position: Length) -> Error { - Error { - kind, - position: Some(position), - } - } - - /// Create a new [`ErrorKind::Incomplete`] for the given length. - /// - /// Computes the expected len as being one greater than `actual_len`. - pub fn incomplete(actual_len: Length) -> Self { - match actual_len + Length::ONE { - Ok(expected_len) => ErrorKind::Incomplete { - expected_len, - actual_len, - } - .at(actual_len), - Err(err) => err.kind().at(actual_len), - } - } - - /// Get the [`ErrorKind`] which occurred. - pub fn kind(self) -> ErrorKind { - self.kind - } - - /// Get the position inside of the message where the error occurred. - pub fn position(self) -> Option { - self.position - } - - /// For errors occurring inside of a nested message, extend the position - /// count by the location where the nested message occurs. - pub(crate) fn nested(self, nested_position: Length) -> Self { - // TODO(tarcieri): better handle length overflows occurring in this calculation? - let position = (nested_position + self.position.unwrap_or_default()).ok(); - - Self { - kind: self.kind, - position, - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.kind)?; - - if let Some(pos) = self.position { - write!(f, " at DER byte {}", pos)?; - } - - Ok(()) - } -} - -impl From for Error { - fn from(kind: ErrorKind) -> Error { - Error { - kind, - position: None, - } - } -} - -impl From for Error { - fn from(_: Infallible) -> Error { - unreachable!() - } -} - -impl From for Error { - fn from(_: TryFromIntError) -> Error { - Error { - kind: ErrorKind::Overflow, - position: None, - } - } -} - -impl From for Error { - fn from(err: Utf8Error) -> Error { - Error { - kind: ErrorKind::Utf8(err), - position: None, - } - } -} - -#[cfg(feature = "alloc")] -impl From for Error { - fn from(err: alloc::string::FromUtf8Error) -> Error { - ErrorKind::Utf8(err.utf8_error()).into() - } -} - -#[cfg(feature = "oid")] -impl From for Error { - fn from(_: const_oid::Error) -> Error { - ErrorKind::OidMalformed.into() - } -} - -#[cfg(feature = "pem")] -impl From for Error { - fn from(err: pem::Error) -> Error { - ErrorKind::Pem(err).into() - } -} - -#[cfg(feature = "std")] -impl From for Error { - fn from(err: std::io::Error) -> Error { - match err.kind() { - std::io::ErrorKind::NotFound => ErrorKind::FileNotFound, - std::io::ErrorKind::PermissionDenied => ErrorKind::PermissionDenied, - other => ErrorKind::Io(other), - } - .into() - } -} - -#[cfg(feature = "time")] -impl From for Error { - fn from(_: time::error::ComponentRange) -> Error { - ErrorKind::DateTime.into() - } -} - -/// Error type. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[non_exhaustive] -pub enum ErrorKind { - /// Date-and-time related errors. - DateTime, - - /// This error indicates a previous DER parsing operation resulted in - /// an error and tainted the state of a `Decoder` or `Encoder`. - /// - /// Once this occurs, the overall operation has failed and cannot be - /// subsequently resumed. - Failed, - - /// File not found error. - #[cfg(feature = "std")] - FileNotFound, - - /// Message is incomplete and does not contain all of the expected data. - Incomplete { - /// Expected message length. - /// - /// Note that this length represents a *minimum* lower bound on how - /// much additional data is needed to continue parsing the message. - /// - /// It's possible upon subsequent message parsing that the parser will - /// discover even more data is needed. - expected_len: Length, - - /// Actual length of the message buffer currently being processed. - actual_len: Length, - }, - - /// I/O errors. - #[cfg(feature = "std")] - Io(std::io::ErrorKind), - - /// Indefinite length disallowed. - IndefiniteLength, - - /// Incorrect length for a given field. - Length { - /// Tag of the value being decoded. - tag: Tag, - }, - - /// Message is not canonically encoded. - Noncanonical { - /// Tag of the value which is not canonically encoded. - tag: Tag, - }, - - /// OID is improperly encoded. - OidMalformed, - - /// Unknown OID. - /// - /// This error is intended to be used by libraries which parse DER-based - /// formats which encounter unknown or unsupported OID libraries. - /// - /// It enables passing back the OID value to the caller, which allows them - /// to determine which OID(s) are causing the error (and then potentially - /// contribute upstream support for algorithms they care about). - #[cfg(feature = "oid")] - OidUnknown { - /// OID value that was unrecognized by a parser for a DER-based format. - oid: ObjectIdentifier, - }, - - /// `SET` cannot contain duplicates. - SetDuplicate, - - /// `SET` ordering error: items not in canonical order. - SetOrdering, - - /// Integer overflow occurred (library bug!). - Overflow, - - /// Message is longer than this library's internal limits support. - Overlength, - - /// PEM encoding errors. - #[cfg(feature = "pem")] - Pem(pem::Error), - - /// Permission denied reading file. - #[cfg(feature = "std")] - PermissionDenied, - - /// Reader does not support the requested operation. - Reader, - - /// Unknown tag mode. - TagModeUnknown, - - /// Invalid tag number. - /// - /// The "tag number" is the lower 5-bits of a tag's octet. - /// This error occurs in the case that all 5-bits are set to `1`, - /// which indicates a multi-byte tag which is unsupported by this library. - TagNumberInvalid, - - /// Unexpected tag. - TagUnexpected { - /// Tag the decoder was expecting (if there is a single such tag). - /// - /// `None` if multiple tags are expected/allowed, but the `actual` tag - /// does not match any of them. - expected: Option, - - /// Actual tag encountered in the message. - actual: Tag, - }, - - /// Unknown/unsupported tag. - TagUnknown { - /// Raw byte value of the tag. - byte: u8, - }, - - /// Undecoded trailing data at end of message. - TrailingData { - /// Length of the decoded data. - decoded: Length, - - /// Total length of the remaining data left in the buffer. - remaining: Length, - }, - - /// UTF-8 errors. - Utf8(Utf8Error), - - /// Unexpected value. - Value { - /// Tag of the unexpected value. - tag: Tag, - }, -} - -impl ErrorKind { - /// Annotate an [`ErrorKind`] with context about where it occurred, - /// returning an error. - pub fn at(self, position: Length) -> Error { - Error::new(self, position) - } -} - -impl fmt::Display for ErrorKind { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - ErrorKind::DateTime => write!(f, "date/time error"), - ErrorKind::Failed => write!(f, "operation failed"), - #[cfg(feature = "std")] - ErrorKind::FileNotFound => write!(f, "file not found"), - ErrorKind::Incomplete { - expected_len, - actual_len, - } => write!( - f, - "ASN.1 DER message is incomplete: expected {}, actual {}", - expected_len, actual_len - ), - #[cfg(feature = "std")] - ErrorKind::Io(err) => write!(f, "I/O error: {:?}", err), - ErrorKind::IndefiniteLength => write!(f, "indefinite length disallowed"), - ErrorKind::Length { tag } => write!(f, "incorrect length for {}", tag), - ErrorKind::Noncanonical { tag } => { - write!(f, "ASN.1 {} not canonically encoded as DER", tag) - } - ErrorKind::OidMalformed => write!(f, "malformed OID"), - #[cfg(feature = "oid")] - ErrorKind::OidUnknown { oid } => { - write!(f, "unknown/unsupported OID: {}", oid) - } - ErrorKind::SetDuplicate => write!(f, "SET OF contains duplicate"), - ErrorKind::SetOrdering => write!(f, "SET OF ordering error"), - ErrorKind::Overflow => write!(f, "integer overflow"), - ErrorKind::Overlength => write!(f, "ASN.1 DER message is too long"), - #[cfg(feature = "pem")] - ErrorKind::Pem(e) => write!(f, "PEM error: {}", e), - #[cfg(feature = "std")] - ErrorKind::PermissionDenied => write!(f, "permission denied"), - ErrorKind::Reader => write!(f, "reader does not support the requested operation"), - ErrorKind::TagModeUnknown => write!(f, "unknown tag mode"), - ErrorKind::TagNumberInvalid => write!(f, "invalid tag number"), - ErrorKind::TagUnexpected { expected, actual } => { - write!(f, "unexpected ASN.1 DER tag: ")?; - - if let Some(tag) = expected { - write!(f, "expected {}, ", tag)?; - } - - write!(f, "got {}", actual) - } - ErrorKind::TagUnknown { byte } => { - write!(f, "unknown/unsupported ASN.1 DER tag: 0x{:02x}", byte) - } - ErrorKind::TrailingData { decoded, remaining } => { - write!( - f, - "trailing data at end of DER message: decoded {} bytes, {} bytes remaining", - decoded, remaining - ) - } - ErrorKind::Utf8(e) => write!(f, "{}", e), - ErrorKind::Value { tag } => write!(f, "malformed ASN.1 DER value for {}", tag), - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/header.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/header.rs deleted file mode 100644 index ad303810c02a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/header.rs +++ /dev/null @@ -1,60 +0,0 @@ -//! ASN.1 DER headers. - -use crate::{Decode, DerOrd, Encode, ErrorKind, Length, Reader, Result, Tag, Writer}; -use core::cmp::Ordering; - -/// ASN.1 DER headers: tag + length component of TLV-encoded values -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Header { - /// Tag representing the type of the encoded value - pub tag: Tag, - - /// Length of the encoded value - pub length: Length, -} - -impl Header { - /// Create a new [`Header`] from a [`Tag`] and a specified length. - /// - /// Returns an error if the length exceeds the limits of [`Length`]. - pub fn new(tag: Tag, length: impl TryInto) -> Result { - let length = length.try_into().map_err(|_| ErrorKind::Overflow)?; - Ok(Self { tag, length }) - } -} - -impl<'a> Decode<'a> for Header { - fn decode>(reader: &mut R) -> Result
{ - let tag = Tag::decode(reader)?; - - let length = Length::decode(reader).map_err(|e| { - if e.kind() == ErrorKind::Overlength { - ErrorKind::Length { tag }.into() - } else { - e - } - })?; - - Ok(Self { tag, length }) - } -} - -impl Encode for Header { - fn encoded_len(&self) -> Result { - self.tag.encoded_len()? + self.length.encoded_len()? - } - - fn encode(&self, writer: &mut impl Writer) -> Result<()> { - self.tag.encode(writer)?; - self.length.encode(writer) - } -} - -impl DerOrd for Header { - fn der_cmp(&self, other: &Self) -> Result { - match self.tag.der_cmp(&other.tag)? { - Ordering::Equal => self.length.der_cmp(&other.length), - ordering => Ok(ordering), - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/length.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/length.rs deleted file mode 100644 index d183a69feab7..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/length.rs +++ /dev/null @@ -1,514 +0,0 @@ -//! Length calculations for encoded ASN.1 DER values - -use crate::{Decode, DerOrd, Encode, Error, ErrorKind, Reader, Result, SliceWriter, Writer}; -use core::{ - cmp::Ordering, - fmt, - ops::{Add, Sub}, -}; - -/// Maximum number of octets in a DER encoding of a [`Length`] using the -/// rules implemented by this crate. -const MAX_DER_OCTETS: usize = 5; - -/// Maximum length as a `u32` (256 MiB). -const MAX_U32: u32 = 0xfff_ffff; - -/// Octet identifying an indefinite length as described in X.690 Section -/// 8.1.3.6.1: -/// -/// > The single octet shall have bit 8 set to one, and bits 7 to -/// > 1 set to zero. -const INDEFINITE_LENGTH_OCTET: u8 = 0b10000000; // 0x80 - -/// ASN.1-encoded length. -/// -/// Maximum length is defined by the [`Length::MAX`] constant (256 MiB). -#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)] -pub struct Length(u32); - -impl Length { - /// Length of `0` - pub const ZERO: Self = Self(0); - - /// Length of `1` - pub const ONE: Self = Self(1); - - /// Maximum length currently supported: 256 MiB - pub const MAX: Self = Self(MAX_U32); - - /// Create a new [`Length`] for any value which fits inside of a [`u16`]. - /// - /// This function is const-safe and therefore useful for [`Length`] constants. - pub const fn new(value: u16) -> Self { - Self(value as u32) - } - - /// Is this length equal to zero? - pub fn is_zero(self) -> bool { - self == Self::ZERO - } - - /// Get the length of DER Tag-Length-Value (TLV) encoded data if `self` - /// is the length of the inner "value" portion of the message. - pub fn for_tlv(self) -> Result { - Self::ONE + self.encoded_len()? + self - } - - /// Perform saturating addition of two lengths. - pub fn saturating_add(self, rhs: Self) -> Self { - Self(self.0.saturating_add(rhs.0)) - } - - /// Perform saturating subtraction of two lengths. - pub fn saturating_sub(self, rhs: Self) -> Self { - Self(self.0.saturating_sub(rhs.0)) - } - - /// Get initial octet of the encoded length (if one is required). - /// - /// From X.690 Section 8.1.3.5: - /// > In the long form, the length octets shall consist of an initial octet - /// > and one or more subsequent octets. The initial octet shall be encoded - /// > as follows: - /// > - /// > a) bit 8 shall be one; - /// > b) bits 7 to 1 shall encode the number of subsequent octets in the - /// > length octets, as an unsigned binary integer with bit 7 as the - /// > most significant bit; - /// > c) the value 11111111₂ shall not be used. - fn initial_octet(self) -> Option { - match self.0 { - 0x80..=0xFF => Some(0x81), - 0x100..=0xFFFF => Some(0x82), - 0x10000..=0xFFFFFF => Some(0x83), - 0x1000000..=MAX_U32 => Some(0x84), - _ => None, - } - } -} - -impl Add for Length { - type Output = Result; - - fn add(self, other: Self) -> Result { - self.0 - .checked_add(other.0) - .ok_or_else(|| ErrorKind::Overflow.into()) - .and_then(TryInto::try_into) - } -} - -impl Add for Length { - type Output = Result; - - fn add(self, other: u8) -> Result { - self + Length::from(other) - } -} - -impl Add for Length { - type Output = Result; - - fn add(self, other: u16) -> Result { - self + Length::from(other) - } -} - -impl Add for Length { - type Output = Result; - - fn add(self, other: u32) -> Result { - self + Length::try_from(other)? - } -} - -impl Add for Length { - type Output = Result; - - fn add(self, other: usize) -> Result { - self + Length::try_from(other)? - } -} - -impl Add for Result { - type Output = Self; - - fn add(self, other: Length) -> Self { - self? + other - } -} - -impl Sub for Length { - type Output = Result; - - fn sub(self, other: Length) -> Result { - self.0 - .checked_sub(other.0) - .ok_or_else(|| ErrorKind::Overflow.into()) - .and_then(TryInto::try_into) - } -} - -impl Sub for Result { - type Output = Self; - - fn sub(self, other: Length) -> Self { - self? - other - } -} - -impl From for Length { - fn from(len: u8) -> Length { - Length(len.into()) - } -} - -impl From for Length { - fn from(len: u16) -> Length { - Length(len.into()) - } -} - -impl From for u32 { - fn from(length: Length) -> u32 { - length.0 - } -} - -impl TryFrom for Length { - type Error = Error; - - fn try_from(len: u32) -> Result { - if len <= Self::MAX.0 { - Ok(Length(len)) - } else { - Err(ErrorKind::Overflow.into()) - } - } -} - -impl TryFrom for Length { - type Error = Error; - - fn try_from(len: usize) -> Result { - u32::try_from(len) - .map_err(|_| ErrorKind::Overflow)? - .try_into() - } -} - -impl TryFrom for usize { - type Error = Error; - - fn try_from(len: Length) -> Result { - len.0.try_into().map_err(|_| ErrorKind::Overflow.into()) - } -} - -impl<'a> Decode<'a> for Length { - fn decode>(reader: &mut R) -> Result { - match reader.read_byte()? { - // Note: per X.690 Section 8.1.3.6.1 the byte 0x80 encodes indefinite - // lengths, which are not allowed in DER, so disallow that byte. - len if len < INDEFINITE_LENGTH_OCTET => Ok(len.into()), - INDEFINITE_LENGTH_OCTET => Err(ErrorKind::IndefiniteLength.into()), - // 1-4 byte variable-sized length prefix - tag @ 0x81..=0x84 => { - let nbytes = tag.checked_sub(0x80).ok_or(ErrorKind::Overlength)? as usize; - debug_assert!(nbytes <= 4); - - let mut decoded_len = 0u32; - for _ in 0..nbytes { - decoded_len = decoded_len.checked_shl(8).ok_or(ErrorKind::Overflow)? - | u32::from(reader.read_byte()?); - } - - let length = Length::try_from(decoded_len)?; - - // X.690 Section 10.1: DER lengths must be encoded with a minimum - // number of octets - if length.initial_octet() == Some(tag) { - Ok(length) - } else { - Err(ErrorKind::Overlength.into()) - } - } - _ => { - // We specialize to a maximum 4-byte length (including initial octet) - Err(ErrorKind::Overlength.into()) - } - } - } -} - -impl Encode for Length { - fn encoded_len(&self) -> Result { - match self.0 { - 0..=0x7F => Ok(Length(1)), - 0x80..=0xFF => Ok(Length(2)), - 0x100..=0xFFFF => Ok(Length(3)), - 0x10000..=0xFFFFFF => Ok(Length(4)), - 0x1000000..=MAX_U32 => Ok(Length(5)), - _ => Err(ErrorKind::Overflow.into()), - } - } - - fn encode(&self, writer: &mut impl Writer) -> Result<()> { - match self.initial_octet() { - Some(tag_byte) => { - writer.write_byte(tag_byte)?; - - // Strip leading zeroes - match self.0.to_be_bytes() { - [0, 0, 0, byte] => writer.write_byte(byte), - [0, 0, bytes @ ..] => writer.write(&bytes), - [0, bytes @ ..] => writer.write(&bytes), - bytes => writer.write(&bytes), - } - } - #[allow(clippy::cast_possible_truncation)] - None => writer.write_byte(self.0 as u8), - } - } -} - -impl DerOrd for Length { - fn der_cmp(&self, other: &Self) -> Result { - let mut buf1 = [0u8; MAX_DER_OCTETS]; - let mut buf2 = [0u8; MAX_DER_OCTETS]; - - let mut encoder1 = SliceWriter::new(&mut buf1); - encoder1.encode(self)?; - - let mut encoder2 = SliceWriter::new(&mut buf2); - encoder2.encode(other)?; - - Ok(encoder1.finish()?.cmp(encoder2.finish()?)) - } -} - -impl fmt::Display for Length { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0.fmt(f) - } -} - -// Implement by hand because the derive would create invalid values. -// Generate a u32 with a valid range. -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for Length { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - Ok(Self(u.int_in_range(0..=MAX_U32)?)) - } - - fn size_hint(depth: usize) -> (usize, Option) { - u32::size_hint(depth) - } -} - -/// Length type with support for indefinite lengths as used by ASN.1 BER, -/// as described in X.690 Section 8.1.3.6: -/// -/// > 8.1.3.6 For the indefinite form, the length octets indicate that the -/// > contents octets are terminated by end-of-contents -/// > octets (see 8.1.5), and shall consist of a single octet. -/// > -/// > 8.1.3.6.1 The single octet shall have bit 8 set to one, and bits 7 to -/// > 1 set to zero. -/// > -/// > 8.1.3.6.2 If this form of length is used, then end-of-contents octets -/// > (see 8.1.5) shall be present in the encoding following the contents -/// > octets. -/// -/// Indefinite lengths are non-canonical and therefore invalid DER, however -/// there are interoperability corner cases where we have little choice but to -/// tolerate some BER productions where this is helpful. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct IndefiniteLength(Option); - -impl IndefiniteLength { - /// Length of `0`. - pub const ZERO: Self = Self(Some(Length::ZERO)); - - /// Length of `1`. - pub const ONE: Self = Self(Some(Length::ONE)); - - /// Indefinite length. - pub const INDEFINITE: Self = Self(None); -} - -impl IndefiniteLength { - /// Create a definite length from a type which can be converted into a - /// `Length`. - pub fn new(length: impl Into) -> Self { - Self(Some(length.into())) - } - - /// Is this length definite? - pub fn is_definite(self) -> bool { - self.0.is_some() - } - /// Is this length indefinite? - pub fn is_indefinite(self) -> bool { - self.0.is_none() - } -} - -impl<'a> Decode<'a> for IndefiniteLength { - fn decode>(reader: &mut R) -> Result { - if reader.peek_byte() == Some(INDEFINITE_LENGTH_OCTET) { - // Consume the byte we already peeked at. - let byte = reader.read_byte()?; - debug_assert_eq!(byte, INDEFINITE_LENGTH_OCTET); - - Ok(Self::INDEFINITE) - } else { - Length::decode(reader).map(Into::into) - } - } -} - -impl Encode for IndefiniteLength { - fn encoded_len(&self) -> Result { - match self.0 { - Some(length) => length.encoded_len(), - None => Ok(Length::ONE), - } - } - - fn encode(&self, writer: &mut impl Writer) -> Result<()> { - match self.0 { - Some(length) => length.encode(writer), - None => writer.write_byte(INDEFINITE_LENGTH_OCTET), - } - } -} - -impl From for IndefiniteLength { - fn from(length: Length) -> IndefiniteLength { - Self(Some(length)) - } -} - -impl From> for IndefiniteLength { - fn from(length: Option) -> IndefiniteLength { - IndefiniteLength(length) - } -} - -impl From for Option { - fn from(length: IndefiniteLength) -> Option { - length.0 - } -} - -impl TryFrom for Length { - type Error = Error; - - fn try_from(length: IndefiniteLength) -> Result { - length.0.ok_or_else(|| ErrorKind::IndefiniteLength.into()) - } -} - -#[cfg(test)] -mod tests { - use super::{IndefiniteLength, Length}; - use crate::{Decode, DerOrd, Encode, ErrorKind}; - use core::cmp::Ordering; - - #[test] - fn decode() { - assert_eq!(Length::ZERO, Length::from_der(&[0x00]).unwrap()); - - assert_eq!(Length::from(0x7Fu8), Length::from_der(&[0x7F]).unwrap()); - - assert_eq!( - Length::from(0x80u8), - Length::from_der(&[0x81, 0x80]).unwrap() - ); - - assert_eq!( - Length::from(0xFFu8), - Length::from_der(&[0x81, 0xFF]).unwrap() - ); - - assert_eq!( - Length::from(0x100u16), - Length::from_der(&[0x82, 0x01, 0x00]).unwrap() - ); - - assert_eq!( - Length::try_from(0x10000u32).unwrap(), - Length::from_der(&[0x83, 0x01, 0x00, 0x00]).unwrap() - ); - } - - #[test] - fn encode() { - let mut buffer = [0u8; 4]; - - assert_eq!(&[0x00], Length::ZERO.encode_to_slice(&mut buffer).unwrap()); - - assert_eq!( - &[0x7F], - Length::from(0x7Fu8).encode_to_slice(&mut buffer).unwrap() - ); - - assert_eq!( - &[0x81, 0x80], - Length::from(0x80u8).encode_to_slice(&mut buffer).unwrap() - ); - - assert_eq!( - &[0x81, 0xFF], - Length::from(0xFFu8).encode_to_slice(&mut buffer).unwrap() - ); - - assert_eq!( - &[0x82, 0x01, 0x00], - Length::from(0x100u16).encode_to_slice(&mut buffer).unwrap() - ); - - assert_eq!( - &[0x83, 0x01, 0x00, 0x00], - Length::try_from(0x10000u32) - .unwrap() - .encode_to_slice(&mut buffer) - .unwrap() - ); - } - - #[test] - fn indefinite_lengths() { - // DER disallows indefinite lengths - assert!(Length::from_der(&[0x80]).is_err()); - - // The `IndefiniteLength` type supports them - let indefinite_length = IndefiniteLength::from_der(&[0x80]).unwrap(); - assert!(indefinite_length.is_indefinite()); - assert_eq!(indefinite_length, IndefiniteLength::INDEFINITE); - - // It also supports definite lengths. - let length = IndefiniteLength::from_der(&[0x83, 0x01, 0x00, 0x00]).unwrap(); - assert!(length.is_definite()); - assert_eq!( - Length::try_from(0x10000u32).unwrap(), - length.try_into().unwrap() - ); - } - - #[test] - fn add_overflows_when_max_length_exceeded() { - let result = Length::MAX + Length::ONE; - assert_eq!( - result.err().map(|err| err.kind()), - Some(ErrorKind::Overflow) - ); - } - - #[test] - fn der_ord() { - assert_eq!(Length::ONE.der_cmp(&Length::MAX).unwrap(), Ordering::Less); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/lib.rs deleted file mode 100644 index dcd5097d4b52..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/lib.rs +++ /dev/null @@ -1,402 +0,0 @@ -#![no_std] -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![doc = include_str!("../README.md")] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" -)] -#![forbid(unsafe_code)] -#![warn( - clippy::cast_lossless, - clippy::cast_possible_truncation, - clippy::cast_possible_wrap, - clippy::cast_precision_loss, - clippy::cast_sign_loss, - clippy::checked_conversions, - clippy::implicit_saturating_sub, - clippy::integer_arithmetic, - clippy::mod_module_files, - clippy::panic, - clippy::panic_in_result_fn, - clippy::unwrap_used, - missing_docs, - rust_2018_idioms, - unused_lifetimes, - unused_qualifications -)] - -//! # Usage -//! ## [`Decode`] and [`Encode`] traits -//! The [`Decode`] and [`Encode`] traits provide the decoding/encoding API -//! respectively, and are designed to work in conjunction with concrete ASN.1 -//! types, including all types which impl the [`Sequence`] trait. -//! -//! The traits are impl'd for the following Rust core types: -//! - `()`: ASN.1 `NULL`. See also [`Null`]. -//! - [`bool`]: ASN.1 `BOOLEAN`. -//! - [`i8`], [`i16`], [`i32`], [`i64`], [`i128`]: ASN.1 `INTEGER`. -//! - [`u8`], [`u16`], [`u32`], [`u64`], [`u128`]: ASN.1 `INTEGER`. -//! - [`f64`]: ASN.1 `REAL` (gated on `real` crate feature) -//! - [`str`], [`String`][`alloc::string::String`]: ASN.1 `UTF8String`. -//! `String` requires `alloc` feature. See also [`Utf8StringRef`]. -//! - [`Option`]: ASN.1 `OPTIONAL`. -//! - [`SystemTime`][`std::time::SystemTime`]: ASN.1 `GeneralizedTime`. Requires `std` feature. -//! - [`Vec`][`alloc::vec::Vec`]: ASN.1 `SEQUENCE OF`. Requires `alloc` feature. -//! - `[T; N]`: ASN.1 `SEQUENCE OF`. See also [`SequenceOf`]. -//! -//! The following ASN.1 types provided by this crate also impl these traits: -//! - [`Any`], [`AnyRef`]: ASN.1 `ANY`. -//! - [`BitString`], [`BitStringRef`]: ASN.1 `BIT STRING` -//! - [`GeneralizedTime`]: ASN.1 `GeneralizedTime`. -//! - [`Ia5StringRef`]: ASN.1 `IA5String`. -//! - [`Null`]: ASN.1 `NULL`. -//! - [`ObjectIdentifier`]: ASN.1 `OBJECT IDENTIFIER`. -//! - [`OctetString`], [`OctetStringRef`]: ASN.1 `OCTET STRING`. -//! - [`PrintableStringRef`]: ASN.1 `PrintableString` (ASCII subset). -//! - [`TeletexStringRef`]: ASN.1 `TeletexString`. -//! - [`VideotexStringRef`]: ASN.1 `VideotexString`. -//! - [`SequenceOf`]: ASN.1 `SEQUENCE OF`. -//! - [`SetOf`], [`SetOfVec`]: ASN.1 `SET OF`. -//! - [`UintRef`]: ASN.1 unsigned `INTEGER` with raw access to encoded bytes. -//! - [`UtcTime`]: ASN.1 `UTCTime`. -//! - [`Utf8StringRef`]: ASN.1 `UTF8String`. -//! -//! Context specific fields can be modeled using these generic types: -//! - [`ContextSpecific`]: decoder/encoder for owned context-specific fields -//! - [`ContextSpecificRef`]: encode-only type for references to context-specific fields -//! -//! ## Example -//! The following example implements X.509's `AlgorithmIdentifier` message type -//! as defined in [RFC 5280 Section 4.1.1.2]. -//! -//! The ASN.1 schema for this message type is as follows: -//! -//! ```text -//! AlgorithmIdentifier ::= SEQUENCE { -//! algorithm OBJECT IDENTIFIER, -//! parameters ANY DEFINED BY algorithm OPTIONAL } -//! ``` -//! -//! Structured ASN.1 messages are typically encoded as a `SEQUENCE`, which -//! this crate maps to a Rust struct using the [`Sequence`] trait. This -//! trait is bounded on the [`Decode`] trait and provides a blanket impl -//! of the [`Encode`] trait, so any type which impls [`Sequence`] can be -//! used for both decoding and encoding. -//! -//! The following code example shows how to define a struct which maps to the -//! above schema, as well as impl the [`Sequence`] trait for that struct: -//! -//! ``` -//! # #[cfg(all(feature = "alloc", feature = "oid"))] -//! # { -//! // Note: the following example does not require the `std` feature at all. -//! // It does leverage the `alloc` feature, but also provides instructions for -//! // "heapless" usage when the `alloc` feature is disabled. -//! use der::{ -//! asn1::{AnyRef, ObjectIdentifier}, -//! DecodeValue, Decode, SliceReader, Encode, Header, Reader, Sequence -//! }; -//! -//! /// X.509 `AlgorithmIdentifier`. -//! #[derive(Copy, Clone, Debug, Eq, PartialEq)] -//! pub struct AlgorithmIdentifier<'a> { -//! /// This field contains an ASN.1 `OBJECT IDENTIFIER`, a.k.a. OID. -//! pub algorithm: ObjectIdentifier, -//! -//! /// This field is `OPTIONAL` and contains the ASN.1 `ANY` type, which -//! /// in this example allows arbitrary algorithm-defined parameters. -//! pub parameters: Option> -//! } -//! -//! impl<'a> DecodeValue<'a> for AlgorithmIdentifier<'a> { -//! fn decode_value>(reader: &mut R, _header: Header) -> der::Result { -//! // The `der::Decoder::Decode` method can be used to decode any -//! // type which impls the `Decode` trait, which is impl'd for -//! // all of the ASN.1 built-in types in the `der` crate. -//! // -//! // Note that if your struct's fields don't contain an ASN.1 -//! // built-in type specifically, there are also helper methods -//! // for all of the built-in types supported by this library -//! // which can be used to select a specific type. -//! // -//! // For example, another way of decoding this particular field, -//! // which contains an ASN.1 `OBJECT IDENTIFIER`, is by calling -//! // `decoder.oid()`. Similar methods are defined for other -//! // ASN.1 built-in types. -//! let algorithm = reader.decode()?; -//! -//! // This field contains an ASN.1 `OPTIONAL` type. The `der` crate -//! // maps this directly to Rust's `Option` type and provides -//! // impls of the `Decode` and `Encode` traits for `Option`. -//! // To explicitly request an `OPTIONAL` type be decoded, use the -//! // `decoder.optional()` method. -//! let parameters = reader.decode()?; -//! -//! // The value returned from the provided `FnOnce` will be -//! // returned from the `any.sequence(...)` call above. -//! // Note that the entire sequence body *MUST* be consumed -//! // or an error will be returned. -//! Ok(Self { algorithm, parameters }) -//! } -//! } -//! -//! impl<'a> ::der::EncodeValue for AlgorithmIdentifier<'a> { -//! fn value_len(&self) -> ::der::Result<::der::Length> { -//! self.algorithm.encoded_len()? + self.parameters.encoded_len()? -//! } -//! -//! fn encode_value(&self, writer: &mut impl ::der::Writer) -> ::der::Result<()> { -//! self.algorithm.encode(writer)?; -//! self.parameters.encode(writer)?; -//! Ok(()) -//! } -//! } -//! -//! impl<'a> Sequence<'a> for AlgorithmIdentifier<'a> {} -//! -//! // Example parameters value: OID for the NIST P-256 elliptic curve. -//! let parameters = "1.2.840.10045.3.1.7".parse::().unwrap(); -//! -//! // We need to convert `parameters` into an `Any<'a>` type, which wraps a -//! // `&'a [u8]` byte slice. -//! // -//! // To do that, we need owned DER-encoded data so that we can have -//! // `AnyRef` borrow a reference to it, so we have to serialize the OID. -//! // -//! // When the `alloc` feature of this crate is enabled, any type that impls -//! // the `Encode` trait including all ASN.1 built-in types and any type -//! // which impls `Sequence` can be serialized by calling `Encode::to_der()`. -//! // -//! // If you would prefer to avoid allocations, you can create a byte array -//! // as backing storage instead, pass that to `der::Encoder::new`, and then -//! // encode the `parameters` value using `encoder.encode(parameters)`. -//! let der_encoded_parameters = parameters.to_der().unwrap(); -//! -//! let algorithm_identifier = AlgorithmIdentifier { -//! // OID for `id-ecPublicKey`, if you're curious -//! algorithm: "1.2.840.10045.2.1".parse().unwrap(), -//! -//! // `Any<'a>` impls `TryFrom<&'a [u8]>`, which parses the provided -//! // slice as an ASN.1 DER-encoded message. -//! parameters: Some(der_encoded_parameters.as_slice().try_into().unwrap()) -//! }; -//! -//! // Serialize the `AlgorithmIdentifier` created above as ASN.1 DER, -//! // allocating a `Vec` for storage. -//! // -//! // As mentioned earlier, if you don't have the `alloc` feature enabled you -//! // can create a fix-sized array instead, then call `Encoder::new` with a -//! // reference to it, then encode the message using -//! // `encoder.encode(algorithm_identifier)`, then finally `encoder.finish()` -//! // to obtain a byte slice containing the encoded message. -//! let der_encoded_algorithm_identifier = algorithm_identifier.to_der().unwrap(); -//! -//! // Deserialize the `AlgorithmIdentifier` we just serialized from ASN.1 DER -//! // using `der::Decode::from_bytes`. -//! let decoded_algorithm_identifier = AlgorithmIdentifier::from_der( -//! &der_encoded_algorithm_identifier -//! ).unwrap(); -//! -//! // Ensure the original `AlgorithmIdentifier` is the same as the one we just -//! // decoded from ASN.1 DER. -//! assert_eq!(algorithm_identifier, decoded_algorithm_identifier); -//! # } -//! ``` -//! -//! ## Custom derive support -//! When the `derive` feature of this crate is enabled, the following custom -//! derive macros are available: -//! -//! - [`Choice`]: derive for `CHOICE` enum (see [`der_derive::Choice`]) -//! - [`Enumerated`]: derive for `ENUMERATED` enum (see [`der_derive::Enumerated`]) -//! - [`Sequence`]: derive for `SEQUENCE` struct (see [`der_derive::Sequence`]) -//! -//! ### Derive [`Sequence`] for struct -//! The following is a code example of how to use the [`Sequence`] custom derive: -//! -//! ``` -//! # #[cfg(all(feature = "alloc", feature = "derive", feature = "oid"))] -//! # { -//! use der::{asn1::{AnyRef, ObjectIdentifier}, Encode, Decode, Sequence}; -//! -//! /// X.509 `AlgorithmIdentifier` (same as above) -//! #[derive(Copy, Clone, Debug, Eq, PartialEq, Sequence)] // NOTE: added `Sequence` -//! pub struct AlgorithmIdentifier<'a> { -//! /// This field contains an ASN.1 `OBJECT IDENTIFIER`, a.k.a. OID. -//! pub algorithm: ObjectIdentifier, -//! -//! /// This field is `OPTIONAL` and contains the ASN.1 `ANY` type, which -//! /// in this example allows arbitrary algorithm-defined parameters. -//! pub parameters: Option> -//! } -//! -//! // Example parameters value: OID for the NIST P-256 elliptic curve. -//! let parameters_oid = "1.2.840.10045.3.1.7".parse::().unwrap(); -//! -//! let algorithm_identifier = AlgorithmIdentifier { -//! // OID for `id-ecPublicKey`, if you're curious -//! algorithm: "1.2.840.10045.2.1".parse().unwrap(), -//! -//! // `Any<'a>` impls `From<&'a ObjectIdentifier>`, allowing OID constants to -//! // be directly converted to an `AnyRef` type for this use case. -//! parameters: Some(AnyRef::from(¶meters_oid)) -//! }; -//! -//! // Encode -//! let der_encoded_algorithm_identifier = algorithm_identifier.to_der().unwrap(); -//! -//! // Decode -//! let decoded_algorithm_identifier = AlgorithmIdentifier::from_der( -//! &der_encoded_algorithm_identifier -//! ).unwrap(); -//! -//! assert_eq!(algorithm_identifier, decoded_algorithm_identifier); -//! # } -//! ``` -//! -//! For fields which don't directly impl [`Decode`] and [`Encode`], -//! you can add annotations to convert to an intermediate ASN.1 type -//! first, so long as that type impls `TryFrom` and `Into` for the -//! ASN.1 type. -//! -//! For example, structs containing `&'a [u8]` fields may want them encoded -//! as either a `BIT STRING` or `OCTET STRING`. By using the -//! `#[asn1(type = "BIT STRING")]` annotation it's possible to select which -//! ASN.1 type should be used. -//! -//! Building off the above example: -//! -//! ```rust -//! # #[cfg(all(feature = "alloc", feature = "derive", feature = "oid"))] -//! # { -//! # use der::{asn1::{AnyRef, BitStringRef, ObjectIdentifier}, Sequence}; -//! # -//! # #[derive(Copy, Clone, Debug, Eq, PartialEq, Sequence)] -//! # pub struct AlgorithmIdentifier<'a> { -//! # pub algorithm: ObjectIdentifier, -//! # pub parameters: Option> -//! # } -//! /// X.509 `SubjectPublicKeyInfo` (SPKI) -//! #[derive(Copy, Clone, Debug, Eq, PartialEq, Sequence)] -//! pub struct SubjectPublicKeyInfo<'a> { -//! /// X.509 `AlgorithmIdentifier` -//! pub algorithm: AlgorithmIdentifier<'a>, -//! -//! /// Public key data -//! pub subject_public_key: BitStringRef<'a>, -//! } -//! # } -//! ``` -//! -//! # See also -//! For more information about ASN.1 DER we recommend the following guides: -//! -//! - [A Layman's Guide to a Subset of ASN.1, BER, and DER] (RSA Laboratories) -//! - [A Warm Welcome to ASN.1 and DER] (Let's Encrypt) -//! -//! [RFC 5280 Section 4.1.1.2]: https://tools.ietf.org/html/rfc5280#section-4.1.1.2 -//! [A Layman's Guide to a Subset of ASN.1, BER, and DER]: https://luca.ntop.org/Teaching/Appunti/asn1.html -//! [A Warm Welcome to ASN.1 and DER]: https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/ -//! -//! [`Any`]: asn1::Any -//! [`AnyRef`]: asn1::AnyRef -//! [`ContextSpecific`]: asn1::ContextSpecific -//! [`ContextSpecificRef`]: asn1::ContextSpecificRef -//! [`BitString`]: asn1::BitString -//! [`BitStringRef`]: asn1::BitStringRef -//! [`GeneralizedTime`]: asn1::GeneralizedTime -//! [`Ia5StringRef`]: asn1::Ia5StringRef -//! [`Null`]: asn1::Null -//! [`ObjectIdentifier`]: asn1::ObjectIdentifier -//! [`OctetString`]: asn1::OctetString -//! [`OctetStringRef`]: asn1::OctetStringRef -//! [`PrintableStringRef`]: asn1::PrintableStringRef -//! [`TeletexStringRef`]: asn1::TeletexStringRef -//! [`VideotexStringRef`]: asn1::VideotexStringRef -//! [`SequenceOf`]: asn1::SequenceOf -//! [`SetOf`]: asn1::SetOf -//! [`SetOfVec`]: asn1::SetOfVec -//! [`UintRef`]: asn1::UintRef -//! [`UtcTime`]: asn1::UtcTime -//! [`Utf8StringRef`]: asn1::Utf8StringRef - -#[cfg(feature = "alloc")] -#[allow(unused_imports)] -#[macro_use] -extern crate alloc; -#[cfg(feature = "std")] -extern crate std; - -pub mod asn1; -pub mod referenced; - -pub(crate) mod arrayvec; -mod bytes_ref; -mod datetime; -mod decode; -mod encode; -mod encode_ref; -mod error; -mod header; -mod length; -mod ord; -mod reader; -mod str_ref; -mod tag; -mod writer; - -#[cfg(feature = "alloc")] -mod bytes_owned; -#[cfg(feature = "alloc")] -mod document; -#[cfg(feature = "alloc")] -mod str_owned; - -pub use crate::{ - asn1::{AnyRef, Choice, Sequence}, - datetime::DateTime, - decode::{Decode, DecodeOwned, DecodeValue}, - encode::{Encode, EncodeValue}, - encode_ref::{EncodeRef, EncodeValueRef}, - error::{Error, ErrorKind, Result}, - header::Header, - length::{IndefiniteLength, Length}, - ord::{DerOrd, ValueOrd}, - reader::{nested::NestedReader, slice::SliceReader, Reader}, - tag::{Class, FixedTag, Tag, TagMode, TagNumber, Tagged}, - writer::{slice::SliceWriter, Writer}, -}; - -#[cfg(feature = "alloc")] -pub use crate::{asn1::Any, document::Document}; - -#[cfg(feature = "bigint")] -pub use crypto_bigint as bigint; - -#[cfg(feature = "derive")] -pub use der_derive::{Choice, Enumerated, Sequence, ValueOrd}; - -#[cfg(feature = "flagset")] -pub use flagset; - -#[cfg(feature = "oid")] -pub use const_oid as oid; - -#[cfg(feature = "pem")] -pub use { - crate::{decode::DecodePem, encode::EncodePem, reader::pem::PemReader, writer::pem::PemWriter}, - pem_rfc7468 as pem, -}; - -#[cfg(feature = "time")] -pub use time; - -#[cfg(feature = "zeroize")] -pub use zeroize; - -#[cfg(all(feature = "alloc", feature = "zeroize"))] -pub use crate::document::SecretDocument; - -pub(crate) use crate::{arrayvec::ArrayVec, bytes_ref::BytesRef, str_ref::StrRef}; -#[cfg(feature = "alloc")] -pub(crate) use crate::{bytes_owned::BytesOwned, str_owned::StrOwned}; diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/ord.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/ord.rs deleted file mode 100644 index 42d462340b42..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/ord.rs +++ /dev/null @@ -1,85 +0,0 @@ -//! Ordering trait. - -use crate::{EncodeValue, Result, Tagged}; -use core::{cmp::Ordering, marker::PhantomData}; - -/// DER ordering trait. -/// -/// Compares the ordering of two values based on their ASN.1 DER -/// serializations. -/// -/// This is used by the DER encoding for `SET OF` in order to establish an -/// ordering for the elements of sets. -pub trait DerOrd { - /// Return an [`Ordering`] between `self` and `other` when serialized as - /// ASN.1 DER. - fn der_cmp(&self, other: &Self) -> Result; -} - -/// DER value ordering trait. -/// -/// Compares the ordering of the value portion of TLV-encoded DER productions. -pub trait ValueOrd { - /// Return an [`Ordering`] between value portion of TLV-encoded `self` and - /// `other` when serialized as ASN.1 DER. - fn value_cmp(&self, other: &Self) -> Result; -} - -impl DerOrd for T -where - T: EncodeValue + ValueOrd + Tagged, -{ - fn der_cmp(&self, other: &Self) -> Result { - match self.header()?.der_cmp(&other.header()?)? { - Ordering::Equal => self.value_cmp(other), - ordering => Ok(ordering), - } - } -} - -/// Marker trait for types whose `Ord` impl can be used as `ValueOrd`. -/// -/// This means the `Ord` impl will sort values in the same order as their DER -/// encodings. -pub trait OrdIsValueOrd: Ord {} - -impl ValueOrd for T -where - T: OrdIsValueOrd, -{ - fn value_cmp(&self, other: &Self) -> Result { - Ok(self.cmp(other)) - } -} - -/// Compare the order of two iterators using [`DerCmp`] on the values. -pub(crate) fn iter_cmp<'a, I, T: 'a>(a: I, b: I) -> Result -where - I: Iterator + ExactSizeIterator, - T: DerOrd, -{ - let length_ord = a.len().cmp(&b.len()); - - for (value1, value2) in a.zip(b) { - match value1.der_cmp(value2)? { - Ordering::Equal => (), - other => return Ok(other), - } - } - - Ok(length_ord) -} - -/// Provide a no-op implementation for PhantomData -impl ValueOrd for PhantomData { - fn value_cmp(&self, _other: &Self) -> Result { - Ok(Ordering::Equal) - } -} - -/// Provide a no-op implementation for PhantomData -impl DerOrd for PhantomData { - fn der_cmp(&self, _other: &Self) -> Result { - Ok(Ordering::Equal) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader.rs deleted file mode 100644 index ea52f7bded92..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader.rs +++ /dev/null @@ -1,167 +0,0 @@ -//! Reader trait. - -pub(crate) mod nested; -#[cfg(feature = "pem")] -pub(crate) mod pem; -pub(crate) mod slice; - -pub(crate) use nested::NestedReader; - -use crate::{ - asn1::ContextSpecific, Decode, DecodeValue, Encode, Error, ErrorKind, FixedTag, Header, Length, - Result, Tag, TagMode, TagNumber, -}; - -#[cfg(feature = "alloc")] -use alloc::vec::Vec; - -/// Reader trait which reads DER-encoded input. -pub trait Reader<'r>: Sized { - /// Get the length of the input. - fn input_len(&self) -> Length; - - /// Peek at the next byte of input without modifying the cursor. - fn peek_byte(&self) -> Option; - - /// Peek forward in the input data, attempting to decode a [`Header`] from - /// the data at the current position in the decoder. - /// - /// Does not modify the decoder's state. - fn peek_header(&self) -> Result
; - - /// Get the position within the buffer. - fn position(&self) -> Length; - - /// Attempt to read data borrowed directly from the input as a slice, - /// updating the internal cursor position. - /// - /// # Returns - /// - `Ok(slice)` on success - /// - `Err(ErrorKind::Incomplete)` if there is not enough data - /// - `Err(ErrorKind::Reader)` if the reader can't borrow from the input - fn read_slice(&mut self, len: Length) -> Result<&'r [u8]>; - - /// Attempt to decode an ASN.1 `CONTEXT-SPECIFIC` field with the - /// provided [`TagNumber`]. - fn context_specific(&mut self, tag_number: TagNumber, tag_mode: TagMode) -> Result> - where - T: DecodeValue<'r> + FixedTag, - { - Ok(match tag_mode { - TagMode::Explicit => ContextSpecific::::decode_explicit(self, tag_number)?, - TagMode::Implicit => ContextSpecific::::decode_implicit(self, tag_number)?, - } - .map(|field| field.value)) - } - - /// Decode a value which impls the [`Decode`] trait. - fn decode>(&mut self) -> Result { - T::decode(self).map_err(|e| e.nested(self.position())) - } - - /// Return an error with the given [`ErrorKind`], annotating it with - /// context about where the error occurred. - fn error(&mut self, kind: ErrorKind) -> Error { - kind.at(self.position()) - } - - /// Finish decoding, returning the given value if there is no - /// remaining data, or an error otherwise - fn finish(self, value: T) -> Result { - if !self.is_finished() { - Err(ErrorKind::TrailingData { - decoded: self.position(), - remaining: self.remaining_len(), - } - .at(self.position())) - } else { - Ok(value) - } - } - - /// Have we read all of the input data? - fn is_finished(&self) -> bool { - self.remaining_len().is_zero() - } - - /// Offset within the original input stream. - /// - /// This is used for error reporting, and doesn't need to be overridden - /// by any reader implementations (except for the built-in `NestedReader`, - /// which consumes nested input messages) - fn offset(&self) -> Length { - self.position() - } - - /// Peek at the next byte in the decoder and attempt to decode it as a - /// [`Tag`] value. - /// - /// Does not modify the decoder's state. - fn peek_tag(&self) -> Result { - match self.peek_byte() { - Some(byte) => byte.try_into(), - None => Err(Error::incomplete(self.input_len())), - } - } - - /// Read a single byte. - fn read_byte(&mut self) -> Result { - let mut buf = [0]; - self.read_into(&mut buf)?; - Ok(buf[0]) - } - - /// Attempt to read input data, writing it into the provided buffer, and - /// returning a slice on success. - /// - /// # Returns - /// - `Ok(slice)` if there is sufficient data - /// - `Err(ErrorKind::Incomplete)` if there is not enough data - fn read_into<'o>(&mut self, buf: &'o mut [u8]) -> Result<&'o [u8]> { - let input = self.read_slice(buf.len().try_into()?)?; - buf.copy_from_slice(input); - Ok(buf) - } - - /// Read nested data of the given length. - fn read_nested<'n, T, F>(&'n mut self, len: Length, f: F) -> Result - where - F: FnOnce(&mut NestedReader<'n, Self>) -> Result, - { - let mut reader = NestedReader::new(self, len)?; - let ret = f(&mut reader)?; - reader.finish(ret) - } - - /// Read a byte vector of the given length. - #[cfg(feature = "alloc")] - fn read_vec(&mut self, len: Length) -> Result> { - let mut bytes = vec![0u8; usize::try_from(len)?]; - self.read_into(&mut bytes)?; - Ok(bytes) - } - - /// Get the number of bytes still remaining in the buffer. - fn remaining_len(&self) -> Length { - debug_assert!(self.position() <= self.input_len()); - self.input_len().saturating_sub(self.position()) - } - - /// Read an ASN.1 `SEQUENCE`, creating a nested [`Reader`] for the body and - /// calling the provided closure with it. - fn sequence<'n, F, T>(&'n mut self, f: F) -> Result - where - F: FnOnce(&mut NestedReader<'n, Self>) -> Result, - { - let header = Header::decode(self)?; - header.tag.assert_eq(Tag::Sequence)?; - self.read_nested(header.length, f) - } - - /// Obtain a slice of bytes contain a complete TLV production suitable for parsing later. - fn tlv_bytes(&mut self) -> Result<&'r [u8]> { - let header = self.peek_header()?; - let header_len = header.encoded_len()?; - self.read_slice((header_len + header.length)?) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/nested.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/nested.rs deleted file mode 100644 index 40ede69ac757..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/nested.rs +++ /dev/null @@ -1,96 +0,0 @@ -//! Reader type for consuming nested TLV records within a DER document. - -use crate::{reader::Reader, Error, ErrorKind, Header, Length, Result}; - -/// Reader type used by [`Reader::read_nested`]. -pub struct NestedReader<'i, R> { - /// Inner reader type. - inner: &'i mut R, - - /// Nested input length. - input_len: Length, - - /// Position within the nested input. - position: Length, -} - -impl<'i, 'r, R: Reader<'r>> NestedReader<'i, R> { - /// Create a new nested reader which can read the given [`Length`]. - pub(crate) fn new(inner: &'i mut R, len: Length) -> Result { - if len <= inner.remaining_len() { - Ok(Self { - inner, - input_len: len, - position: Length::ZERO, - }) - } else { - Err(ErrorKind::Incomplete { - expected_len: (inner.offset() + len)?, - actual_len: (inner.offset() + inner.remaining_len())?, - } - .at(inner.offset())) - } - } - - /// Move the position cursor the given length, returning an error if there - /// isn't enough remaining data in the nested input. - fn advance_position(&mut self, len: Length) -> Result<()> { - let new_position = (self.position + len)?; - - if new_position <= self.input_len { - self.position = new_position; - Ok(()) - } else { - Err(ErrorKind::Incomplete { - expected_len: (self.inner.offset() + len)?, - actual_len: (self.inner.offset() + self.remaining_len())?, - } - .at(self.inner.offset())) - } - } -} - -impl<'i, 'r, R: Reader<'r>> Reader<'r> for NestedReader<'i, R> { - fn input_len(&self) -> Length { - self.input_len - } - - fn peek_byte(&self) -> Option { - if self.is_finished() { - None - } else { - self.inner.peek_byte() - } - } - - fn peek_header(&self) -> Result
{ - if self.is_finished() { - Err(Error::incomplete(self.offset())) - } else { - // TODO(tarcieri): handle peeking past nested length - self.inner.peek_header() - } - } - - fn position(&self) -> Length { - self.position - } - - fn read_slice(&mut self, len: Length) -> Result<&'r [u8]> { - self.advance_position(len)?; - self.inner.read_slice(len) - } - - fn error(&mut self, kind: ErrorKind) -> Error { - self.inner.error(kind) - } - - fn offset(&self) -> Length { - self.inner.offset() - } - - fn read_into<'o>(&mut self, out: &'o mut [u8]) -> Result<&'o [u8]> { - self.advance_position(Length::try_from(out.len())?)?; - self.inner.read_into(out) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/pem.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/pem.rs deleted file mode 100644 index f11341aa6f35..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/pem.rs +++ /dev/null @@ -1,206 +0,0 @@ -//! Streaming PEM reader. - -use super::Reader; -use crate::{Decode, Error, ErrorKind, Header, Length, Result}; -use core::cell::RefCell; - -#[allow(clippy::integer_arithmetic)] -mod utils { - use crate::{Error, Length, Result}; - use pem_rfc7468::Decoder; - - #[derive(Clone)] - pub(super) struct BufReader<'i> { - /// Inner PEM decoder. - decoder: Decoder<'i>, - - /// Remaining after base64 decoding - remaining: usize, - - /// Read buffer - buf: [u8; BufReader::CAPACITY], - - /// Position of the head in the buffer, - pos: usize, - - /// Position of the tail in the buffer, - cap: usize, - } - - impl<'i> BufReader<'i> { - const CAPACITY: usize = 256; - - pub fn new(pem: &'i [u8]) -> Result { - let decoder = Decoder::new(pem)?; - let remaining = decoder.remaining_len(); - - Ok(Self { - decoder, - remaining, - buf: [0u8; 256], - pos: 0, - cap: 0, - }) - } - - pub fn remaining_len(&self) -> usize { - self.decoder.remaining_len() + self.cap - self.pos - } - - fn fill_buffer(&mut self) -> Result<()> { - debug_assert!(self.pos <= self.cap); - - if self.is_empty() { - self.pos = 0; - self.cap = 0; - } - - let end = (self.cap + self.remaining).min(Self::CAPACITY); - let writable_slice = &mut self.buf[self.cap..end]; - if writable_slice.is_empty() { - return Ok(()); - } - - let wrote = self.decoder.decode(writable_slice)?.len(); - if wrote == 0 { - return Err(Error::incomplete(Length::try_from(self.pos)?)); - } - - self.cap += wrote; - self.remaining -= wrote; - debug_assert!(self.cap <= Self::CAPACITY); - - Ok(()) - } - - /// Get the PEM label which will be used in the encapsulation boundaries - /// for this document. - pub fn type_label(&self) -> &'i str { - self.decoder.type_label() - } - - fn is_empty(&self) -> bool { - self.pos == self.cap - } - - fn as_slice(&self) -> &[u8] { - &self.buf[self.pos..self.cap] - } - } - - impl<'i> BufReader<'i> { - pub fn peek_byte(&self) -> Option { - let s = self.as_slice(); - s.first().copied() - } - - pub fn copy_to_slice<'o>(&mut self, buf: &'o mut [u8]) -> Result<&'o [u8]> { - let mut output_pos = 0; - - while output_pos < buf.len() { - if self.is_empty() { - self.fill_buffer()?; - } - - let available = &self.buf[self.pos..self.cap]; - let window_len = (buf.len() - output_pos).min(available.len()); - let window = &mut buf[output_pos..output_pos + window_len]; - - window.copy_from_slice(&available[..window_len]); - self.pos += window_len; - output_pos += window_len; - } - - // Don't leave the read buffer empty for peek_byte() - if self.is_empty() && self.decoder.remaining_len() != 0 { - self.fill_buffer()? - } - - debug_assert_eq!(output_pos, buf.len()); - - Ok(buf) - } - } -} - -/// `Reader` type which decodes PEM on-the-fly. -#[cfg(feature = "pem")] -#[derive(Clone)] -pub struct PemReader<'i> { - /// Inner PEM decoder wrapped in a BufReader. - reader: RefCell>, - - /// Input length (in bytes after Base64 decoding). - input_len: Length, - - /// Position in the input buffer (in bytes after Base64 decoding). - position: Length, -} - -#[cfg(feature = "pem")] -impl<'i> PemReader<'i> { - /// Create a new PEM reader which decodes data on-the-fly. - /// - /// Uses the default 64-character line wrapping. - pub fn new(pem: &'i [u8]) -> Result { - let reader = utils::BufReader::new(pem)?; - let input_len = Length::try_from(reader.remaining_len())?; - - Ok(Self { - reader: RefCell::new(reader), - input_len, - position: Length::ZERO, - }) - } - - /// Get the PEM label which will be used in the encapsulation boundaries - /// for this document. - pub fn type_label(&self) -> &'i str { - self.reader.borrow().type_label() - } -} - -#[cfg(feature = "pem")] -impl<'i> Reader<'i> for PemReader<'i> { - fn input_len(&self) -> Length { - self.input_len - } - - fn peek_byte(&self) -> Option { - if self.is_finished() { - None - } else { - self.reader.borrow().peek_byte() - } - } - - fn peek_header(&self) -> Result
{ - if self.is_finished() { - Err(Error::incomplete(self.offset())) - } else { - Header::decode(&mut self.clone()) - } - } - - fn position(&self) -> Length { - self.position - } - - fn read_slice(&mut self, _len: Length) -> Result<&'i [u8]> { - // Can't borrow from PEM because it requires decoding - Err(ErrorKind::Reader.into()) - } - - fn read_into<'o>(&mut self, buf: &'o mut [u8]) -> Result<&'o [u8]> { - let bytes = self.reader.borrow_mut().copy_to_slice(buf)?; - - self.position = (self.position + bytes.len())?; - - debug_assert_eq!( - self.position, - (self.input_len - Length::try_from(self.reader.borrow().remaining_len())?)? - ); - - Ok(bytes) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/slice.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/slice.rs deleted file mode 100644 index e78468fed542..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/slice.rs +++ /dev/null @@ -1,214 +0,0 @@ -//! Slice reader. - -use crate::{BytesRef, Decode, Error, ErrorKind, Header, Length, Reader, Result, Tag}; - -/// [`Reader`] which consumes an input byte slice. -#[derive(Clone, Debug)] -pub struct SliceReader<'a> { - /// Byte slice being decoded. - bytes: BytesRef<'a>, - - /// Did the decoding operation fail? - failed: bool, - - /// Position within the decoded slice. - position: Length, -} - -impl<'a> SliceReader<'a> { - /// Create a new slice reader for the given byte slice. - pub fn new(bytes: &'a [u8]) -> Result { - Ok(Self { - bytes: BytesRef::new(bytes)?, - failed: false, - position: Length::ZERO, - }) - } - - /// Return an error with the given [`ErrorKind`], annotating it with - /// context about where the error occurred. - pub fn error(&mut self, kind: ErrorKind) -> Error { - self.failed = true; - kind.at(self.position) - } - - /// Return an error for an invalid value with the given tag. - pub fn value_error(&mut self, tag: Tag) -> Error { - self.error(tag.value_error().kind()) - } - - /// Did the decoding operation fail due to an error? - pub fn is_failed(&self) -> bool { - self.failed - } - - /// Obtain the remaining bytes in this slice reader from the current cursor - /// position. - fn remaining(&self) -> Result<&'a [u8]> { - if self.is_failed() { - Err(ErrorKind::Failed.at(self.position)) - } else { - self.bytes - .as_slice() - .get(self.position.try_into()?..) - .ok_or_else(|| Error::incomplete(self.input_len())) - } - } -} - -impl<'a> Reader<'a> for SliceReader<'a> { - fn input_len(&self) -> Length { - self.bytes.len() - } - - fn peek_byte(&self) -> Option { - self.remaining() - .ok() - .and_then(|bytes| bytes.first().cloned()) - } - - fn peek_header(&self) -> Result
{ - Header::decode(&mut self.clone()) - } - - fn position(&self) -> Length { - self.position - } - - fn read_slice(&mut self, len: Length) -> Result<&'a [u8]> { - if self.is_failed() { - return Err(self.error(ErrorKind::Failed)); - } - - match self.remaining()?.get(..len.try_into()?) { - Some(result) => { - self.position = (self.position + len)?; - Ok(result) - } - None => Err(self.error(ErrorKind::Incomplete { - expected_len: (self.position + len)?, - actual_len: self.input_len(), - })), - } - } - - fn decode>(&mut self) -> Result { - if self.is_failed() { - return Err(self.error(ErrorKind::Failed)); - } - - T::decode(self).map_err(|e| { - self.failed = true; - e.nested(self.position) - }) - } - - fn error(&mut self, kind: ErrorKind) -> Error { - self.failed = true; - kind.at(self.position) - } - - fn finish(self, value: T) -> Result { - if self.is_failed() { - Err(ErrorKind::Failed.at(self.position)) - } else if !self.is_finished() { - Err(ErrorKind::TrailingData { - decoded: self.position, - remaining: self.remaining_len(), - } - .at(self.position)) - } else { - Ok(value) - } - } - - fn remaining_len(&self) -> Length { - debug_assert!(self.position <= self.input_len()); - self.input_len().saturating_sub(self.position) - } -} - -#[cfg(test)] -mod tests { - use super::SliceReader; - use crate::{Decode, ErrorKind, Length, Reader, Tag}; - use hex_literal::hex; - - // INTEGER: 42 - const EXAMPLE_MSG: &[u8] = &hex!("02012A00"); - - #[test] - fn empty_message() { - let mut reader = SliceReader::new(&[]).unwrap(); - let err = bool::decode(&mut reader).err().unwrap(); - assert_eq!(Some(Length::ZERO), err.position()); - - match err.kind() { - ErrorKind::Incomplete { - expected_len, - actual_len, - } => { - assert_eq!(actual_len, 0u8.into()); - assert_eq!(expected_len, 1u8.into()); - } - other => panic!("unexpected error kind: {:?}", other), - } - } - - #[test] - fn invalid_field_length() { - const MSG_LEN: usize = 2; - - let mut reader = SliceReader::new(&EXAMPLE_MSG[..MSG_LEN]).unwrap(); - let err = i8::decode(&mut reader).err().unwrap(); - assert_eq!(Some(Length::from(2u8)), err.position()); - - match err.kind() { - ErrorKind::Incomplete { - expected_len, - actual_len, - } => { - assert_eq!(actual_len, MSG_LEN.try_into().unwrap()); - assert_eq!(expected_len, (MSG_LEN + 1).try_into().unwrap()); - } - other => panic!("unexpected error kind: {:?}", other), - } - } - - #[test] - fn trailing_data() { - let mut reader = SliceReader::new(EXAMPLE_MSG).unwrap(); - let x = i8::decode(&mut reader).unwrap(); - assert_eq!(42i8, x); - - let err = reader.finish(x).err().unwrap(); - assert_eq!(Some(Length::from(3u8)), err.position()); - - assert_eq!( - ErrorKind::TrailingData { - decoded: 3u8.into(), - remaining: 1u8.into() - }, - err.kind() - ); - } - - #[test] - fn peek_tag() { - let reader = SliceReader::new(EXAMPLE_MSG).unwrap(); - assert_eq!(reader.position(), Length::ZERO); - assert_eq!(reader.peek_tag().unwrap(), Tag::Integer); - assert_eq!(reader.position(), Length::ZERO); // Position unchanged - } - - #[test] - fn peek_header() { - let reader = SliceReader::new(EXAMPLE_MSG).unwrap(); - assert_eq!(reader.position(), Length::ZERO); - - let header = reader.peek_header().unwrap(); - assert_eq!(header.tag, Tag::Integer); - assert_eq!(header.length, Length::ONE); - assert_eq!(reader.position(), Length::ZERO); // Position unchanged - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/referenced.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/referenced.rs deleted file mode 100644 index b0c8f0325882..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/referenced.rs +++ /dev/null @@ -1,69 +0,0 @@ -//! A module for working with referenced data. - -/// A trait for borrowing data from an owned struct -pub trait OwnedToRef { - /// The resulting type referencing back to Self - type Borrowed<'a> - where - Self: 'a; - - /// Creates a new object referencing back to the self for storage - fn owned_to_ref(&self) -> Self::Borrowed<'_>; -} - -/// A trait for cloning a referenced structure and getting owned objects -/// -/// This is the pendant to [`OwnedToRef`] -pub trait RefToOwned<'a> { - /// The resulting type after obtaining ownership. - type Owned: OwnedToRef = Self> - where - Self: 'a; - - /// Creates a new object taking ownership of the data - fn ref_to_owned(&self) -> Self::Owned; -} - -impl OwnedToRef for Option -where - T: OwnedToRef, -{ - type Borrowed<'a> = Option> where T: 'a; - - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - self.as_ref().map(|o| o.owned_to_ref()) - } -} - -impl<'a, T> RefToOwned<'a> for Option -where - T: RefToOwned<'a> + 'a, - T::Owned: OwnedToRef, -{ - type Owned = Option; - fn ref_to_owned(&self) -> Self::Owned { - self.as_ref().map(|o| o.ref_to_owned()) - } -} - -#[cfg(feature = "alloc")] -mod allocating { - use super::{OwnedToRef, RefToOwned}; - use alloc::boxed::Box; - - impl<'a> RefToOwned<'a> for &'a [u8] { - type Owned = Box<[u8]>; - - fn ref_to_owned(&self) -> Self::Owned { - Box::from(*self) - } - } - - impl OwnedToRef for Box<[u8]> { - type Borrowed<'a> = &'a [u8]; - - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - self.as_ref() - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_owned.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_owned.rs deleted file mode 100644 index 20bfea5bd7a1..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_owned.rs +++ /dev/null @@ -1,104 +0,0 @@ -//! Common handling for types backed by `String` with enforcement of a -//! library-level length limitation i.e. `Length::max()`. - -use crate::{ - referenced::OwnedToRef, BytesRef, DecodeValue, EncodeValue, Header, Length, Reader, Result, - StrRef, Writer, -}; -use alloc::string::String; -use core::str; - -/// String newtype which respects the [`Length::max`] limit. -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct StrOwned { - /// Inner value - pub(crate) inner: String, - - /// Precomputed `Length` (avoids possible panicking conversions) - pub(crate) length: Length, -} - -impl StrOwned { - /// Create a new [`StrOwned`], ensuring that the byte representation of - /// the provided `str` value is shorter than `Length::max()`. - pub fn new(s: String) -> Result { - let length = Length::try_from(s.as_bytes().len())?; - - Ok(Self { inner: s, length }) - } - - /// Parse a [`String`] from UTF-8 encoded bytes. - pub fn from_bytes(bytes: &[u8]) -> Result { - Ok(Self { - inner: String::from_utf8(bytes.to_vec())?, - length: Length::try_from(bytes.len())?, - }) - } - - /// Borrow the inner `str` - pub fn as_str(&self) -> &str { - &self.inner - } - - /// Borrow the inner byte slice - pub fn as_bytes(&self) -> &[u8] { - self.inner.as_bytes() - } - - /// Get the [`Length`] of this [`StrOwned`] - pub fn len(&self) -> Length { - self.length - } - - /// Is this [`StrOwned`] empty? - pub fn is_empty(&self) -> bool { - self.len() == Length::ZERO - } -} - -impl AsRef for StrOwned { - fn as_ref(&self) -> &str { - self.as_str() - } -} - -impl AsRef<[u8]> for StrOwned { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } -} - -impl<'a> DecodeValue<'a> for StrOwned { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Self::from_bytes(BytesRef::decode_value(reader, header)?.as_slice()) - } -} - -impl EncodeValue for StrOwned { - fn value_len(&self) -> Result { - Ok(self.length) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_ref()) - } -} - -impl From> for StrOwned { - fn from(s: StrRef<'_>) -> StrOwned { - Self { - inner: String::from(s.inner), - length: s.length, - } - } -} - -impl OwnedToRef for StrOwned { - type Borrowed<'a> = StrRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - StrRef { - length: self.length, - inner: self.inner.as_ref(), - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_ref.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_ref.rs deleted file mode 100644 index 899c7506b5f9..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_ref.rs +++ /dev/null @@ -1,92 +0,0 @@ -//! Common handling for types backed by `str` slices with enforcement of a -//! library-level length limitation i.e. `Length::max()`. - -use crate::{BytesRef, DecodeValue, EncodeValue, Header, Length, Reader, Result, Writer}; -use core::str; - -/// String slice newtype which respects the [`Length::max`] limit. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct StrRef<'a> { - /// Inner value - pub(crate) inner: &'a str, - - /// Precomputed `Length` (avoids possible panicking conversions) - pub(crate) length: Length, -} - -impl<'a> StrRef<'a> { - /// Create a new [`StrRef`], ensuring that the byte representation of - /// the provided `str` value is shorter than `Length::max()`. - pub fn new(s: &'a str) -> Result { - Ok(Self { - inner: s, - length: Length::try_from(s.as_bytes().len())?, - }) - } - - /// Parse a [`StrRef`] from UTF-8 encoded bytes. - pub fn from_bytes(bytes: &'a [u8]) -> Result { - Self::new(str::from_utf8(bytes)?) - } - - /// Borrow the inner `str` - pub fn as_str(&self) -> &'a str { - self.inner - } - - /// Borrow the inner byte slice - pub fn as_bytes(&self) -> &'a [u8] { - self.inner.as_bytes() - } - - /// Get the [`Length`] of this [`StrRef`] - pub fn len(self) -> Length { - self.length - } - - /// Is this [`StrRef`] empty? - pub fn is_empty(self) -> bool { - self.len() == Length::ZERO - } -} - -impl AsRef for StrRef<'_> { - fn as_ref(&self) -> &str { - self.as_str() - } -} - -impl AsRef<[u8]> for StrRef<'_> { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } -} - -impl<'a> DecodeValue<'a> for StrRef<'a> { - fn decode_value>(reader: &mut R, header: Header) -> Result { - Self::from_bytes(BytesRef::decode_value(reader, header)?.as_slice()) - } -} - -impl<'a> EncodeValue for StrRef<'a> { - fn value_len(&self) -> Result { - Ok(self.length) - } - - fn encode_value(&self, writer: &mut impl Writer) -> Result<()> { - writer.write(self.as_ref()) - } -} - -#[cfg(feature = "alloc")] -mod allocating { - use super::StrRef; - use crate::{referenced::RefToOwned, StrOwned}; - - impl<'a> RefToOwned<'a> for StrRef<'a> { - type Owned = StrOwned; - fn ref_to_owned(&self) -> Self::Owned { - StrOwned::from(*self) - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag.rs deleted file mode 100644 index 7a1fed1b77ad..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag.rs +++ /dev/null @@ -1,460 +0,0 @@ -//! ASN.1 tags. -#![cfg_attr(feature = "arbitrary", allow(clippy::integer_arithmetic))] - -mod class; -mod mode; -mod number; - -pub use self::{class::Class, mode::TagMode, number::TagNumber}; - -use crate::{Decode, DerOrd, Encode, Error, ErrorKind, Length, Reader, Result, Writer}; -use core::{cmp::Ordering, fmt}; - -/// Indicator bit for constructed form encoding (i.e. vs primitive form) -const CONSTRUCTED_FLAG: u8 = 0b100000; - -/// Types which have a constant ASN.1 [`Tag`]. -pub trait FixedTag { - /// ASN.1 tag - const TAG: Tag; -} - -/// Types which have an ASN.1 [`Tag`]. -pub trait Tagged { - /// Get the ASN.1 tag that this type is encoded with. - fn tag(&self) -> Tag; -} - -/// Types which are [`FixedTag`] always have a known [`Tag`] type. -impl Tagged for T { - fn tag(&self) -> Tag { - T::TAG - } -} - -/// ASN.1 tags. -/// -/// Tags are the leading identifier octet of the Tag-Length-Value encoding -/// used by ASN.1 DER and identify the type of the subsequent value. -/// -/// They are described in X.690 Section 8.1.2: Identifier octets, and -/// structured as follows: -/// -/// ```text -/// | Class | P/C | Tag Number | -/// ``` -/// -/// - Bits 8/7: [`Class`] -/// - Bit 6: primitive (0) or constructed (1) -/// - Bits 5-1: tag number -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)] -#[non_exhaustive] -pub enum Tag { - /// `BOOLEAN` tag: `1`. - Boolean, - - /// `INTEGER` tag: `2`. - Integer, - - /// `BIT STRING` tag: `3`. - BitString, - - /// `OCTET STRING` tag: `4`. - OctetString, - - /// `NULL` tag: `5`. - Null, - - /// `OBJECT IDENTIFIER` tag: `6`. - ObjectIdentifier, - - /// `REAL` tag: `9`. - Real, - - /// `ENUMERATED` tag: `10`. - Enumerated, - - /// `UTF8String` tag: `12`. - Utf8String, - - /// `SEQUENCE` tag: `16`. - Sequence, - - /// `SET` and `SET OF` tag: `17`. - Set, - - /// `NumericString` tag: `18`. - NumericString, - - /// `PrintableString` tag: `19`. - PrintableString, - - /// `TeletexString` tag: `20`. - TeletexString, - - /// `VideotexString` tag: `21`. - VideotexString, - - /// `IA5String` tag: `22`. - Ia5String, - - /// `UTCTime` tag: `23`. - UtcTime, - - /// `GeneralizedTime` tag: `24`. - GeneralizedTime, - - /// `VisibleString` tag: `26`. - VisibleString, - - /// `BMPString` tag: `30`. - BmpString, - - /// Application tag. - Application { - /// Is this tag constructed? (vs primitive). - constructed: bool, - - /// Tag number. - number: TagNumber, - }, - - /// Context-specific tag. - ContextSpecific { - /// Is this tag constructed? (vs primitive). - constructed: bool, - - /// Tag number. - number: TagNumber, - }, - - /// Private tag number. - Private { - /// Is this tag constructed? (vs primitive). - constructed: bool, - - /// Tag number. - number: TagNumber, - }, -} - -impl Tag { - /// Assert that this [`Tag`] matches the provided expected tag. - /// - /// On mismatch, returns an [`Error`] with [`ErrorKind::TagUnexpected`]. - pub fn assert_eq(self, expected: Tag) -> Result { - if self == expected { - Ok(self) - } else { - Err(self.unexpected_error(Some(expected))) - } - } - - /// Get the [`Class`] that corresponds to this [`Tag`]. - pub fn class(self) -> Class { - match self { - Tag::Application { .. } => Class::Application, - Tag::ContextSpecific { .. } => Class::ContextSpecific, - Tag::Private { .. } => Class::Private, - _ => Class::Universal, - } - } - - /// Get the [`TagNumber`] (lower 6-bits) for this tag. - pub fn number(self) -> TagNumber { - TagNumber(self.octet() & TagNumber::MASK) - } - - /// Does this tag represent a constructed (as opposed to primitive) field? - pub fn is_constructed(self) -> bool { - self.octet() & CONSTRUCTED_FLAG != 0 - } - - /// Is this an application tag? - pub fn is_application(self) -> bool { - self.class() == Class::Application - } - - /// Is this a context-specific tag? - pub fn is_context_specific(self) -> bool { - self.class() == Class::ContextSpecific - } - - /// Is this a private tag? - pub fn is_private(self) -> bool { - self.class() == Class::Private - } - - /// Is this a universal tag? - pub fn is_universal(self) -> bool { - self.class() == Class::Universal - } - - /// Get the octet encoding for this [`Tag`]. - pub fn octet(self) -> u8 { - match self { - Tag::Boolean => 0x01, - Tag::Integer => 0x02, - Tag::BitString => 0x03, - Tag::OctetString => 0x04, - Tag::Null => 0x05, - Tag::ObjectIdentifier => 0x06, - Tag::Real => 0x09, - Tag::Enumerated => 0x0A, - Tag::Utf8String => 0x0C, - Tag::Sequence => 0x10 | CONSTRUCTED_FLAG, - Tag::Set => 0x11 | CONSTRUCTED_FLAG, - Tag::NumericString => 0x12, - Tag::PrintableString => 0x13, - Tag::TeletexString => 0x14, - Tag::VideotexString => 0x15, - Tag::Ia5String => 0x16, - Tag::UtcTime => 0x17, - Tag::GeneralizedTime => 0x18, - Tag::VisibleString => 0x1A, - Tag::BmpString => 0x1E, - Tag::Application { - constructed, - number, - } - | Tag::ContextSpecific { - constructed, - number, - } - | Tag::Private { - constructed, - number, - } => self.class().octet(constructed, number), - } - } - - /// Create an [`Error`] for an invalid [`Length`]. - pub fn length_error(self) -> Error { - ErrorKind::Length { tag: self }.into() - } - - /// Create an [`Error`] for an non-canonical value with the ASN.1 type - /// identified by this tag. - pub fn non_canonical_error(self) -> Error { - ErrorKind::Noncanonical { tag: self }.into() - } - - /// Create an [`Error`] because the current tag was unexpected, with an - /// optional expected tag. - pub fn unexpected_error(self, expected: Option) -> Error { - ErrorKind::TagUnexpected { - expected, - actual: self, - } - .into() - } - - /// Create an [`Error`] for an invalid value with the ASN.1 type identified - /// by this tag. - pub fn value_error(self) -> Error { - ErrorKind::Value { tag: self }.into() - } -} - -impl TryFrom for Tag { - type Error = Error; - - fn try_from(byte: u8) -> Result { - let constructed = byte & CONSTRUCTED_FLAG != 0; - let number = TagNumber::try_from(byte & TagNumber::MASK)?; - - match byte { - 0x01 => Ok(Tag::Boolean), - 0x02 => Ok(Tag::Integer), - 0x03 => Ok(Tag::BitString), - 0x04 => Ok(Tag::OctetString), - 0x05 => Ok(Tag::Null), - 0x06 => Ok(Tag::ObjectIdentifier), - 0x09 => Ok(Tag::Real), - 0x0A => Ok(Tag::Enumerated), - 0x0C => Ok(Tag::Utf8String), - 0x12 => Ok(Tag::NumericString), - 0x13 => Ok(Tag::PrintableString), - 0x14 => Ok(Tag::TeletexString), - 0x15 => Ok(Tag::VideotexString), - 0x16 => Ok(Tag::Ia5String), - 0x17 => Ok(Tag::UtcTime), - 0x18 => Ok(Tag::GeneralizedTime), - 0x1A => Ok(Tag::VisibleString), - 0x1E => Ok(Tag::BmpString), - 0x30 => Ok(Tag::Sequence), // constructed - 0x31 => Ok(Tag::Set), // constructed - 0x40..=0x7E => Ok(Tag::Application { - constructed, - number, - }), - 0x80..=0xBE => Ok(Tag::ContextSpecific { - constructed, - number, - }), - 0xC0..=0xFE => Ok(Tag::Private { - constructed, - number, - }), - _ => Err(ErrorKind::TagUnknown { byte }.into()), - } - } -} - -impl From for u8 { - fn from(tag: Tag) -> u8 { - tag.octet() - } -} - -impl From<&Tag> for u8 { - fn from(tag: &Tag) -> u8 { - u8::from(*tag) - } -} - -impl<'a> Decode<'a> for Tag { - fn decode>(reader: &mut R) -> Result { - reader.read_byte().and_then(Self::try_from) - } -} - -impl Encode for Tag { - fn encoded_len(&self) -> Result { - Ok(Length::ONE) - } - - fn encode(&self, writer: &mut impl Writer) -> Result<()> { - writer.write_byte(self.into()) - } -} - -impl DerOrd for Tag { - fn der_cmp(&self, other: &Self) -> Result { - Ok(self.octet().cmp(&other.octet())) - } -} - -impl fmt::Display for Tag { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - const FIELD_TYPE: [&str; 2] = ["primitive", "constructed"]; - - match *self { - Tag::Boolean => f.write_str("BOOLEAN"), - Tag::Integer => f.write_str("INTEGER"), - Tag::BitString => f.write_str("BIT STRING"), - Tag::OctetString => f.write_str("OCTET STRING"), - Tag::Null => f.write_str("NULL"), - Tag::ObjectIdentifier => f.write_str("OBJECT IDENTIFIER"), - Tag::Real => f.write_str("REAL"), - Tag::Enumerated => f.write_str("ENUMERATED"), - Tag::Utf8String => f.write_str("UTF8String"), - Tag::Set => f.write_str("SET"), - Tag::NumericString => f.write_str("NumericString"), - Tag::PrintableString => f.write_str("PrintableString"), - Tag::TeletexString => f.write_str("TeletexString"), - Tag::VideotexString => f.write_str("VideotexString"), - Tag::Ia5String => f.write_str("IA5String"), - Tag::UtcTime => f.write_str("UTCTime"), - Tag::GeneralizedTime => f.write_str("GeneralizedTime"), - Tag::VisibleString => f.write_str("VisibleString"), - Tag::BmpString => f.write_str("BMPString"), - Tag::Sequence => f.write_str("SEQUENCE"), - Tag::Application { - constructed, - number, - } => write!( - f, - "APPLICATION [{}] ({})", - number, - FIELD_TYPE[usize::from(constructed)] - ), - Tag::ContextSpecific { - constructed, - number, - } => write!( - f, - "CONTEXT-SPECIFIC [{}] ({})", - number, - FIELD_TYPE[usize::from(constructed)] - ), - Tag::Private { - constructed, - number, - } => write!( - f, - "PRIVATE [{}] ({})", - number, - FIELD_TYPE[usize::from(constructed)] - ), - } - } -} - -impl fmt::Debug for Tag { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Tag(0x{:02x}: {})", u8::from(*self), self) - } -} - -#[cfg(test)] -mod tests { - use super::TagNumber; - use super::{Class, Tag}; - - #[test] - fn tag_class() { - assert_eq!(Tag::Boolean.class(), Class::Universal); - assert_eq!(Tag::Integer.class(), Class::Universal); - assert_eq!(Tag::BitString.class(), Class::Universal); - assert_eq!(Tag::OctetString.class(), Class::Universal); - assert_eq!(Tag::Null.class(), Class::Universal); - assert_eq!(Tag::ObjectIdentifier.class(), Class::Universal); - assert_eq!(Tag::Real.class(), Class::Universal); - assert_eq!(Tag::Enumerated.class(), Class::Universal); - assert_eq!(Tag::Utf8String.class(), Class::Universal); - assert_eq!(Tag::Set.class(), Class::Universal); - assert_eq!(Tag::NumericString.class(), Class::Universal); - assert_eq!(Tag::PrintableString.class(), Class::Universal); - assert_eq!(Tag::TeletexString.class(), Class::Universal); - assert_eq!(Tag::VideotexString.class(), Class::Universal); - assert_eq!(Tag::Ia5String.class(), Class::Universal); - assert_eq!(Tag::UtcTime.class(), Class::Universal); - assert_eq!(Tag::GeneralizedTime.class(), Class::Universal); - assert_eq!(Tag::Sequence.class(), Class::Universal); - - for num in 0..=30 { - for &constructed in &[false, true] { - let number = TagNumber::new(num); - - assert_eq!( - Tag::Application { - constructed, - number - } - .class(), - Class::Application - ); - - assert_eq!( - Tag::ContextSpecific { - constructed, - number - } - .class(), - Class::ContextSpecific - ); - - assert_eq!( - Tag::Private { - constructed, - number - } - .class(), - Class::Private - ); - } - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/class.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/class.rs deleted file mode 100644 index 8a3e2ed10195..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/class.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! Class of an ASN.1 tag. - -use super::{TagNumber, CONSTRUCTED_FLAG}; -use core::fmt; - -/// Class of an ASN.1 tag. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -#[repr(u8)] -pub enum Class { - /// `UNIVERSAL`: built-in types whose meaning is the same in all - /// applications. - Universal = 0b00000000, - - /// `APPLICATION`: types whose meaning is specific to an application, - /// - /// Types in two different applications may have the same - /// application-specific tag and different meanings. - Application = 0b01000000, - - /// `CONTEXT-SPECIFIC`: types whose meaning is specific to a given - /// structured type. - /// - /// Context-specific tags are used to distinguish between component types - /// with the same underlying tag within the context of a given structured - /// type, and component types in two different structured types may have - /// the same tag and different meanings. - ContextSpecific = 0b10000000, - - /// `PRIVATE`: types whose meaning is specific to a given enterprise. - Private = 0b11000000, -} - -impl Class { - /// Compute the identifier octet for a tag number of this class. - #[allow(clippy::integer_arithmetic)] - pub(super) fn octet(self, constructed: bool, number: TagNumber) -> u8 { - self as u8 | number.value() | (u8::from(constructed) * CONSTRUCTED_FLAG) - } -} - -impl fmt::Display for Class { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(match self { - Class::Universal => "UNIVERSAL", - Class::Application => "APPLICATION", - Class::ContextSpecific => "CONTEXT-SPECIFIC", - Class::Private => "PRIVATE", - }) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/mode.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/mode.rs deleted file mode 100644 index ecdaf023a125..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/mode.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! Tag modes. - -use crate::{Error, ErrorKind, Result}; -use core::{fmt, str::FromStr}; - -/// Tagging modes: `EXPLICIT` versus `IMPLICIT`. -#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)] -pub enum TagMode { - /// `EXPLICIT` tagging. - /// - /// Tag is added in addition to the inner tag of the type. - #[default] - Explicit, - - /// `IMPLICIT` tagging. - /// - /// Tag replaces the existing tag of the inner type. - Implicit, -} - -impl FromStr for TagMode { - type Err = Error; - - fn from_str(s: &str) -> Result { - match s { - "EXPLICIT" | "explicit" => Ok(TagMode::Explicit), - "IMPLICIT" | "implicit" => Ok(TagMode::Implicit), - _ => Err(ErrorKind::TagModeUnknown.into()), - } - } -} - -impl fmt::Display for TagMode { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - TagMode::Explicit => f.write_str("EXPLICIT"), - TagMode::Implicit => f.write_str("IMPLICIT"), - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/number.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/number.rs deleted file mode 100644 index 6a7eaae22cab..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/number.rs +++ /dev/null @@ -1,201 +0,0 @@ -//! ASN.1 tag numbers - -use super::Tag; -use crate::{Error, ErrorKind, Result}; -use core::fmt; - -/// ASN.1 tag numbers (i.e. lower 5 bits of a [`Tag`]). -/// -/// From X.690 Section 8.1.2.2: -/// -/// > bits 5 to 1 shall encode the number of the tag as a binary integer with -/// > bit 5 as the most significant bit. -/// -/// This library supports tag numbers ranging from zero to 30 (inclusive), -/// which can be represented as a single identifier octet. -/// -/// Section 8.1.2.4 describes how to support multi-byte tag numbers, which are -/// encoded by using a leading tag number of 31 (`0b11111`). This library -/// deliberately does not support this: tag numbers greater than 30 are -/// disallowed. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct TagNumber(pub(super) u8); - -impl TagNumber { - /// Tag number `0` - pub const N0: Self = Self(0); - - /// Tag number `1` - pub const N1: Self = Self(1); - - /// Tag number `2` - pub const N2: Self = Self(2); - - /// Tag number `3` - pub const N3: Self = Self(3); - - /// Tag number `4` - pub const N4: Self = Self(4); - - /// Tag number `5` - pub const N5: Self = Self(5); - - /// Tag number `6` - pub const N6: Self = Self(6); - - /// Tag number `7` - pub const N7: Self = Self(7); - - /// Tag number `8` - pub const N8: Self = Self(8); - - /// Tag number `9` - pub const N9: Self = Self(9); - - /// Tag number `10` - pub const N10: Self = Self(10); - - /// Tag number `11` - pub const N11: Self = Self(11); - - /// Tag number `12` - pub const N12: Self = Self(12); - - /// Tag number `13` - pub const N13: Self = Self(13); - - /// Tag number `14` - pub const N14: Self = Self(14); - - /// Tag number `15` - pub const N15: Self = Self(15); - - /// Tag number `16` - pub const N16: Self = Self(16); - - /// Tag number `17` - pub const N17: Self = Self(17); - - /// Tag number `18` - pub const N18: Self = Self(18); - - /// Tag number `19` - pub const N19: Self = Self(19); - - /// Tag number `20` - pub const N20: Self = Self(20); - - /// Tag number `21` - pub const N21: Self = Self(21); - - /// Tag number `22` - pub const N22: Self = Self(22); - - /// Tag number `23` - pub const N23: Self = Self(23); - - /// Tag number `24` - pub const N24: Self = Self(24); - - /// Tag number `25` - pub const N25: Self = Self(25); - - /// Tag number `26` - pub const N26: Self = Self(26); - - /// Tag number `27` - pub const N27: Self = Self(27); - - /// Tag number `28` - pub const N28: Self = Self(28); - - /// Tag number `29` - pub const N29: Self = Self(29); - - /// Tag number `30` - pub const N30: Self = Self(30); - - /// Mask value used to obtain the tag number from a tag octet. - pub(super) const MASK: u8 = 0b11111; - - /// Maximum tag number supported (inclusive). - const MAX: u8 = 30; - - /// Create a new tag number (const-friendly). - /// - /// Panics if the tag number is greater than `30`. - /// For a fallible conversion, use [`TryFrom`] instead. - pub const fn new(byte: u8) -> Self { - #[allow(clippy::panic)] - if byte > Self::MAX { - panic!("tag number out of range"); - } - - Self(byte) - } - - /// Create an `APPLICATION` tag with this tag number. - pub fn application(self, constructed: bool) -> Tag { - Tag::Application { - constructed, - number: self, - } - } - - /// Create a `CONTEXT-SPECIFIC` tag with this tag number. - pub fn context_specific(self, constructed: bool) -> Tag { - Tag::ContextSpecific { - constructed, - number: self, - } - } - - /// Create a `PRIVATE` tag with this tag number. - pub fn private(self, constructed: bool) -> Tag { - Tag::Private { - constructed, - number: self, - } - } - - /// Get the inner value. - pub fn value(self) -> u8 { - self.0 - } -} - -impl TryFrom for TagNumber { - type Error = Error; - - fn try_from(byte: u8) -> Result { - match byte { - 0..=Self::MAX => Ok(Self(byte)), - _ => Err(ErrorKind::TagNumberInvalid.into()), - } - } -} - -impl From for u8 { - fn from(tag_number: TagNumber) -> u8 { - tag_number.0 - } -} - -impl fmt::Display for TagNumber { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.0) - } -} - -// Implement by hand because the derive would create invalid values. -// Use the constructor to create a valid value. -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for TagNumber { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - Ok(Self::new(u.int_in_range(0..=Self::MAX)?)) - } - - fn size_hint(depth: usize) -> (usize, Option) { - u8::size_hint(depth) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer.rs deleted file mode 100644 index 164b215f75f4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Writer trait. - -#[cfg(feature = "pem")] -pub(crate) mod pem; -pub(crate) mod slice; - -use crate::Result; - -#[cfg(feature = "std")] -use std::io; - -/// Writer trait which outputs encoded DER. -pub trait Writer { - /// Write the given DER-encoded bytes as output. - fn write(&mut self, slice: &[u8]) -> Result<()>; - - /// Write a single byte. - fn write_byte(&mut self, byte: u8) -> Result<()> { - self.write(&[byte]) - } -} - -#[cfg(feature = "std")] -impl Writer for W { - fn write(&mut self, slice: &[u8]) -> Result<()> { - ::write(self, slice)?; - Ok(()) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/pem.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/pem.rs deleted file mode 100644 index 87a6f8fd8e2e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/pem.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Streaming PEM writer. - -use super::Writer; -use crate::Result; -use pem_rfc7468::{Encoder, LineEnding}; - -/// `Writer` type which outputs PEM-encoded data. -pub struct PemWriter<'w>(Encoder<'static, 'w>); - -impl<'w> PemWriter<'w> { - /// Create a new PEM writer which outputs into the provided buffer. - /// - /// Uses the default 64-character line wrapping. - pub fn new( - type_label: &'static str, - line_ending: LineEnding, - out: &'w mut [u8], - ) -> Result { - Ok(Self(Encoder::new(type_label, line_ending, out)?)) - } - - /// Get the PEM label which will be used in the encapsulation boundaries - /// for this document. - pub fn type_label(&self) -> &'static str { - self.0.type_label() - } - - /// Finish encoding PEM, writing the post-encapsulation boundary. - /// - /// On success, returns the total number of bytes written to the output buffer. - pub fn finish(self) -> Result { - Ok(self.0.finish()?) - } -} - -impl Writer for PemWriter<'_> { - fn write(&mut self, slice: &[u8]) -> Result<()> { - self.0.encode(slice)?; - Ok(()) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/slice.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/slice.rs deleted file mode 100644 index 87083ad12dd5..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/slice.rs +++ /dev/null @@ -1,149 +0,0 @@ -//! Slice writer. - -use crate::{ - asn1::*, Encode, EncodeValue, ErrorKind, Header, Length, Result, Tag, TagMode, TagNumber, - Tagged, Writer, -}; - -/// [`Writer`] which encodes DER into a mutable output byte slice. -#[derive(Debug)] -pub struct SliceWriter<'a> { - /// Buffer into which DER-encoded message is written - bytes: &'a mut [u8], - - /// Has the encoding operation failed? - failed: bool, - - /// Total number of bytes written to buffer so far - position: Length, -} - -impl<'a> SliceWriter<'a> { - /// Create a new encoder with the given byte slice as a backing buffer. - pub fn new(bytes: &'a mut [u8]) -> Self { - Self { - bytes, - failed: false, - position: Length::ZERO, - } - } - - /// Encode a value which impls the [`Encode`] trait. - pub fn encode(&mut self, encodable: &T) -> Result<()> { - if self.is_failed() { - self.error(ErrorKind::Failed)? - } - - encodable.encode(self).map_err(|e| { - self.failed = true; - e.nested(self.position) - }) - } - - /// Return an error with the given [`ErrorKind`], annotating it with - /// context about where the error occurred. - pub fn error(&mut self, kind: ErrorKind) -> Result { - self.failed = true; - Err(kind.at(self.position)) - } - - /// Did the decoding operation fail due to an error? - pub fn is_failed(&self) -> bool { - self.failed - } - - /// Finish encoding to the buffer, returning a slice containing the data - /// written to the buffer. - pub fn finish(self) -> Result<&'a [u8]> { - let position = self.position; - - if self.is_failed() { - return Err(ErrorKind::Failed.at(position)); - } - - self.bytes - .get(..usize::try_from(position)?) - .ok_or_else(|| ErrorKind::Overlength.at(position)) - } - - /// Encode a `CONTEXT-SPECIFIC` field with the provided tag number and mode. - pub fn context_specific( - &mut self, - tag_number: TagNumber, - tag_mode: TagMode, - value: &T, - ) -> Result<()> - where - T: EncodeValue + Tagged, - { - ContextSpecificRef { - tag_number, - tag_mode, - value, - } - .encode(self) - } - - /// Encode an ASN.1 `SEQUENCE` of the given length. - /// - /// Spawns a nested slice writer which is expected to be exactly the - /// specified length upon completion. - pub fn sequence(&mut self, length: Length, f: F) -> Result<()> - where - F: FnOnce(&mut SliceWriter<'_>) -> Result<()>, - { - Header::new(Tag::Sequence, length).and_then(|header| header.encode(self))?; - - let mut nested_encoder = SliceWriter::new(self.reserve(length)?); - f(&mut nested_encoder)?; - - if nested_encoder.finish()?.len() == usize::try_from(length)? { - Ok(()) - } else { - self.error(ErrorKind::Length { tag: Tag::Sequence }) - } - } - - /// Reserve a portion of the internal buffer, updating the internal cursor - /// position and returning a mutable slice. - fn reserve(&mut self, len: impl TryInto) -> Result<&mut [u8]> { - if self.is_failed() { - return Err(ErrorKind::Failed.at(self.position)); - } - - let len = len - .try_into() - .or_else(|_| self.error(ErrorKind::Overflow))?; - - let end = (self.position + len).or_else(|e| self.error(e.kind()))?; - let slice = self - .bytes - .get_mut(self.position.try_into()?..end.try_into()?) - .ok_or_else(|| ErrorKind::Overlength.at(end))?; - - self.position = end; - Ok(slice) - } -} - -impl<'a> Writer for SliceWriter<'a> { - fn write(&mut self, slice: &[u8]) -> Result<()> { - self.reserve(slice.len())?.copy_from_slice(slice); - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::SliceWriter; - use crate::{Encode, ErrorKind, Length}; - - #[test] - fn overlength_message() { - let mut buffer = []; - let mut writer = SliceWriter::new(&mut buffer); - let err = false.encode(&mut writer).err().unwrap(); - assert_eq!(err.kind(), ErrorKind::Overlength); - assert_eq!(err.position(), Some(Length::ONE)); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/datetime.proptest-regressions b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/datetime.proptest-regressions deleted file mode 100644 index f280ac46a541..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/datetime.proptest-regressions +++ /dev/null @@ -1,8 +0,0 @@ -# Seeds for failure cases proptest has generated in the past. It is -# automatically read and these particular cases re-run before any -# novel cases are generated. -# -# It is recommended to check this file in to source control so that -# everyone who runs the test benefits from these saved cases. -cc 00dbea7e90761c16aa20e2fbf7ffad420da0c84d4ed4e6df123de03c9b4567e5 # shrinks to year = 1970, month = 1, day = 1, hour = 0, min = 60, sec = 0 -cc 3b0bd01ef4cad6bea0a287f9cdcd56bad186125ec388d204f6afcd193ca12c39 # shrinks to year = 1970, month = 1, day = 1, hour = 0, min = 0, sec = 60 diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/datetime.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/datetime.rs deleted file mode 100644 index 454c1f0e480a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/datetime.rs +++ /dev/null @@ -1,64 +0,0 @@ -//! Tests for the [`DateTime`] type. - -use der::{asn1::UtcTime, DateTime, Decode, Encode}; -use proptest::prelude::*; - -proptest! { - #[test] - fn roundtrip_datetime( - year in 1970u16..=9999, - month in 1u8..=12, - day in 1u8..=31, - hour in 0u8..=23, - min in 0u8..=59, - sec in 0u8..=59, - ) { - let datetime1 = make_datetime(year, month, day, hour, min, sec); - let datetime2 = DateTime::from_unix_duration(datetime1.unix_duration()).unwrap(); - prop_assert_eq!(datetime1, datetime2); - } - - #[test] - fn roundtrip_utctime( - year in 1970u16..=2049, - month in 1u8..=12, - day in 1u8..=31, - hour in 0u8..=23, - min in 0u8..=59, - sec in 0u8..=59, - ) { - let datetime = make_datetime(year, month, day, hour, min, sec); - let utc_time1 = UtcTime::try_from(datetime).unwrap(); - - let mut buf = [0u8; 128]; - let mut encoder = der::SliceWriter::new(&mut buf); - utc_time1.encode(&mut encoder).unwrap(); - let der_bytes = encoder.finish().unwrap(); - - let utc_time2 = UtcTime::from_der(der_bytes).unwrap(); - prop_assert_eq!(utc_time1, utc_time2); - } -} - -fn make_datetime(year: u16, month: u8, day: u8, hour: u8, min: u8, sec: u8) -> DateTime { - let max_day = if month == 2 { - let is_leap_year = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); - - if is_leap_year { - 29 - } else { - 28 - } - } else { - 30 - }; - - let day = if day > max_day { max_day } else { day }; - - DateTime::new(year, month, day, hour, min, sec).unwrap_or_else(|e| { - panic!( - "invalid DateTime: {:02}-{:02}-{:02}T{:02}:{:02}:{:02}: {}", - year, month, day, hour, min, sec, e - ); - }) -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/derive.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/derive.rs deleted file mode 100644 index a8c77febc296..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/derive.rs +++ /dev/null @@ -1,461 +0,0 @@ -//! Tests for custom derive support. -//! -//! # Debugging with `cargo expand` -//! -//! To expand the Rust code generated by the proc macro when debugging -//! issues related to these tests, run: -//! -//! $ cargo expand --test derive --all-features - -#![cfg(all(feature = "derive", feature = "alloc"))] - -/// Custom derive test cases for the `Choice` macro. -mod choice { - /// `Choice` with `EXPLICIT` tagging. - mod explicit { - use der::{ - asn1::{GeneralizedTime, UtcTime}, - Choice, Decode, Encode, SliceWriter, - }; - use hex_literal::hex; - use std::time::Duration; - - /// Custom derive test case for the `Choice` macro. - /// - /// Based on `Time` as defined in RFC 5280: - /// - /// - /// ```text - /// Time ::= CHOICE { - /// utcTime UTCTime, - /// generalTime GeneralizedTime } - /// ``` - #[derive(Choice)] - pub enum Time { - #[asn1(type = "UTCTime")] - UtcTime(UtcTime), - - #[asn1(type = "GeneralizedTime")] - GeneralTime(GeneralizedTime), - } - - impl Time { - fn to_unix_duration(self) -> Duration { - match self { - Time::UtcTime(t) => t.to_unix_duration(), - Time::GeneralTime(t) => t.to_unix_duration(), - } - } - } - - const UTC_TIMESTAMP_DER: &[u8] = &hex!("17 0d 39 31 30 35 30 36 32 33 34 35 34 30 5a"); - const GENERAL_TIMESTAMP_DER: &[u8] = - &hex!("18 0f 31 39 39 31 30 35 30 36 32 33 34 35 34 30 5a"); - - #[test] - fn decode() { - let utc_time = Time::from_der(UTC_TIMESTAMP_DER).unwrap(); - assert_eq!(utc_time.to_unix_duration().as_secs(), 673573540); - - let general_time = Time::from_der(GENERAL_TIMESTAMP_DER).unwrap(); - assert_eq!(general_time.to_unix_duration().as_secs(), 673573540); - } - - #[test] - fn encode() { - let mut buf = [0u8; 128]; - - let utc_time = Time::from_der(UTC_TIMESTAMP_DER).unwrap(); - let mut encoder = SliceWriter::new(&mut buf); - utc_time.encode(&mut encoder).unwrap(); - assert_eq!(UTC_TIMESTAMP_DER, encoder.finish().unwrap()); - - let general_time = Time::from_der(GENERAL_TIMESTAMP_DER).unwrap(); - let mut encoder = SliceWriter::new(&mut buf); - general_time.encode(&mut encoder).unwrap(); - assert_eq!(GENERAL_TIMESTAMP_DER, encoder.finish().unwrap()); - } - } - - /// `Choice` with `IMPLICIT` tagging. - mod implicit { - use der::{ - asn1::{BitStringRef, GeneralizedTime}, - Choice, Decode, Encode, SliceWriter, - }; - use hex_literal::hex; - - /// `Choice` macro test case for `IMPLICIT` tagging. - #[derive(Choice, Debug, Eq, PartialEq)] - #[asn1(tag_mode = "IMPLICIT")] - pub enum ImplicitChoice<'a> { - #[asn1(context_specific = "0", type = "BIT STRING")] - BitString(BitStringRef<'a>), - - #[asn1(context_specific = "1", type = "GeneralizedTime")] - Time(GeneralizedTime), - - #[asn1(context_specific = "2", type = "UTF8String")] - Utf8String(String), - } - - impl<'a> ImplicitChoice<'a> { - pub fn bit_string(&self) -> Option> { - match self { - Self::BitString(bs) => Some(*bs), - _ => None, - } - } - - pub fn time(&self) -> Option { - match self { - Self::Time(time) => Some(*time), - _ => None, - } - } - } - - const BITSTRING_DER: &[u8] = &hex!("80 04 00 01 02 03"); - const TIME_DER: &[u8] = &hex!("81 0f 31 39 39 31 30 35 30 36 32 33 34 35 34 30 5a"); - - #[test] - fn decode() { - let cs_bit_string = ImplicitChoice::from_der(BITSTRING_DER).unwrap(); - assert_eq!( - cs_bit_string.bit_string().unwrap().as_bytes().unwrap(), - &[1, 2, 3] - ); - - let cs_time = ImplicitChoice::from_der(TIME_DER).unwrap(); - assert_eq!( - cs_time.time().unwrap().to_unix_duration().as_secs(), - 673573540 - ); - } - - #[test] - fn encode() { - let mut buf = [0u8; 128]; - - let cs_bit_string = ImplicitChoice::from_der(BITSTRING_DER).unwrap(); - let mut encoder = SliceWriter::new(&mut buf); - cs_bit_string.encode(&mut encoder).unwrap(); - assert_eq!(BITSTRING_DER, encoder.finish().unwrap()); - - let cs_time = ImplicitChoice::from_der(TIME_DER).unwrap(); - let mut encoder = SliceWriter::new(&mut buf); - cs_time.encode(&mut encoder).unwrap(); - assert_eq!(TIME_DER, encoder.finish().unwrap()); - } - } -} - -/// Custom derive test cases for the `Enumerated` macro. -mod enumerated { - use der::{Decode, Encode, Enumerated, SliceWriter}; - use hex_literal::hex; - - /// X.509 `CRLReason`. - #[derive(Enumerated, Copy, Clone, Debug, Eq, PartialEq)] - #[repr(u32)] - pub enum CrlReason { - Unspecified = 0, - KeyCompromise = 1, - CaCompromise = 2, - AffiliationChanged = 3, - Superseded = 4, - CessationOfOperation = 5, - CertificateHold = 6, - RemoveFromCrl = 8, - PrivilegeWithdrawn = 9, - AaCompromised = 10, - } - - const UNSPECIFIED_DER: &[u8] = &hex!("0a 01 00"); - const KEY_COMPROMISE_DER: &[u8] = &hex!("0a 01 01"); - - #[test] - fn decode() { - let unspecified = CrlReason::from_der(UNSPECIFIED_DER).unwrap(); - assert_eq!(CrlReason::Unspecified, unspecified); - - let key_compromise = CrlReason::from_der(KEY_COMPROMISE_DER).unwrap(); - assert_eq!(CrlReason::KeyCompromise, key_compromise); - } - - #[test] - fn encode() { - let mut buf = [0u8; 128]; - - let mut encoder = SliceWriter::new(&mut buf); - CrlReason::Unspecified.encode(&mut encoder).unwrap(); - assert_eq!(UNSPECIFIED_DER, encoder.finish().unwrap()); - - let mut encoder = SliceWriter::new(&mut buf); - CrlReason::KeyCompromise.encode(&mut encoder).unwrap(); - assert_eq!(KEY_COMPROMISE_DER, encoder.finish().unwrap()); - } -} - -/// Custom derive test cases for the `Sequence` macro. -#[cfg(feature = "oid")] -mod sequence { - use core::marker::PhantomData; - use der::{ - asn1::{AnyRef, ObjectIdentifier, SetOf}, - Decode, Encode, Sequence, ValueOrd, - }; - use hex_literal::hex; - - pub fn default_false_example() -> bool { - false - } - - // Issuing distribution point extension as defined in [RFC 5280 Section 5.2.5] and as identified by the [`PKIX_PE_SUBJECTINFOACCESS`](constant.PKIX_PE_SUBJECTINFOACCESS.html) OID. - // - // ```text - // IssuingDistributionPoint ::= SEQUENCE { - // distributionPoint [0] DistributionPointName OPTIONAL, - // onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE, - // onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE, - // onlySomeReasons [3] ReasonFlags OPTIONAL, - // indirectCRL [4] BOOLEAN DEFAULT FALSE, - // onlyContainsAttributeCerts [5] BOOLEAN DEFAULT FALSE } - // -- at most one of onlyContainsUserCerts, onlyContainsCACerts, - // -- and onlyContainsAttributeCerts may be set to TRUE. - // ``` - // - // [RFC 5280 Section 5.2.5]: https://datatracker.ietf.org/doc/html/rfc5280#section-5.2.5 - #[derive(Sequence)] - pub struct IssuingDistributionPointExample { - // Omit distributionPoint and only_some_reasons because corresponding structs are not - // available here and are not germane to the example - // distributionPoint [0] DistributionPointName OPTIONAL, - //#[asn1(context_specific="0", optional="true", tag_mode="IMPLICIT")] - //pub distribution_point: Option>, - /// onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE, - #[asn1( - context_specific = "1", - default = "default_false_example", - tag_mode = "IMPLICIT" - )] - pub only_contains_user_certs: bool, - - /// onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE, - #[asn1( - context_specific = "2", - default = "default_false_example", - tag_mode = "IMPLICIT" - )] - pub only_contains_cacerts: bool, - - // onlySomeReasons [3] ReasonFlags OPTIONAL, - //#[asn1(context_specific="3", optional="true", tag_mode="IMPLICIT")] - //pub only_some_reasons: Option>, - /// indirectCRL [4] BOOLEAN DEFAULT FALSE, - #[asn1( - context_specific = "4", - default = "default_false_example", - tag_mode = "IMPLICIT" - )] - pub indirect_crl: bool, - - /// onlyContainsAttributeCerts [5] BOOLEAN DEFAULT FALSE - #[asn1( - context_specific = "5", - default = "default_false_example", - tag_mode = "IMPLICIT" - )] - pub only_contains_attribute_certs: bool, - - /// Test handling of PhantomData. - pub phantom: PhantomData<()>, - } - - // Extension as defined in [RFC 5280 Section 4.1.2.9]. - // - // The ASN.1 definition for Extension objects is below. The extnValue type may be further parsed using a decoder corresponding to the extnID value. - // - // ```text - // Extension ::= SEQUENCE { - // extnID OBJECT IDENTIFIER, - // critical BOOLEAN DEFAULT FALSE, - // extnValue OCTET STRING - // -- contains the DER encoding of an ASN.1 value - // -- corresponding to the extension type identified - // -- by extnID - // } - // ``` - // - // [RFC 5280 Section 4.1.2.9]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.9 - #[derive(Clone, Debug, Eq, PartialEq, Sequence)] - pub struct ExtensionExample<'a> { - /// extnID OBJECT IDENTIFIER, - pub extn_id: ObjectIdentifier, - - /// critical BOOLEAN DEFAULT FALSE, - #[asn1(default = "default_false_example")] - pub critical: bool, - - /// extnValue OCTET STRING - #[asn1(type = "OCTET STRING")] - pub extn_value: &'a [u8], - } - - /// X.509 `AlgorithmIdentifier` - #[derive(Copy, Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)] - pub struct AlgorithmIdentifier<'a> { - pub algorithm: ObjectIdentifier, - pub parameters: Option>, - } - - /// X.509 `SubjectPublicKeyInfo` (SPKI) - #[derive(Copy, Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)] - pub struct SubjectPublicKeyInfo<'a> { - pub algorithm: AlgorithmIdentifier<'a>, - #[asn1(type = "BIT STRING")] - pub subject_public_key: &'a [u8], - } - - /// PKCS#8v2 `OneAsymmetricKey` - #[derive(Sequence)] - pub struct OneAsymmetricKey<'a> { - pub version: u8, - pub private_key_algorithm: AlgorithmIdentifier<'a>, - #[asn1(type = "OCTET STRING")] - pub private_key: &'a [u8], - #[asn1(context_specific = "0", extensible = "true", optional = "true")] - pub attributes: Option, 1>>, - #[asn1( - context_specific = "1", - extensible = "true", - optional = "true", - type = "BIT STRING" - )] - pub public_key: Option<&'a [u8]>, - } - - /// X.509 extension - // TODO(tarcieri): tests for code derived with the `default` attribute - #[derive(Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)] - pub struct Extension<'a> { - extn_id: ObjectIdentifier, - #[asn1(default = "critical_default")] - critical: bool, - #[asn1(type = "OCTET STRING")] - extn_value: &'a [u8], - } - - /// Default value of the `critical` bit - fn critical_default() -> bool { - false - } - - const ID_EC_PUBLIC_KEY_OID: ObjectIdentifier = - ObjectIdentifier::new_unwrap("1.2.840.10045.2.1"); - - const PRIME256V1_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.10045.3.1.7"); - - const ALGORITHM_IDENTIFIER_DER: &[u8] = - &hex!("30 13 06 07 2a 86 48 ce 3d 02 01 06 08 2a 86 48 ce 3d 03 01 07"); - - #[derive(Sequence)] - #[asn1(tag_mode = "IMPLICIT")] - pub struct TypeCheckExpandedSequenceFieldAttributeCombinations<'a> { - pub simple: bool, - #[asn1(type = "BIT STRING")] - pub typed: &'a [u8], - #[asn1(context_specific = "0")] - pub context_specific: bool, - #[asn1(optional = "true")] - pub optional: Option, - #[asn1(default = "default_false_example")] - pub default: bool, - #[asn1(type = "BIT STRING", context_specific = "1")] - pub typed_context_specific: &'a [u8], - #[asn1(context_specific = "2", optional = "true")] - pub context_specific_optional: Option, - #[asn1(context_specific = "3", default = "default_false_example")] - pub context_specific_default: bool, - #[asn1(type = "BIT STRING", context_specific = "4", optional = "true")] - pub typed_context_specific_optional: Option<&'a [u8]>, - } - - #[test] - fn idp_test() { - let idp = IssuingDistributionPointExample::from_der(&hex!("30038101FF")).unwrap(); - assert_eq!(idp.only_contains_user_certs, true); - assert_eq!(idp.only_contains_cacerts, false); - assert_eq!(idp.indirect_crl, false); - assert_eq!(idp.only_contains_attribute_certs, false); - - let idp = IssuingDistributionPointExample::from_der(&hex!("30038201FF")).unwrap(); - assert_eq!(idp.only_contains_user_certs, false); - assert_eq!(idp.only_contains_cacerts, true); - assert_eq!(idp.indirect_crl, false); - assert_eq!(idp.only_contains_attribute_certs, false); - - let idp = IssuingDistributionPointExample::from_der(&hex!("30038401FF")).unwrap(); - assert_eq!(idp.only_contains_user_certs, false); - assert_eq!(idp.only_contains_cacerts, false); - assert_eq!(idp.indirect_crl, true); - assert_eq!(idp.only_contains_attribute_certs, false); - - let idp = IssuingDistributionPointExample::from_der(&hex!("30038501FF")).unwrap(); - assert_eq!(idp.only_contains_user_certs, false); - assert_eq!(idp.only_contains_cacerts, false); - assert_eq!(idp.indirect_crl, false); - assert_eq!(idp.only_contains_attribute_certs, true); - } - - // demonstrates default field that is not context specific - #[test] - fn extension_test() { - let ext1 = ExtensionExample::from_der(&hex!( - "300F" // 0 15: SEQUENCE { - "0603551D13" // 2 3: OBJECT IDENTIFIER basicConstraints (2 5 29 19) - "0101FF" // 7 1: BOOLEAN TRUE - "0405" // 10 5: OCTET STRING, encapsulates { - "3003" // 12 3: SEQUENCE { - "0101FF" // 14 1: BOOLEAN TRUE - )) - .unwrap(); - assert_eq!(ext1.critical, true); - - let ext2 = ExtensionExample::from_der(&hex!( - "301F" // 0 31: SEQUENCE { - "0603551D23" // 2 3: OBJECT IDENTIFIER authorityKeyIdentifier (2 5 29 35) - "0418" // 7 24: OCTET STRING, encapsulates { - "3016" // 9 22: SEQUENCE { - "8014E47D5FD15C9586082C05AEBE75B665A7D95DA866" // 11 20: [0] E4 7D 5F D1 5C 95 86 08 2C 05 AE BE 75 B6 65 A7 D9 5D A8 66 - )) - .unwrap(); - assert_eq!(ext2.critical, false); - } - - #[test] - fn decode() { - let algorithm_identifier = AlgorithmIdentifier::from_der(ALGORITHM_IDENTIFIER_DER).unwrap(); - - assert_eq!(ID_EC_PUBLIC_KEY_OID, algorithm_identifier.algorithm); - assert_eq!( - PRIME256V1_OID, - ObjectIdentifier::try_from(algorithm_identifier.parameters.unwrap()).unwrap() - ); - } - - #[test] - fn encode() { - let parameters_oid = PRIME256V1_OID; - - let algorithm_identifier = AlgorithmIdentifier { - algorithm: ID_EC_PUBLIC_KEY_OID, - parameters: Some(AnyRef::from(¶meters_oid)), - }; - - assert_eq!( - ALGORITHM_IDENTIFIER_DER, - algorithm_identifier.to_der().unwrap() - ); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/examples/spki.der b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/examples/spki.der deleted file mode 100644 index 1b602ee1f2754f327636c7e58cbbf340dd7ca82b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44 zcmXreGGJw6)=n*8R%Gzi6sxzF6k7Iu?JrF$Rw>Z~amT9r#nq~1LIdu+2;R#J00n>! ARR910 diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/examples/spki.pem b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/examples/spki.pem deleted file mode 100644 index 6891701f7888..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/examples/spki.pem +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEATSkWfz8ZEqb3rfopOgUaFcBexnuPFyZ7HFVQ3OhTvQ0= ------END PUBLIC KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/pem.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/pem.rs deleted file mode 100644 index d2c8654638ef..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/pem.rs +++ /dev/null @@ -1,67 +0,0 @@ -//! PEM decoding and encoding tests. - -#![cfg(all(feature = "derive", feature = "oid", feature = "pem"))] - -use der::{ - asn1::{BitString, ObjectIdentifier}, - pem::{LineEnding, PemLabel}, - Decode, DecodePem, EncodePem, Sequence, -}; - -/// Example SPKI document encoded as DER. -const SPKI_DER: &[u8] = include_bytes!("examples/spki.der"); - -/// Example SPKI document encoded as PEM. -const SPKI_PEM: &str = include_str!("examples/spki.pem"); - -/// X.509 `AlgorithmIdentifier` -#[derive(Copy, Clone, Debug, Eq, PartialEq, Sequence)] -pub struct AlgorithmIdentifier { - pub algorithm: ObjectIdentifier, - // pub parameters: ... (not used in spki.pem) -} - -/// X.509 `SubjectPublicKeyInfo` (SPKI) in borrowed form -#[derive(Copy, Clone, Debug, Eq, PartialEq, Sequence)] -pub struct SpkiBorrowed<'a> { - pub algorithm: AlgorithmIdentifier, - #[asn1(type = "BIT STRING")] - pub subject_public_key: &'a [u8], -} - -impl PemLabel for SpkiBorrowed<'_> { - const PEM_LABEL: &'static str = "PUBLIC KEY"; -} - -/// X.509 `SubjectPublicKeyInfo` (SPKI) in owned form -#[derive(Clone, Debug, Eq, PartialEq, Sequence)] -pub struct SpkiOwned { - pub algorithm: AlgorithmIdentifier, - pub subject_public_key: BitString, -} - -impl PemLabel for SpkiOwned { - const PEM_LABEL: &'static str = "PUBLIC KEY"; -} - -#[test] -fn from_pem() { - // Decode PEM to owned form. - let pem_spki = SpkiOwned::from_pem(SPKI_PEM).unwrap(); - - // Decode DER to borrowed form. - let der_spki = SpkiBorrowed::from_der(SPKI_DER).unwrap(); - - assert_eq!(pem_spki.algorithm, der_spki.algorithm); - assert_eq!( - pem_spki.subject_public_key.raw_bytes(), - der_spki.subject_public_key - ); -} - -#[test] -fn to_pem() { - let spki = SpkiBorrowed::from_der(SPKI_DER).unwrap(); - let pem = spki.to_pem(LineEnding::LF).unwrap(); - assert_eq!(&pem, SPKI_PEM); -} diff --git a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/set_of.rs b/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/set_of.rs deleted file mode 100644 index d5839919886f..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/der-0.7.9/tests/set_of.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! `SetOf` tests. - -#![cfg(feature = "alloc")] - -use der::{asn1::SetOfVec, DerOrd}; -use proptest::{prelude::*, string::*}; -use std::collections::BTreeSet; - -proptest! { - #[test] - fn sort_equiv(bytes in bytes_regex(".{0,64}").unwrap()) { - let mut uniq = BTreeSet::new(); - - // Ensure there are no duplicates - if bytes.iter().copied().all(move |x| uniq.insert(x)) { - let mut expected = bytes.clone(); - expected.sort_by(|a, b| a.der_cmp(b).unwrap()); - - let set = SetOfVec::try_from(bytes).unwrap(); - prop_assert_eq!(expected.as_slice(), set.as_slice()); - } - } -} - -/// Set ordering tests. -#[cfg(all(feature = "derive", feature = "oid"))] -mod ordering { - use der::{ - asn1::{AnyRef, ObjectIdentifier, SetOf, SetOfVec}, - Decode, Sequence, ValueOrd, - }; - use hex_literal::hex; - - /// X.501 `AttributeTypeAndValue` - #[derive(Copy, Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)] - pub struct AttributeTypeAndValue<'a> { - pub oid: ObjectIdentifier, - pub value: AnyRef<'a>, - } - - const OUT_OF_ORDER_RDN_EXAMPLE: &[u8] = - &hex!("311F301106035504030C0A4A4F484E20534D495448300A060355040A0C03313233"); - - /// For compatibility reasons, we allow non-canonical DER with out-of-order - /// sets in order to match the behavior of other implementations. - #[test] - fn allow_out_of_order_setof() { - assert!(SetOf::, 2>::from_der(OUT_OF_ORDER_RDN_EXAMPLE).is_ok()); - } - - /// Same as above, with `SetOfVec` instead of `SetOf`. - #[test] - fn allow_out_of_order_setofvec() { - assert!(SetOfVec::>::from_der(OUT_OF_ORDER_RDN_EXAMPLE).is_ok()); - } - - /// Test to ensure ordering is handled correctly. - #[test] - fn ordering_regression() { - let der_bytes = hex!("3139301906035504030C12546573742055736572393031353734333830301C060A0992268993F22C640101130E3437303031303030303134373333"); - let set = SetOf::, 3>::from_der(&der_bytes).unwrap(); - let attr1 = set.get(0).unwrap(); - assert_eq!(ObjectIdentifier::new("2.5.4.3").unwrap(), attr1.oid); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.cargo_vcs_info.json deleted file mode 100644 index b14b7eaa35da..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "dec9b215770cc5d4445edc02b61586b29b4f3dfb" - }, - "path_in_vcs": "" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.github/workflows/audit.yml b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.github/workflows/audit.yml deleted file mode 100644 index abcbbff5ea5a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.github/workflows/audit.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Security audit -on: - push: - paths: - - '**/Cargo.toml' - - '**/Cargo.lock' - schedule: - - cron: '0 0 * * *' -jobs: - security_audit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.github/workflows/ci.yml b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.github/workflows/ci.yml deleted file mode 100644 index ced88fec08ab..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.github/workflows/ci.yml +++ /dev/null @@ -1,82 +0,0 @@ -on: [push, pull_request] - -name: Continuous integration - -jobs: - test: - name: Test Suite - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: test - - fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add clippy - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings - - no-std-check: - name: no_std Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-no-std-check - - run: cargo-no-std-check --no-default-features - env: - RUSTFLAGS: -D warnings - - doc: - name: Doc generation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: doc diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.gitignore b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.gitignore deleted file mode 100644 index 96ef6c0b944e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -Cargo.lock diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/Cargo.toml deleted file mode 100644 index 3acadce31cb5..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2018" -name = "derivation-path" -version = "0.2.0" -authors = ["Julian Popescu "] -description = "Simple struct for dealing with BIP32/44/49 derivation paths" -homepage = "https://github.com/jpopesculian/derivation-path" -documentation = "https://docs.rs/derivation-path/" -readme = "README.md" -keywords = [ - "derivation", - "BIP32", - "BIP44", - "BIP49", - "blockchain", -] -categories = [ - "cryptography", - "no-std", - "parsing", -] -license = "MIT OR Apache-2.0" -repository = "https://github.com/jpopesculian/derivation-path" - -[features] -default = ["std"] -std = [] diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/Cargo.toml.orig deleted file mode 100644 index acf93cd9865d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/Cargo.toml.orig +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "derivation-path" -version = "0.2.0" -authors = ["Julian Popescu "] -edition = "2018" -license = "MIT OR Apache-2.0" -readme = "README.md" -homepage = "https://github.com/jpopesculian/derivation-path" -documentation = "https://docs.rs/derivation-path/" -repository = "https://github.com/jpopesculian/derivation-path" -description = "Simple struct for dealing with BIP32/44/49 derivation paths" -keywords = ["derivation", "BIP32", "BIP44", "BIP49", "blockchain"] -categories = ["cryptography", "no-std", "parsing"] - -[features] -default = ["std"] -std = [] diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/README.md b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/README.md deleted file mode 100644 index 0dbed6e6525f..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# derivation-path - -A simple struct for dealing with derivation paths as defined by BIP32, BIP44 and BIP49 of the -Bitcoin protocol. This crate provides interfaces for dealing with hardened vs normal child -indexes, as well as display and parsing derivation paths from strings - -## Example - -```rust -let path = DerivationPath::bip44(0, 1, 0, 1).unwrap(); -assert_eq!(&path.to_string(), "m/44'/0'/1'/0/1"); -assert_eq!(path.path()[2], ChildIndex::Hardened(1)); - -let path: DerivationPath = "m/49'/0'/0'/1/0".parse().unwrap(); -assert_eq!(path.path()[4], ChildIndex::Normal(0)); -assert_eq!(path.path_type(), DerivationPathType::BIP49); -``` - -License: MIT OR Apache-2.0 diff --git a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/src/lib.rs deleted file mode 100644 index 5348d9d71202..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/src/lib.rs +++ /dev/null @@ -1,775 +0,0 @@ -//! A simple struct for dealing with derivation paths as defined by BIP32, BIP44 and BIP49 of the -//! Bitcoin protocol. This crate provides interfaces for dealing with hardened vs normal child -//! indexes, as well as display and parsing derivation paths from strings -//! -//! # Example -//! -//! ``` -//! # use derivation_path::{ChildIndex, DerivationPath, DerivationPathType}; -//! let path = DerivationPath::bip44(0, 1, 0, 1).unwrap(); -//! assert_eq!(&path.to_string(), "m/44'/0'/1'/0/1"); -//! assert_eq!(path.path()[2], ChildIndex::Hardened(1)); -//! -//! let path: DerivationPath = "m/49'/0'/0'/1/0".parse().unwrap(); -//! assert_eq!(path.path()[4], ChildIndex::Normal(0)); -//! assert_eq!(path.path_type(), DerivationPathType::BIP49); -//! ``` - -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(not(feature = "std"))] -extern crate alloc; - -#[cfg(not(feature = "std"))] -use alloc::{borrow::ToOwned, boxed::Box, string::String}; - -use core::fmt; -use core::iter::IntoIterator; -use core::slice::Iter; -use core::str::FromStr; - -/// Errors when building a [DerivationPath] -#[derive(Debug, Clone)] -pub enum DerivationPathError { - PathTooLong, - InvalidChildIndex(ChildIndexError), -} - -impl fmt::Display for DerivationPathError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::PathTooLong => f.write_str("path too long"), - Self::InvalidChildIndex(err) => { - f.write_fmt(format_args!("invalid child index: {}", err)) - } - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for DerivationPathError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - Self::InvalidChildIndex(err) => Some(err), - Self::PathTooLong => None, - } - } -} - -/// Errors when parsing a [DerivationPath] from a [str] -#[derive(Debug, Clone)] -pub enum DerivationPathParseError { - Empty, - InvalidPrefix(String), - InvalidChildIndex(ChildIndexParseError), -} - -impl fmt::Display for DerivationPathParseError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Empty => f.write_str("empty"), - Self::InvalidPrefix(prefix) => f.write_fmt(format_args!("invalid prefix: {}", prefix)), - Self::InvalidChildIndex(err) => { - f.write_fmt(format_args!("invalid child index: {}", err)) - } - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for DerivationPathParseError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - Self::InvalidChildIndex(err) => Some(err), - Self::Empty | Self::InvalidPrefix(_) => None, - } - } -} - -/// A list of [ChildIndex] items -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct DerivationPath(Box<[ChildIndex]>); - -/// [DerivationPath] specifications as defined by BIP's -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub enum DerivationPathType { - None, - BIP32, - BIP44, - BIP49, -} - -impl DerivationPath { - /// Build a [DerivationPath] from a list of [ChildIndex] items - #[inline] - pub fn new

(path: P) -> Self - where - P: Into>, - { - DerivationPath(path.into()) - } - - /// Build a BIP32 style [DerivationPath]. This will fail if the length of the path is greater - /// than 255 items - pub fn bip32

(path: P) -> Result - where - P: Into>, - { - let path = path.into(); - if path.len() > 255 { - return Err(DerivationPathError::PathTooLong); - } - Ok(Self::new(path)) - } - - /// Build a BIP44 style [DerivationPath]: `m/44'/coin'/account'/change/address` - #[inline] - pub fn bip44( - coin: u32, - account: u32, - change: u32, - address: u32, - ) -> Result { - Self::bip4x(44, coin, account, change, address) - } - - /// Build a BIP49 style [DerivationPath]: `m/49'/coin'/account'/change/address` - #[inline] - pub fn bip49( - coin: u32, - account: u32, - change: u32, - address: u32, - ) -> Result { - Self::bip4x(49, coin, account, change, address) - } - - #[inline] - fn bip4x( - purpose: u32, - coin: u32, - account: u32, - change: u32, - address: u32, - ) -> Result { - Ok(Self::new( - [ - ChildIndex::hardened(purpose)?, - ChildIndex::hardened(coin)?, - ChildIndex::hardened(account)?, - ChildIndex::normal(change)?, - ChildIndex::normal(address)?, - ] - .as_ref(), - )) - } - - /// Get a reference to the list of [ChildIndex] items - #[inline] - pub fn path(&self) -> &[ChildIndex] { - self.0.as_ref() - } - - /// Get the [DerivationPathType]. This will check the "purpose" index in BIP44/49 style - /// derivation paths or otherwise return BIP32 if the length is less than 255 - pub fn path_type(&self) -> DerivationPathType { - let path = self.path(); - let len = path.len(); - if len == 5 - && path[1].is_hardened() - && path[2].is_hardened() - && path[3].is_normal() - && path[4].is_normal() - { - match path[0] { - ChildIndex::Hardened(44) => DerivationPathType::BIP44, - ChildIndex::Hardened(49) => DerivationPathType::BIP49, - _ => DerivationPathType::BIP32, - } - } else if len < 256 { - DerivationPathType::BIP32 - } else { - DerivationPathType::None - } - } -} - -impl fmt::Display for DerivationPath { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str("m")?; - for index in self.path() { - f.write_str("/")?; - fmt::Display::fmt(index, f)?; - } - Ok(()) - } -} - -impl FromStr for DerivationPath { - type Err = DerivationPathParseError; - - fn from_str(s: &str) -> Result { - if s.is_empty() { - return Err(DerivationPathParseError::Empty); - } - let mut parts = s.split('/'); - match parts.next().unwrap() { - "m" => (), - prefix => return Err(DerivationPathParseError::InvalidPrefix(prefix.to_owned())), - } - let path = parts - .map(|part| ChildIndex::from_str(part).map_err(|e| e.into())) - .collect::, DerivationPathParseError>>()?; - Ok(DerivationPath::new(path)) - } -} - -impl AsRef<[ChildIndex]> for DerivationPath { - fn as_ref(&self) -> &[ChildIndex] { - self.path() - } -} - -impl<'a> IntoIterator for &'a DerivationPath { - type IntoIter = Iter<'a, ChildIndex>; - type Item = &'a ChildIndex; - fn into_iter(self) -> Self::IntoIter { - self.path().iter() - } -} - -/// An index in a [DerivationPath] -#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] -pub enum ChildIndex { - Normal(u32), - Hardened(u32), -} - -/// Errors when parsing a [ChildIndex] from a [str] -#[derive(Debug, Clone)] -pub enum ChildIndexParseError { - ParseIntError(core::num::ParseIntError), - ChildIndexError(ChildIndexError), -} - -impl fmt::Display for ChildIndexParseError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::ParseIntError(err) => { - f.write_fmt(format_args!("could not parse child index: {}", err)) - } - Self::ChildIndexError(err) => f.write_fmt(format_args!("invalid child index: {}", err)), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for ChildIndexParseError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - Self::ParseIntError(err) => Some(err), - Self::ChildIndexError(err) => Some(err), - } - } -} - -/// Errors when building a [ChildIndex] -#[derive(Debug, Clone)] -pub enum ChildIndexError { - NumberTooLarge(u32), -} - -impl fmt::Display for ChildIndexError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::NumberTooLarge(num) => f.write_fmt(format_args!("number too large: {}", num)), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for ChildIndexError {} - -impl ChildIndex { - /// Create a [ChildIndex::Hardened] instance from a [u32]. This will fail if `num` is not - /// in `[0, 2^31 - 1]` - pub fn hardened(num: u32) -> Result { - Ok(Self::Hardened(Self::check_size(num)?)) - } - - /// Create a [ChildIndex::Normal] instance from a [u32]. This will fail if `num` is not - /// in `[0, 2^31 - 1]` - pub fn normal(num: u32) -> Result { - Ok(Self::Normal(Self::check_size(num)?)) - } - - fn check_size(num: u32) -> Result { - if num & (1 << 31) == 0 { - Ok(num) - } else { - Err(ChildIndexError::NumberTooLarge(num)) - } - } - - /// Convert [ChildIndex] to its inner [u32] - #[inline] - pub fn to_u32(self) -> u32 { - match self { - ChildIndex::Hardened(index) => index, - ChildIndex::Normal(index) => index, - } - } - - /// Convert [ChildIndex] to a [u32] representing the type and a 31 bit number. The highest bit - /// is set for a hard derivation and clear for a normal derivation, and the remaining 31 bits are - /// the index - #[inline] - pub fn to_bits(self) -> u32 { - match self { - ChildIndex::Hardened(index) => (1 << 31) | index, - ChildIndex::Normal(index) => index, - } - } - - /// Build a [ChildIndex] from a [u32] representing the type and a 31 bit number. - /// See [ChildIndex::to_bits] for more information - #[inline] - pub fn from_bits(bits: u32) -> Self { - if bits & (1 << 31) == 0 { - ChildIndex::Normal(bits) - } else { - ChildIndex::Hardened(bits & !(1 << 31)) - } - } - - /// Check if the [ChildIndex] is "hardened" - #[inline] - pub fn is_hardened(self) -> bool { - matches!(self, Self::Hardened(_)) - } - - /// Check if the [ChildIndex] is "normal" - #[inline] - pub fn is_normal(self) -> bool { - matches!(self, Self::Normal(_)) - } -} - -impl fmt::Display for ChildIndex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(&self.to_u32(), f)?; - if self.is_hardened() { - f.write_str("'")?; - } - Ok(()) - } -} - -impl FromStr for ChildIndex { - type Err = ChildIndexParseError; - - fn from_str(s: &str) -> Result { - let mut chars = s.chars(); - Ok(match chars.next_back() { - Some('\'') => Self::hardened(u32::from_str(chars.as_str())?)?, - _ => Self::normal(u32::from_str(s)?)?, - }) - } -} - -impl From for ChildIndexParseError { - fn from(err: core::num::ParseIntError) -> Self { - Self::ParseIntError(err) - } -} - -impl From for ChildIndexParseError { - fn from(err: ChildIndexError) -> Self { - Self::ChildIndexError(err) - } -} - -impl From for DerivationPathParseError { - fn from(err: ChildIndexParseError) -> Self { - Self::InvalidChildIndex(err) - } -} - -impl From for DerivationPathError { - fn from(err: ChildIndexError) -> Self { - Self::InvalidChildIndex(err) - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[cfg(not(feature = "std"))] - use alloc::{string::ToString, vec}; - - #[test] - fn child_index_is_normal() { - assert!(ChildIndex::Hardened(0).is_hardened()); - assert!(!ChildIndex::Normal(0).is_hardened()); - } - - #[test] - fn child_index_is_hardened() { - assert!(!ChildIndex::Hardened(0).is_normal()); - assert!(ChildIndex::Normal(0).is_normal()); - } - - #[test] - fn child_index_range() { - assert!(ChildIndex::normal(0).is_ok()); - assert!(ChildIndex::normal(1).is_ok()); - assert!(ChildIndex::normal(100).is_ok()); - assert!(ChildIndex::normal(1 << 31).is_err()); - - assert!(ChildIndex::hardened(0).is_ok()); - assert!(ChildIndex::hardened(1 << 31).is_err()); - } - - #[test] - fn child_index_to_u32() { - assert_eq!(ChildIndex::Normal(0).to_u32(), 0); - assert_eq!(ChildIndex::Normal(1).to_u32(), 1); - assert_eq!(ChildIndex::Normal(100).to_u32(), 100); - assert_eq!(ChildIndex::Hardened(0).to_u32(), 0); - assert_eq!(ChildIndex::Hardened(1).to_u32(), 1); - } - - #[test] - fn child_index_to_bits() { - assert_eq!(ChildIndex::Normal(0).to_bits(), 0); - assert_eq!(ChildIndex::Normal(1).to_bits(), 1); - assert_eq!(ChildIndex::Normal(100).to_bits(), 100); - assert_eq!(ChildIndex::Hardened(0).to_bits(), (1 << 31) | 0); - assert_eq!(ChildIndex::Hardened(1).to_bits(), (1 << 31) | 1); - assert_eq!(ChildIndex::Hardened(100).to_bits(), (1 << 31) | 100); - } - - #[test] - fn child_index_from_bits() { - assert_eq!(ChildIndex::from_bits(0), ChildIndex::Normal(0)); - assert_eq!(ChildIndex::from_bits(1), ChildIndex::Normal(1)); - assert_eq!(ChildIndex::from_bits(100), ChildIndex::Normal(100)); - assert_eq!( - ChildIndex::from_bits((1 << 31) | 0), - ChildIndex::Hardened(0) - ); - assert_eq!( - ChildIndex::from_bits((1 << 31) | 1), - ChildIndex::Hardened(1) - ); - assert_eq!( - ChildIndex::from_bits((1 << 31) | 100), - ChildIndex::Hardened(100) - ); - } - - #[test] - fn child_index_to_string() { - assert_eq!(&ChildIndex::Normal(0).to_string(), "0"); - assert_eq!(&ChildIndex::Normal(1).to_string(), "1"); - assert_eq!(&ChildIndex::Normal(100).to_string(), "100"); - assert_eq!(&ChildIndex::Hardened(0).to_string(), "0'"); - assert_eq!(&ChildIndex::Hardened(1).to_string(), "1'"); - assert_eq!(&ChildIndex::Hardened(100).to_string(), "100'"); - } - - #[test] - fn child_index_from_str() { - assert_eq!(ChildIndex::Normal(0), "0".parse().unwrap()); - assert_eq!(ChildIndex::Normal(1), "1".parse().unwrap()); - assert_eq!(ChildIndex::Normal(100), "100".parse().unwrap()); - assert_eq!(ChildIndex::Hardened(0), "0'".parse().unwrap()); - assert_eq!(ChildIndex::Hardened(1), "1'".parse().unwrap()); - assert_eq!(ChildIndex::Hardened(100), "100'".parse().unwrap()); - assert!(matches!( - ChildIndex::from_str(""), - Err(ChildIndexParseError::ParseIntError(_)) - )); - assert!(matches!( - ChildIndex::from_str("a"), - Err(ChildIndexParseError::ParseIntError(_)) - )); - assert!(matches!( - ChildIndex::from_str("100 "), - Err(ChildIndexParseError::ParseIntError(_)) - )); - assert!(matches!( - ChildIndex::from_str("99a"), - Err(ChildIndexParseError::ParseIntError(_)) - )); - assert!(matches!( - ChildIndex::from_str("a10"), - Err(ChildIndexParseError::ParseIntError(_)) - )); - assert!(matches!( - ChildIndex::from_str(" 10"), - Err(ChildIndexParseError::ParseIntError(_)) - )); - assert!(matches!( - ChildIndex::from_str(&(1u32 << 31).to_string()), - Err(ChildIndexParseError::ChildIndexError(_)) - )); - } - - #[test] - fn derivation_path_new() { - let path = [ - ChildIndex::Normal(1), - ChildIndex::Hardened(2), - ChildIndex::Normal(3), - ]; - assert_eq!(&path, DerivationPath::new(path.as_ref()).path()); - - let path: [ChildIndex; 0] = []; - assert_eq!(&path, DerivationPath::new(path.as_ref()).path()); - - let path = vec![ChildIndex::Normal(0); 256]; - assert_eq!(path.as_slice(), DerivationPath::new(path.as_ref()).path()); - } - - #[test] - fn derivation_bip32() { - let path = [ - ChildIndex::Normal(1), - ChildIndex::Hardened(2), - ChildIndex::Normal(3), - ]; - assert_eq!(&path, DerivationPath::bip32(path.as_ref()).unwrap().path()); - - let path: [ChildIndex; 0] = []; - assert_eq!(&path, DerivationPath::bip32(path.as_ref()).unwrap().path()); - - let path = vec![ChildIndex::Normal(0); 256]; - assert!(matches!( - DerivationPath::bip32(path.as_ref()), - Err(DerivationPathError::PathTooLong) - )); - } - - #[test] - fn derivation_bip44() { - assert_eq!( - DerivationPath::bip44(1, 2, 3, 4).unwrap().path(), - &[ - ChildIndex::Hardened(44), - ChildIndex::Hardened(1), - ChildIndex::Hardened(2), - ChildIndex::Normal(3), - ChildIndex::Normal(4) - ] - ); - - assert!(matches!( - DerivationPath::bip44(1 << 31, 0, 0, 0), - Err(DerivationPathError::InvalidChildIndex(_)) - )); - } - - #[test] - fn derivation_bip49() { - assert_eq!( - DerivationPath::bip49(1, 2, 3, 4).unwrap().path(), - &[ - ChildIndex::Hardened(49), - ChildIndex::Hardened(1), - ChildIndex::Hardened(2), - ChildIndex::Normal(3), - ChildIndex::Normal(4) - ] - ); - - assert!(matches!( - DerivationPath::bip44(1 << 31, 0, 0, 0), - Err(DerivationPathError::InvalidChildIndex(_)) - )); - } - - #[test] - fn derivation_path_type() { - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Normal(0), - ChildIndex::Normal(0), - ChildIndex::Normal(0) - ]) - .path_type(), - DerivationPathType::BIP32 - ); - assert_eq!( - DerivationPath::new(vec![]).path_type(), - DerivationPathType::BIP32 - ); - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Hardened(44), - ChildIndex::Hardened(0), - ChildIndex::Hardened(0), - ChildIndex::Normal(0), - ChildIndex::Normal(0) - ]) - .path_type(), - DerivationPathType::BIP44 - ); - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Hardened(44), - ChildIndex::Hardened(0), - ChildIndex::Hardened(0), - ChildIndex::Normal(0), - ]) - .path_type(), - DerivationPathType::BIP32 - ); - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Hardened(43), - ChildIndex::Hardened(0), - ChildIndex::Hardened(0), - ChildIndex::Normal(0), - ChildIndex::Normal(0) - ]) - .path_type(), - DerivationPathType::BIP32 - ); - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Hardened(44), - ChildIndex::Hardened(0), - ChildIndex::Normal(0), - ChildIndex::Normal(0), - ChildIndex::Normal(0) - ]) - .path_type(), - DerivationPathType::BIP32 - ); - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Hardened(49), - ChildIndex::Hardened(0), - ChildIndex::Hardened(0), - ChildIndex::Normal(0), - ChildIndex::Normal(0) - ]) - .path_type(), - DerivationPathType::BIP49 - ); - assert_eq!( - DerivationPath::new(vec![ChildIndex::Normal(0); 256]).path_type(), - DerivationPathType::None - ); - } - - #[test] - fn derivation_path_to_string() { - assert_eq!( - &DerivationPath::new(vec![ - ChildIndex::Hardened(1), - ChildIndex::Hardened(2), - ChildIndex::Normal(3), - ChildIndex::Hardened(4) - ]) - .to_string(), - "m/1'/2'/3/4'" - ); - assert_eq!( - &DerivationPath::new(vec![ - ChildIndex::Hardened(1), - ChildIndex::Hardened(2), - ChildIndex::Hardened(4), - ChildIndex::Normal(3), - ]) - .to_string(), - "m/1'/2'/4'/3" - ); - assert_eq!( - &DerivationPath::new(vec![ - ChildIndex::Normal(100), - ChildIndex::Hardened(2), - ChildIndex::Hardened(4), - ChildIndex::Normal(3), - ]) - .to_string(), - "m/100/2'/4'/3" - ); - assert_eq!( - &DerivationPath::new(vec![ChildIndex::Normal(0),]).to_string(), - "m/0" - ); - assert_eq!(&DerivationPath::new(vec![]).to_string(), "m"); - } - - #[test] - fn derivation_path_parsing() { - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Hardened(1), - ChildIndex::Hardened(2), - ChildIndex::Normal(3), - ChildIndex::Hardened(4) - ]), - "m/1'/2'/3/4'".parse().unwrap() - ); - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Hardened(1), - ChildIndex::Hardened(2), - ChildIndex::Hardened(4), - ChildIndex::Normal(3), - ]), - "m/1'/2'/4'/3".parse().unwrap() - ); - assert_eq!( - DerivationPath::new(vec![ - ChildIndex::Normal(100), - ChildIndex::Hardened(2), - ChildIndex::Hardened(4), - ChildIndex::Normal(3), - ]), - "m/100/2'/4'/3".parse().unwrap() - ); - assert_eq!( - DerivationPath::new(vec![ChildIndex::Normal(0),]), - "m/0".parse().unwrap() - ); - assert_eq!(DerivationPath::new(vec![]), "m".parse().unwrap()); - - assert!(matches!( - DerivationPath::from_str(""), - Err(DerivationPathParseError::Empty) - )); - assert!(matches!( - DerivationPath::from_str("n/0"), - Err(DerivationPathParseError::InvalidPrefix(_)) - )); - assert!(matches!( - DerivationPath::from_str("mn/0"), - Err(DerivationPathParseError::InvalidPrefix(_)) - )); - assert!(matches!( - DerivationPath::from_str("m/0/"), - Err(DerivationPathParseError::InvalidChildIndex(_)) - )); - assert!(matches!( - DerivationPath::from_str("m/0/a/1"), - Err(DerivationPathParseError::InvalidChildIndex(_)) - )); - assert!(matches!( - DerivationPath::from_str("m/0///1"), - Err(DerivationPathParseError::InvalidChildIndex(_)) - )); - assert!(matches!( - DerivationPath::from_str(&format!("m/0/{}/1", (1u32 << 31))), - Err(DerivationPathParseError::InvalidChildIndex(_)) - )); - assert!(matches!( - DerivationPath::from_str("m|1"), - Err(DerivationPathParseError::InvalidPrefix(_)) - )); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/.cargo_vcs_info.json deleted file mode 100644 index 6d167d077d47..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "07b095c32a3527ee47da5c4878bf203557b36e5e" - }, - "path_in_vcs": "ed25519" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/CHANGELOG.md b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/CHANGELOG.md deleted file mode 100644 index 90d35b96bfa0..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/CHANGELOG.md +++ /dev/null @@ -1,249 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## 2.2.3 (2023-10-15) -### Changed -- Bump `ring-compat` from 0.7 to 0.8 ([#744]) -- Enable `pkcs8/std` feature when `std` feature is enabled ([#746]) -- Hex-format `Signature` components in `Debug` impl ([#747]) - -[#744]: https://github.com/RustCrypto/signatures/pull/744 -[#746]: https://github.com/RustCrypto/signatures/pull/746 -[#747]: https://github.com/RustCrypto/signatures/pull/747 - -## 2.2.2 (2023-08-13) -### Changed -- Bump `ed25519-dalek` to v2 ([#738]) - -[#738]: https://github.com/RustCrypto/signatures/pull/738 - -## 2.2.1 (2023-04-03) -### Changed -- Bump `ring-compat` dev-dependency to v0.7 ([#692]) -- Bump `ed25519-dalek` to v2.0.0-rc.2 ([#693]) - -[#692]: https://github.com/RustCrypto/signatures/pull/692 -[#693]: https://github.com/RustCrypto/signatures/pull/693 - -## 2.2.0 (2023-03-01) -### Changed -- Bump `pkcs8` dependency to v0.10 ([#665]) - -[#665]: https://github.com/RustCrypto/signatures/pull/665 - -## 2.1.0 (2023-01-21) -### Changed -- Use namespaced features for `serde_bytes`; MSRV 1.60 ([#628]) - -[#628]: https://github.com/RustCrypto/signatures/pull/628 - -## 2.0.1 (2023-01-21) -### Changed -- Make `Signature` parsing infallible ([#623]) - -[#623]: https://github.com/RustCrypto/signatures/pull/623 - -## 2.0.0 (2023-01-15) [YANKED] -### Added -- `pkcs8` re-exports ([#589], [#590], [#591], [#592]) -- `Signature::from_components` method ([#600]) -- Impl `TryFrom` for `Signature` ([#601]) - -### Changed -- Use `PublicKeyBytes` as `KeypairBytes::public_key` ([#570]) -- `Signature::from_bytes` takes `SignatureBytes` as an argument ([#593]) -- Store `R` and `s` components separately ([#595]) -- Bump `signature` crate dependency to v2.0 ([#614]) - -### Removed -- Deprecated `From<[u8; 64]>` conversion for signature ([#564]) -- `AsRef<[u8]>` impl on `signature` ([#595]) - -[#564]: https://github.com/RustCrypto/signatures/pull/564 -[#570]: https://github.com/RustCrypto/signatures/pull/570 -[#589]: https://github.com/RustCrypto/signatures/pull/589 -[#590]: https://github.com/RustCrypto/signatures/pull/590 -[#591]: https://github.com/RustCrypto/signatures/pull/591 -[#592]: https://github.com/RustCrypto/signatures/pull/592 -[#593]: https://github.com/RustCrypto/signatures/pull/593 -[#595]: https://github.com/RustCrypto/signatures/pull/595 -[#600]: https://github.com/RustCrypto/signatures/pull/600 -[#601]: https://github.com/RustCrypto/signatures/pull/601 -[#614]: https://github.com/RustCrypto/signatures/pull/614 - -## 1.5.3 (2023-01-15) -### Changed -- Fix `signature` version requirement which accidentally matched v2 or above ([#616]) - -[#616]: https://github.com/RustCrypto/signatures/pull/616 - -## 1.5.2 (2022-05-16) [YANKED] -### Fixed -- Overflow handling in `serde` deserializers ([#482]) - -[#482]: https://github.com/RustCrypto/signatures/pull/482 - -## 1.5.1 (2022-05-15) [YANKED] -### Fixed -- Use `TryInto` in `serde` deserializers ([#479]) - -[#479]: https://github.com/RustCrypto/signatures/pull/479 - -## 1.5.0 (2022-05-09) [YANKED] -### Changed -- Bump `pkcs8` dependency to v0.9 ([#473]) - -[#473]: https://github.com/RustCrypto/signatures/pull/473 - -## 1.4.1 (2022-03-18) [YANKED] -### Added -- License files ([#447]) -- `pkcs8::PublicKeyBytes` type ([#455]) - -[#447]: https://github.com/RustCrypto/signatures/pull/447 -[#455]: https://github.com/RustCrypto/signatures/pull/455 - -## 1.4.0 (2022-02-25) [YANKED] - -This crate now requires **Rust 1.56** at a minimum as the Rust edition has been -upgraded to 2021. - -Previous 1.x releases of this crate supported an MSRV of 1.47. If you would -like to use this crate with earlier releases of Rust, add the following version -constraint in your project's Cargo.toml to constrain it to the supported -version range: - -```toml -[dependencies] -ed25519 = ">=1, <1.4" # ed25519 1.4 requires MSRV 1.56 -``` - -Note that is our policy that we may change the MSRV in the future, but it will -be accompanied by a minor version bump. - -### Added -- `Signature::to_vec` ([#428]) - -### Changed -- Rust 2021 edition upgrade ([#412]) - -[#412]: https://github.com/RustCrypto/signatures/pull/412 -[#428]: https://github.com/RustCrypto/signatures/pull/428 - -## 1.3.0 (2021-11-18) [YANKED] -### Added -- `Signature::BYTE_SIZE` constant ([#380]) -- PKCS#8 support via `KeypairBytes` type ([#381]) -- `zeroize` feature ([#400]) -- Impl `Display`/`LowerHex`/`UpperHex`/`FromStr` for `Signature` ([#402]) - -### Changed -- Deprecate `SIGNATURE_LENGTH` constant in favor of `Signature::BYTE_SIZE` ([#380]) -- Deprecate `Signature::new` in favor of `Signature::from_bytes`/`TryFrom` ([#401]) -- `Signature::new` now panics on invalid signatures ([#403]) - -[#380]: https://github.com/RustCrypto/signatures/pull/380 -[#381]: https://github.com/RustCrypto/signatures/pull/381 -[#400]: https://github.com/RustCrypto/signatures/pull/400 -[#401]: https://github.com/RustCrypto/signatures/pull/401 -[#402]: https://github.com/RustCrypto/signatures/pull/402 -[#403]: https://github.com/RustCrypto/signatures/pull/403 - -## 1.2.0 (2021-07-21) -### Added -- `serde_bytes` optional dependency ([#337]) - -[#337]: https://github.com/RustCrypto/signatures/pull/337 - -## 1.1.1 (2021-04-30) -### Changed -- Updates for `ring-compat` v0.2.1 ([#291]) - -[#291]: https://github.com/RustCrypto/signatures/pull/291 - -## 1.1.0 (2021-04-30) -### Changed -- Bump `ring-compat` to v0.2; MSRV 1.47+ ([#289]) - -### Fixed -- Compile error in example ([#246]) - -[#246]: https://github.com/RustCrypto/signatures/pull/246 -[#289]: https://github.com/RustCrypto/signatures/pull/289 - -## 1.0.3 (2020-10-12) -### Added -- `ring-compat` usage example ([#187]) - -[#187]: https://github.com/RustCrypto/signatures/pull/187 - -## 1.0.2 (2020-09-11) -### Added -- `ed25519-dalek` usage example ([#167]) - -[#167]: https://github.com/RustCrypto/signatures/pull/167 - -## 1.0.1 (2020-04-20) -### Added -- Usage documentation ([#83]) - -[#83]: https://github.com/RustCrypto/signatures/pull/83 - -## 1.0.0 (2020-04-18) -### Changed -- Upgrade `signature` crate to v1.0 final release ([#80]) - -[#80]: https://github.com/RustCrypto/signatures/pull/80 - -## 1.0.0-pre.4 (2020-03-17) -### Changed -- Avoid serializing a length prefix with `serde` ([#78]) - -[#78]: https://github.com/RustCrypto/signatures/pull/78 - -## 1.0.0-pre.3 (2020-03-16) -### Changed -- Upgrade `signature` crate to v1.0.0-pre.3 ([#74]) -- Bump MSRV to 1.40 ([#75]) - -[#74]: https://github.com/RustCrypto/signatures/pull/74 -[#75]: https://github.com/RustCrypto/signatures/pull/75 - -## 1.0.0-pre.2 (2020-03-08) -### Changed -- Upgrade to `signature` crate v1.0.0-pre.3 ([#71]) -- Bump MSRV to 1.37 ([#63]) - -[#71]: https://github.com/RustCrypto/signatures/pull/71 -[#63]: https://github.com/RustCrypto/signatures/pull/63 - -## 1.0.0-pre.1 (2019-10-11) -### Added -- Optional `serde` support ([#40]) -- Add `TryFrom` impl for `Signature` ([#39]) - -### Changed -- Upgrade to `signature` 1.0.0-pre.1 ([#41]) - -[#41]: https://github.com/RustCrypto/signatures/pull/41 -[#40]: https://github.com/RustCrypto/signatures/pull/40 -[#39]: https://github.com/RustCrypto/signatures/pull/39 - -## 1.0.0-pre.0 (2019-10-11) -### Changed -- Upgrade to `signature` 1.0.0-pre.0 ([#34]) - -[#34]: https://github.com/RustCrypto/signatures/pull/34 - -## 0.2.0 (2019-10-10) -### Changed -- Upgrade to `signature` v0.3; MSRV 1.36+ ([#29]) - -[#29]: https://github.com/RustCrypto/signatures/pull/29 - -## 0.1.0 (2019-08-10) - -- Initial release diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/Cargo.toml deleted file mode 100644 index 04dc4434aded..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/Cargo.toml +++ /dev/null @@ -1,101 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -rust-version = "1.60" -name = "ed25519" -version = "2.2.3" -authors = ["RustCrypto Developers"] -description = """ -Edwards Digital Signature Algorithm (EdDSA) over Curve25519 (as specified in RFC 8032) -support library providing signature type definitions and PKCS#8 private key -decoding/encoding support -""" -documentation = "https://docs.rs/ed25519" -readme = "README.md" -keywords = [ - "crypto", - "curve25519", - "ecc", - "signature", - "signing", -] -categories = [ - "cryptography", - "no-std", -] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/signatures/tree/master/ed25519" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = [ - "--cfg", - "docsrs", -] - -[dependencies.pkcs8] -version = "0.10" -optional = true - -[dependencies.serde] -version = "1" -optional = true -default-features = false - -[dependencies.serde_bytes] -version = "0.11" -optional = true - -[dependencies.signature] -version = "2" -default-features = false - -[dependencies.zeroize] -version = "1" -optional = true -default-features = false - -[dev-dependencies.bincode] -version = "1" - -[dev-dependencies.ed25519-dalek] -version = "2" -features = ["rand_core"] - -[dev-dependencies.hex-literal] -version = "0.4" - -[dev-dependencies.rand_core] -version = "0.6" -features = ["std"] - -[dev-dependencies.ring-compat] -version = "0.8" -features = ["signature"] -default-features = false - -[features] -alloc = ["pkcs8?/alloc"] -default = ["std"] -pem = [ - "alloc", - "pkcs8/pem", -] -serde_bytes = [ - "serde", - "dep:serde_bytes", -] -std = [ - "pkcs8?/std", - "signature/std", -] diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/Cargo.toml.orig deleted file mode 100644 index 5595649025ff..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/Cargo.toml.orig +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "ed25519" -version = "2.2.3" -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" -description = """ -Edwards Digital Signature Algorithm (EdDSA) over Curve25519 (as specified in RFC 8032) -support library providing signature type definitions and PKCS#8 private key -decoding/encoding support -""" -documentation = "https://docs.rs/ed25519" -repository = "https://github.com/RustCrypto/signatures/tree/master/ed25519" -readme = "README.md" -categories = ["cryptography", "no-std"] -keywords = ["crypto", "curve25519", "ecc", "signature", "signing"] -edition = "2021" -rust-version = "1.60" - -[dependencies] -signature = { version = "2", default-features = false } - -# optional dependencies -pkcs8 = { version = "0.10", optional = true } -serde = { version = "1", optional = true, default-features = false } -serde_bytes = { version = "0.11", optional = true } -zeroize = { version = "1", optional = true, default-features = false } - -[dev-dependencies] -bincode = "1" -ed25519-dalek = { version = "2", features = ["rand_core"] } -hex-literal = "0.4" -ring-compat = { version = "0.8", default-features = false, features = ["signature"] } -rand_core = { version = "0.6", features = ["std"] } - -[features] -default = ["std"] -alloc = ["pkcs8?/alloc"] -pem = ["alloc", "pkcs8/pem"] -serde_bytes = ["serde", "dep:serde_bytes"] -std = ["pkcs8?/std", "signature/std"] - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-APACHE b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-APACHE deleted file mode 100644 index c394d8ad9fc9..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - 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 2018-2022 RustCrypto Developers - -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. diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-MIT b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-MIT deleted file mode 100644 index d8d87fe2997c..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2018-2023 RustCrypto Developers - -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. diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/README.md b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/README.md deleted file mode 100644 index de24ae2367f9..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/README.md +++ /dev/null @@ -1,81 +0,0 @@ -# [RustCrypto]: Ed25519 - -[![crate][crate-image]][crate-link] -[![Docs][docs-image]][docs-link] -[![Build Status][build-image]][build-link] -![Apache2/MIT licensed][license-image] -![Rust Version][rustc-image] -[![Project Chat][chat-image]][chat-link] - -[Edwards Digital Signature Algorithm (EdDSA)][1] over Curve25519 as specified -in [RFC 8032][2]. - -[Documentation][docs-link] - -## About - -This crate doesn't contain an implementation of Ed25519, but instead -contains an [`ed25519::Signature`][3] type which other crates can use in -conjunction with the [`signature::Signer`][4] and [`signature::Verifier`][5] -traits. - -These traits allow crates which produce and consume Ed25519 signatures -to be written abstractly in such a way that different signer/verifier -providers can be plugged in, enabling support for using different -Ed25519 implementations, including HSMs or Cloud KMS services. - -## Minimum Supported Rust Version - -This crate requires **Rust 1.60** at a minimum. - -Our policy is to allow MSRV to be raised in future released without that -qualifing as a SemVer-breaking change, but it will be accompanied by a minor -version bump, ensuring if you lock to a minor version MSRV will be preserved -for the default feature set. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above -- The `pkcs8` module is exempted as it uses a pre-1.0 dependency, however, - breaking changes to this module will be accompanied by a minor version bump. - -## License - -All crates licensed under either of - - * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) - * [MIT license](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. - -[//]: # (badges) - -[crate-image]: https://buildstats.info/crate/ed25519 -[crate-link]: https://crates.io/crates/ed25519 -[docs-image]: https://docs.rs/ed25519/badge.svg -[docs-link]: https://docs.rs/ed25519/ -[build-image]: https://github.com/RustCrypto/signatures/actions/workflows/ed25519.yml/badge.svg -[build-link]: https://github.com/RustCrypto/signatures/actions/workflows/ed25519.yml -[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.60+-blue.svg -[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg -[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures - -[//]: # (links) - -[RustCrypto]: https://github.com/RustCrypto - -[//]: # (footnotes) - -[1]: https://en.wikipedia.org/wiki/EdDSA#Ed25519 -[2]: https://tools.ietf.org/html/rfc8032 -[3]: https://docs.rs/ed25519/latest/ed25519/struct.Signature.html -[4]: https://docs.rs/signature/latest/signature/trait.Signer.html -[5]: https://docs.rs/signature/latest/signature/trait.Verifier.html diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/hex.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/hex.rs deleted file mode 100644 index 4052286c098d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/hex.rs +++ /dev/null @@ -1,87 +0,0 @@ -//! Hexadecimal encoding support -// TODO(tarcieri): use `base16ct`? - -use crate::{ComponentBytes, Error, Signature}; -use core::{fmt, str}; - -/// Format a signature component as hex. -pub(crate) struct ComponentFormatter<'a>(pub(crate) &'a ComponentBytes); - -impl fmt::Debug for ComponentFormatter<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "0x")?; - - for byte in self.0 { - write!(f, "{:02x}", byte)?; - } - - Ok(()) - } -} - -impl fmt::LowerHex for Signature { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - for component in [&self.R, &self.s] { - for byte in component { - write!(f, "{:02x}", byte)?; - } - } - Ok(()) - } -} - -impl fmt::UpperHex for Signature { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - for component in [&self.R, &self.s] { - for byte in component { - write!(f, "{:02X}", byte)?; - } - } - Ok(()) - } -} - -/// Decode a signature from hexadecimal. -/// -/// Upper and lower case hexadecimal are both accepted, however mixed case is -/// rejected. -// TODO(tarcieri): use `base16ct`? -impl str::FromStr for Signature { - type Err = Error; - - fn from_str(hex: &str) -> signature::Result { - if hex.as_bytes().len() != Signature::BYTE_SIZE * 2 { - return Err(Error::new()); - } - - let mut upper_case = None; - - // Ensure all characters are valid and case is not mixed - for &byte in hex.as_bytes() { - match byte { - b'0'..=b'9' => (), - b'a'..=b'z' => match upper_case { - Some(true) => return Err(Error::new()), - Some(false) => (), - None => upper_case = Some(false), - }, - b'A'..=b'Z' => match upper_case { - Some(true) => (), - Some(false) => return Err(Error::new()), - None => upper_case = Some(true), - }, - _ => return Err(Error::new()), - } - } - - let mut result = [0u8; Self::BYTE_SIZE]; - for (digit, byte) in hex.as_bytes().chunks_exact(2).zip(result.iter_mut()) { - *byte = str::from_utf8(digit) - .ok() - .and_then(|s| u8::from_str_radix(s, 16).ok()) - .ok_or_else(Error::new)?; - } - - Self::try_from(&result[..]) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/lib.rs deleted file mode 100644 index 2e8cb45b408e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/lib.rs +++ /dev/null @@ -1,419 +0,0 @@ -#![no_std] -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![doc = include_str!("../README.md")] -#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")] -#![allow(non_snake_case)] -#![forbid(unsafe_code)] -#![warn( - clippy::unwrap_used, - missing_docs, - rust_2018_idioms, - unused_lifetimes, - unused_qualifications -)] - -//! # Using Ed25519 generically over algorithm implementations/providers -//! -//! By using the `ed25519` crate, you can write code which signs and verifies -//! messages using the Ed25519 signature algorithm generically over any -//! supported Ed25519 implementation (see the next section for available -//! providers). -//! -//! This allows consumers of your code to plug in whatever implementation they -//! want to use without having to add all potential Ed25519 libraries you'd -//! like to support as optional dependencies. -//! -//! ## Example -//! -//! ``` -//! use ed25519::signature::{Signer, Verifier}; -//! -//! pub struct HelloSigner -//! where -//! S: Signer -//! { -//! pub signing_key: S -//! } -//! -//! impl HelloSigner -//! where -//! S: Signer -//! { -//! pub fn sign(&self, person: &str) -> ed25519::Signature { -//! // NOTE: use `try_sign` if you'd like to be able to handle -//! // errors from external signing services/devices (e.g. HSM/KMS) -//! // -//! self.signing_key.sign(format_message(person).as_bytes()) -//! } -//! } -//! -//! pub struct HelloVerifier { -//! pub verifying_key: V -//! } -//! -//! impl HelloVerifier -//! where -//! V: Verifier -//! { -//! pub fn verify( -//! &self, -//! person: &str, -//! signature: &ed25519::Signature -//! ) -> Result<(), ed25519::Error> { -//! self.verifying_key.verify(format_message(person).as_bytes(), signature) -//! } -//! } -//! -//! fn format_message(person: &str) -> String { -//! format!("Hello, {}!", person) -//! } -//! ``` -//! -//! ## Using above example with `ed25519-dalek` -//! -//! The [`ed25519-dalek`] crate natively supports the [`ed25519::Signature`][`Signature`] -//! type defined in this crate along with the [`signature::Signer`] and -//! [`signature::Verifier`] traits. -//! -//! Below is an example of how a hypothetical consumer of the code above can -//! instantiate and use the previously defined `HelloSigner` and `HelloVerifier` -//! types with [`ed25519-dalek`] as the signing/verification provider: -//! -//! *NOTE: requires [`ed25519-dalek`] v2 or newer for compatibility with -//! `ed25519` v2.2+*. -//! -//! ``` -//! use ed25519_dalek::{Signer, Verifier, Signature}; -//! # -//! # pub struct HelloSigner -//! # where -//! # S: Signer -//! # { -//! # pub signing_key: S -//! # } -//! # -//! # impl HelloSigner -//! # where -//! # S: Signer -//! # { -//! # pub fn sign(&self, person: &str) -> Signature { -//! # // NOTE: use `try_sign` if you'd like to be able to handle -//! # // errors from external signing services/devices (e.g. HSM/KMS) -//! # // -//! # self.signing_key.sign(format_message(person).as_bytes()) -//! # } -//! # } -//! # -//! # pub struct HelloVerifier { -//! # pub verifying_key: V -//! # } -//! # -//! # impl HelloVerifier -//! # where -//! # V: Verifier -//! # { -//! # pub fn verify( -//! # &self, -//! # person: &str, -//! # signature: &Signature -//! # ) -> Result<(), ed25519::Error> { -//! # self.verifying_key.verify(format_message(person).as_bytes(), signature) -//! # } -//! # } -//! # -//! # fn format_message(person: &str) -> String { -//! # format!("Hello, {}!", person) -//! # } -//! use rand_core::OsRng; // Requires the `std` feature of `rand_core` -//! -//! /// `HelloSigner` defined above instantiated with `ed25519-dalek` as -//! /// the signing provider. -//! pub type DalekHelloSigner = HelloSigner; -//! -//! let signing_key = ed25519_dalek::SigningKey::generate(&mut OsRng); -//! let signer = DalekHelloSigner { signing_key }; -//! let person = "Joe"; // Message to sign -//! let signature = signer.sign(person); -//! -//! /// `HelloVerifier` defined above instantiated with `ed25519-dalek` -//! /// as the signature verification provider. -//! pub type DalekHelloVerifier = HelloVerifier; -//! -//! let verifying_key: ed25519_dalek::VerifyingKey = signer.signing_key.verifying_key(); -//! let verifier = DalekHelloVerifier { verifying_key }; -//! assert!(verifier.verify(person, &signature).is_ok()); -//! ``` -//! -//! ## Using above example with `ring-compat` -//! -//! The [`ring-compat`] crate provides wrappers for [*ring*] which implement -//! the [`signature::Signer`] and [`signature::Verifier`] traits for -//! [`ed25519::Signature`][`Signature`]. -//! -//! Below is an example of how a hypothetical consumer of the code above can -//! instantiate and use the previously defined `HelloSigner` and `HelloVerifier` -//! types with [`ring-compat`] as the signing/verification provider: -//! -//! ``` -//! use ring_compat::signature::{ -//! ed25519::{Signature, SigningKey, VerifyingKey}, -//! Signer, Verifier -//! }; -//! # -//! # pub struct HelloSigner -//! # where -//! # S: Signer -//! # { -//! # pub signing_key: S -//! # } -//! # -//! # impl HelloSigner -//! # where -//! # S: Signer -//! # { -//! # pub fn sign(&self, person: &str) -> Signature { -//! # // NOTE: use `try_sign` if you'd like to be able to handle -//! # // errors from external signing services/devices (e.g. HSM/KMS) -//! # // -//! # self.signing_key.sign(format_message(person).as_bytes()) -//! # } -//! # } -//! # -//! # pub struct HelloVerifier { -//! # pub verifying_key: V -//! # } -//! # -//! # impl HelloVerifier -//! # where -//! # V: Verifier -//! # { -//! # pub fn verify( -//! # &self, -//! # person: &str, -//! # signature: &Signature -//! # ) -> Result<(), ed25519::Error> { -//! # self.verifying_key.verify(format_message(person).as_bytes(), signature) -//! # } -//! # } -//! # -//! # fn format_message(person: &str) -> String { -//! # format!("Hello, {}!", person) -//! # } -//! use rand_core::{OsRng, RngCore}; // Requires the `std` feature of `rand_core` -//! -//! /// `HelloSigner` defined above instantiated with *ring* as -//! /// the signing provider. -//! pub type RingHelloSigner = HelloSigner; -//! -//! let mut ed25519_seed = [0u8; 32]; -//! OsRng.fill_bytes(&mut ed25519_seed); -//! -//! let signing_key = SigningKey::from_bytes(&ed25519_seed); -//! let verifying_key = signing_key.verifying_key(); -//! -//! let signer = RingHelloSigner { signing_key }; -//! let person = "Joe"; // Message to sign -//! let signature = signer.sign(person); -//! -//! /// `HelloVerifier` defined above instantiated with *ring* -//! /// as the signature verification provider. -//! pub type RingHelloVerifier = HelloVerifier; -//! -//! let verifier = RingHelloVerifier { verifying_key }; -//! assert!(verifier.verify(person, &signature).is_ok()); -//! ``` -//! -//! # Available Ed25519 providers -//! -//! The following libraries support the types/traits from the `ed25519` crate: -//! -//! - [`ed25519-dalek`] - mature pure Rust implementation of Ed25519 -//! - [`ring-compat`] - compatibility wrapper for [*ring*] -//! - [`yubihsm`] - host-side client library for YubiHSM2 devices from Yubico -//! -//! [`ed25519-dalek`]: https://docs.rs/ed25519-dalek -//! [`ring-compat`]: https://docs.rs/ring-compat -//! [*ring*]: https://github.com/briansmith/ring -//! [`yubihsm`]: https://github.com/iqlusioninc/yubihsm.rs/blob/develop/README.md -//! -//! # Features -//! -//! The following features are presently supported: -//! -//! - `pkcs8`: support for decoding/encoding PKCS#8-formatted private keys using the -//! [`KeypairBytes`] type. -//! - `std` *(default)*: Enable `std` support in [`signature`], which currently only affects whether -//! [`signature::Error`] implements `std::error::Error`. -//! - `serde`: Implement `serde::Deserialize` and `serde::Serialize` for [`Signature`]. Signatures -//! are serialized as their bytes. -//! - `serde_bytes`: Implement `serde_bytes::Deserialize` and `serde_bytes::Serialize` for -//! [`Signature`]. This enables more compact representations for formats with an efficient byte -//! array representation. As per the `serde_bytes` documentation, this can most easily be realised -//! using the `#[serde(with = "serde_bytes")]` annotation, e.g.: -//! -//! ```ignore -//! # use ed25519::Signature; -//! # use serde::{Deserialize, Serialize}; -//! #[derive(Deserialize, Serialize)] -//! #[serde(transparent)] -//! struct SignatureAsBytes(#[serde(with = "serde_bytes")] Signature); -//! ``` - -#[cfg(feature = "alloc")] -extern crate alloc; - -mod hex; - -#[cfg(feature = "pkcs8")] -pub mod pkcs8; - -#[cfg(feature = "serde")] -mod serde; - -pub use signature::{self, Error, SignatureEncoding}; - -#[cfg(feature = "pkcs8")] -pub use crate::pkcs8::{KeypairBytes, PublicKeyBytes}; - -use core::fmt; - -#[cfg(feature = "alloc")] -use alloc::vec::Vec; - -/// Size of a single component of an Ed25519 signature. -const COMPONENT_SIZE: usize = 32; - -/// Size of an `R` or `s` component of an Ed25519 signature when serialized -/// as bytes. -pub type ComponentBytes = [u8; COMPONENT_SIZE]; - -/// Ed25519 signature serialized as a byte array. -pub type SignatureBytes = [u8; Signature::BYTE_SIZE]; - -/// Ed25519 signature. -/// -/// This type represents a container for the byte serialization of an Ed25519 -/// signature, and does not necessarily represent well-formed field or curve -/// elements. -/// -/// Signature verification libraries are expected to reject invalid field -/// elements at the time a signature is verified. -#[derive(Copy, Clone, Eq, PartialEq)] -#[repr(C)] -pub struct Signature { - R: ComponentBytes, - s: ComponentBytes, -} - -impl Signature { - /// Size of an encoded Ed25519 signature in bytes. - pub const BYTE_SIZE: usize = COMPONENT_SIZE * 2; - - /// Parse an Ed25519 signature from a byte slice. - pub fn from_bytes(bytes: &SignatureBytes) -> Self { - let mut R = ComponentBytes::default(); - let mut s = ComponentBytes::default(); - - let components = bytes.split_at(COMPONENT_SIZE); - R.copy_from_slice(components.0); - s.copy_from_slice(components.1); - - Self { R, s } - } - - /// Parse an Ed25519 signature from its `R` and `s` components. - pub fn from_components(R: ComponentBytes, s: ComponentBytes) -> Self { - Self { R, s } - } - - /// Parse an Ed25519 signature from a byte slice. - /// - /// # Returns - /// - `Ok` on success - /// - `Err` if the input byte slice is not 64-bytes - pub fn from_slice(bytes: &[u8]) -> signature::Result { - SignatureBytes::try_from(bytes) - .map(Into::into) - .map_err(|_| Error::new()) - } - - /// Bytes for the `R` component of a signature. - pub fn r_bytes(&self) -> &ComponentBytes { - &self.R - } - - /// Bytes for the `s` component of a signature. - pub fn s_bytes(&self) -> &ComponentBytes { - &self.s - } - - /// Return the inner byte array. - pub fn to_bytes(&self) -> SignatureBytes { - let mut ret = [0u8; Self::BYTE_SIZE]; - let (R, s) = ret.split_at_mut(COMPONENT_SIZE); - R.copy_from_slice(&self.R); - s.copy_from_slice(&self.s); - ret - } - - /// Convert this signature into a byte vector. - #[cfg(feature = "alloc")] - pub fn to_vec(&self) -> Vec { - self.to_bytes().to_vec() - } -} - -impl SignatureEncoding for Signature { - type Repr = SignatureBytes; - - fn to_bytes(&self) -> SignatureBytes { - self.to_bytes() - } -} - -impl From for SignatureBytes { - fn from(sig: Signature) -> SignatureBytes { - sig.to_bytes() - } -} - -impl From<&Signature> for SignatureBytes { - fn from(sig: &Signature) -> SignatureBytes { - sig.to_bytes() - } -} - -impl From for Signature { - fn from(bytes: SignatureBytes) -> Self { - Signature::from_bytes(&bytes) - } -} - -impl From<&SignatureBytes> for Signature { - fn from(bytes: &SignatureBytes) -> Self { - Signature::from_bytes(bytes) - } -} - -impl TryFrom<&[u8]> for Signature { - type Error = Error; - - fn try_from(bytes: &[u8]) -> signature::Result { - Self::from_slice(bytes) - } -} - -impl fmt::Debug for Signature { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("ed25519::Signature") - .field("R", &hex::ComponentFormatter(self.r_bytes())) - .field("s", &hex::ComponentFormatter(self.s_bytes())) - .finish() - } -} - -impl fmt::Display for Signature { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:X}", self) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/pkcs8.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/pkcs8.rs deleted file mode 100644 index 92039aec97bb..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/pkcs8.rs +++ /dev/null @@ -1,356 +0,0 @@ -//! PKCS#8 private key support. -//! -//! Implements Ed25519 PKCS#8 private keys as described in RFC8410 Section 7: -//! -//! -//! ## SemVer Notes -//! -//! The `pkcs8` module of this crate is exempted from SemVer as it uses a -//! pre-1.0 dependency (the `pkcs8` crate). -//! -//! However, breaking changes to this module will be accompanied by a minor -//! version bump. -//! -//! Please lock to a specific minor version of the `ed25519` crate to avoid -//! breaking changes when using this module. - -pub use pkcs8::{ - spki, DecodePrivateKey, DecodePublicKey, Error, ObjectIdentifier, PrivateKeyInfo, Result, -}; - -#[cfg(feature = "alloc")] -pub use pkcs8::{spki::EncodePublicKey, EncodePrivateKey}; - -#[cfg(feature = "alloc")] -pub use pkcs8::der::{asn1::BitStringRef, Document, SecretDocument}; - -use core::fmt; - -#[cfg(feature = "pem")] -use { - alloc::string::{String, ToString}, - core::str, -}; - -#[cfg(feature = "zeroize")] -use zeroize::Zeroize; - -/// Algorithm [`ObjectIdentifier`] for the Ed25519 digital signature algorithm -/// (`id-Ed25519`). -/// -/// -pub const ALGORITHM_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.3.101.112"); - -/// Ed25519 Algorithm Identifier. -pub const ALGORITHM_ID: pkcs8::AlgorithmIdentifierRef<'static> = pkcs8::AlgorithmIdentifierRef { - oid: ALGORITHM_OID, - parameters: None, -}; - -/// Ed25519 keypair serialized as bytes. -/// -/// This type is primarily useful for decoding/encoding PKCS#8 private key -/// files (either DER or PEM) encoded using the following traits: -/// -/// - [`DecodePrivateKey`]: decode DER or PEM encoded PKCS#8 private key. -/// - [`EncodePrivateKey`]: encode DER or PEM encoded PKCS#8 private key. -/// -/// PKCS#8 private key files encoded with PEM begin with: -/// -/// ```text -/// -----BEGIN PRIVATE KEY----- -/// ``` -/// -/// Note that this type operates on raw bytes and performs no validation that -/// keys represent valid Ed25519 field elements. -pub struct KeypairBytes { - /// Ed25519 secret key. - /// - /// Little endian serialization of an element of the Curve25519 scalar - /// field, prior to "clamping" (i.e. setting/clearing bits to ensure the - /// scalar is actually a valid field element) - pub secret_key: [u8; Self::BYTE_SIZE / 2], - - /// Ed25519 public key (if available). - /// - /// Compressed Edwards-y encoded curve point. - pub public_key: Option, -} - -impl KeypairBytes { - /// Size of an Ed25519 keypair when serialized as bytes. - const BYTE_SIZE: usize = 64; - - /// Parse raw keypair from a 64-byte input. - pub fn from_bytes(bytes: &[u8; Self::BYTE_SIZE]) -> Self { - let (sk, pk) = bytes.split_at(Self::BYTE_SIZE / 2); - - Self { - secret_key: sk.try_into().expect("secret key size error"), - public_key: Some(PublicKeyBytes( - pk.try_into().expect("public key size error"), - )), - } - } - - /// Serialize as a 64-byte keypair. - /// - /// # Returns - /// - /// - `Some(bytes)` if the `public_key` is present. - /// - `None` if the `public_key` is absent (i.e. `None`). - pub fn to_bytes(&self) -> Option<[u8; Self::BYTE_SIZE]> { - if let Some(public_key) = &self.public_key { - let mut result = [0u8; Self::BYTE_SIZE]; - let (sk, pk) = result.split_at_mut(Self::BYTE_SIZE / 2); - sk.copy_from_slice(&self.secret_key); - pk.copy_from_slice(public_key.as_ref()); - Some(result) - } else { - None - } - } -} - -impl Drop for KeypairBytes { - fn drop(&mut self) { - #[cfg(feature = "zeroize")] - self.secret_key.zeroize() - } -} - -#[cfg(feature = "alloc")] -impl EncodePrivateKey for KeypairBytes { - fn to_pkcs8_der(&self) -> Result { - // Serialize private key as nested OCTET STRING - let mut private_key = [0u8; 2 + (Self::BYTE_SIZE / 2)]; - private_key[0] = 0x04; - private_key[1] = 0x20; - private_key[2..].copy_from_slice(&self.secret_key); - - let private_key_info = PrivateKeyInfo { - algorithm: ALGORITHM_ID, - private_key: &private_key, - public_key: self.public_key.as_ref().map(|pk| pk.0.as_slice()), - }; - - let result = SecretDocument::encode_msg(&private_key_info)?; - - #[cfg(feature = "zeroize")] - private_key.zeroize(); - - Ok(result) - } -} - -impl TryFrom> for KeypairBytes { - type Error = Error; - - fn try_from(private_key: PrivateKeyInfo<'_>) -> Result { - private_key.algorithm.assert_algorithm_oid(ALGORITHM_OID)?; - - if private_key.algorithm.parameters.is_some() { - return Err(Error::ParametersMalformed); - } - - // Ed25519 PKCS#8 keys are represented as a nested OCTET STRING - // (i.e. an OCTET STRING within an OCTET STRING). - // - // This match statement checks and removes the inner OCTET STRING - // header value: - // - // - 0x04: OCTET STRING tag - // - 0x20: 32-byte length - let secret_key = match private_key.private_key { - [0x04, 0x20, rest @ ..] => rest.try_into().map_err(|_| Error::KeyMalformed), - _ => Err(Error::KeyMalformed), - }?; - - let public_key = private_key - .public_key - .map(|bytes| bytes.try_into().map_err(|_| Error::KeyMalformed)) - .transpose()? - .map(PublicKeyBytes); - - Ok(Self { - secret_key, - public_key, - }) - } -} - -impl TryFrom<&[u8]> for KeypairBytes { - type Error = Error; - - fn try_from(der_bytes: &[u8]) -> Result { - Self::from_pkcs8_der(der_bytes) - } -} - -impl fmt::Debug for KeypairBytes { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("KeypairBytes") - .field("public_key", &self.public_key) - .finish_non_exhaustive() - } -} - -#[cfg(feature = "pem")] -impl str::FromStr for KeypairBytes { - type Err = Error; - - fn from_str(pem: &str) -> Result { - Self::from_pkcs8_pem(pem) - } -} - -/// Ed25519 public key serialized as bytes. -/// -/// This type is primarily useful for decoding/encoding SPKI public key -/// files (either DER or PEM) encoded using the following traits: -/// -/// - [`DecodePublicKey`]: decode DER or PEM encoded PKCS#8 private key. -/// - [`EncodePublicKey`]: encode DER or PEM encoded PKCS#8 private key. -/// -/// SPKI public key files encoded with PEM begin with: -/// -/// ```text -/// -----BEGIN PUBLIC KEY----- -/// ``` -/// -/// Note that this type operates on raw bytes and performs no validation that -/// public keys represent valid compressed Ed25519 y-coordinates. -#[derive(Clone, Copy, Eq, PartialEq)] -pub struct PublicKeyBytes(pub [u8; Self::BYTE_SIZE]); - -impl PublicKeyBytes { - /// Size of an Ed25519 public key when serialized as bytes. - const BYTE_SIZE: usize = 32; - - /// Returns the raw bytes of the public key. - pub fn to_bytes(&self) -> [u8; Self::BYTE_SIZE] { - self.0 - } -} - -impl AsRef<[u8; Self::BYTE_SIZE]> for PublicKeyBytes { - fn as_ref(&self) -> &[u8; Self::BYTE_SIZE] { - &self.0 - } -} - -#[cfg(feature = "alloc")] -impl EncodePublicKey for PublicKeyBytes { - fn to_public_key_der(&self) -> spki::Result { - pkcs8::SubjectPublicKeyInfoRef { - algorithm: ALGORITHM_ID, - subject_public_key: BitStringRef::new(0, &self.0)?, - } - .try_into() - } -} - -impl TryFrom> for PublicKeyBytes { - type Error = spki::Error; - - fn try_from(spki: spki::SubjectPublicKeyInfoRef<'_>) -> spki::Result { - spki.algorithm.assert_algorithm_oid(ALGORITHM_OID)?; - - if spki.algorithm.parameters.is_some() { - return Err(spki::Error::KeyMalformed); - } - - spki.subject_public_key - .as_bytes() - .ok_or(spki::Error::KeyMalformed)? - .try_into() - .map(Self) - .map_err(|_| spki::Error::KeyMalformed) - } -} - -impl TryFrom<&[u8]> for PublicKeyBytes { - type Error = spki::Error; - - fn try_from(der_bytes: &[u8]) -> spki::Result { - Self::from_public_key_der(der_bytes) - } -} - -impl TryFrom for PublicKeyBytes { - type Error = spki::Error; - - fn try_from(keypair: KeypairBytes) -> spki::Result { - PublicKeyBytes::try_from(&keypair) - } -} - -impl TryFrom<&KeypairBytes> for PublicKeyBytes { - type Error = spki::Error; - - fn try_from(keypair: &KeypairBytes) -> spki::Result { - keypair.public_key.ok_or(spki::Error::KeyMalformed) - } -} - -impl fmt::Debug for PublicKeyBytes { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("PublicKeyBytes(")?; - - for &byte in self.as_ref() { - write!(f, "{:02X}", byte)?; - } - - f.write_str(")") - } -} - -#[cfg(feature = "pem")] -impl str::FromStr for PublicKeyBytes { - type Err = spki::Error; - - fn from_str(pem: &str) -> spki::Result { - Self::from_public_key_pem(pem) - } -} - -#[cfg(feature = "pem")] -impl ToString for PublicKeyBytes { - fn to_string(&self) -> String { - self.to_public_key_pem(Default::default()) - .expect("PEM serialization error") - } -} - -#[cfg(feature = "pem")] -#[cfg(test)] -mod tests { - use super::{KeypairBytes, PublicKeyBytes}; - use hex_literal::hex; - - const SECRET_KEY_BYTES: [u8; 32] = - hex!("D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F44755842"); - - const PUBLIC_KEY_BYTES: [u8; 32] = - hex!("19BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1"); - - #[test] - fn to_bytes() { - let valid_keypair = KeypairBytes { - secret_key: SECRET_KEY_BYTES, - public_key: Some(PublicKeyBytes(PUBLIC_KEY_BYTES)), - }; - - assert_eq!( - valid_keypair.to_bytes().unwrap(), - hex!("D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F4475584219BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1") - ); - - let invalid_keypair = KeypairBytes { - secret_key: SECRET_KEY_BYTES, - public_key: None, - }; - - assert_eq!(invalid_keypair.to_bytes(), None); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/serde.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/serde.rs deleted file mode 100644 index d7a7022ce602..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/serde.rs +++ /dev/null @@ -1,121 +0,0 @@ -//! `serde` support. - -use crate::{Signature, SignatureBytes}; -use ::serde::{de, ser, Deserialize, Serialize}; -use core::fmt; - -impl Serialize for Signature { - fn serialize(&self, serializer: S) -> Result { - use ser::SerializeTuple; - - let mut seq = serializer.serialize_tuple(Signature::BYTE_SIZE)?; - - for byte in self.to_bytes() { - seq.serialize_element(&byte)?; - } - - seq.end() - } -} - -// serde lacks support for deserializing arrays larger than 32-bytes -// see: -impl<'de> Deserialize<'de> for Signature { - fn deserialize>(deserializer: D) -> Result { - struct ByteArrayVisitor; - - impl<'de> de::Visitor<'de> for ByteArrayVisitor { - type Value = [u8; Signature::BYTE_SIZE]; - - fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("bytestring of length 64") - } - - fn visit_seq(self, mut seq: A) -> Result<[u8; Signature::BYTE_SIZE], A::Error> - where - A: de::SeqAccess<'de>, - { - use de::Error; - let mut arr = [0u8; Signature::BYTE_SIZE]; - - for (i, byte) in arr.iter_mut().enumerate() { - *byte = seq - .next_element()? - .ok_or_else(|| Error::invalid_length(i, &self))?; - } - - Ok(arr) - } - } - - deserializer - .deserialize_tuple(Signature::BYTE_SIZE, ByteArrayVisitor) - .map(Into::into) - } -} - -#[cfg(feature = "serde_bytes")] -impl serde_bytes::Serialize for Signature { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - serializer.serialize_bytes(&self.to_bytes()) - } -} - -#[cfg(feature = "serde_bytes")] -impl<'de> serde_bytes::Deserialize<'de> for Signature { - fn deserialize(deserializer: D) -> Result - where - D: de::Deserializer<'de>, - { - struct ByteArrayVisitor; - - impl<'de> de::Visitor<'de> for ByteArrayVisitor { - type Value = SignatureBytes; - - fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("bytestring of length 64") - } - - fn visit_bytes(self, bytes: &[u8]) -> Result - where - E: de::Error, - { - use de::Error; - - bytes - .try_into() - .map_err(|_| Error::invalid_length(bytes.len(), &self)) - } - } - - deserializer - .deserialize_bytes(ByteArrayVisitor) - .map(Into::into) - } -} - -#[cfg(test)] -mod tests { - use crate::{Signature, SignatureBytes}; - use hex_literal::hex; - - const SIGNATURE_BYTES: SignatureBytes = hex!( - " - e5564300c360ac729086e2cc806e828a - 84877f1eb8e5d974d873e06522490155 - 5fb8821590a33bacc61e39701cf9b46b - d25bf5f0595bbe24655141438e7a100b - " - ); - - #[test] - fn round_trip() { - let signature = Signature::from_bytes(&SIGNATURE_BYTES); - let serialized = bincode::serialize(&signature).unwrap(); - let deserialized = bincode::deserialize(&serialized).unwrap(); - assert_eq!(signature, deserialized); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v1.der b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v1.der deleted file mode 100644 index cb780b362c9dbb7e62b9159ac40c45b1242bec2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 48 zcmV-00MGw0E&>4nFa-t!D`jv5A_O4R?sD7t6Ie>sw%GCaY51)={(LCQ@znd^m#B|K Gbyz~LI~HgF diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v1.pem b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v1.pem deleted file mode 100644 index e447080ae285..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v1.pem +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VwBCIEINTuctv5E1hK1bbY8fdp+K06/nwoy/HU++CXqI9EdVhC ------END PRIVATE KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v2.der b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v2.der deleted file mode 100644 index 3358e8a730ac3daf865b6eab869bb9a921ab9ef4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 116 zcmV-)0E_=HasmMXFa-t!D`jv5A_O4R?sD7t6Ie>sw%GCaY51)={(LCQ@znd^m#B|K zbyz~6A21yT3Mz(3hW8Bt2?-Q24-5@Mb#i2EWgtUnVQF%6fgu1HzeEXXgw6hiLAt?b W+&h-YP==~7wzkU*TsW<8F=pYUFECsH diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v2.pem b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v2.pem deleted file mode 100644 index e56a7d96d302..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pkcs8-v2.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PRIVATE KEY----- -MHICAQEwBQYDK2VwBCIEINTuctv5E1hK1bbY8fdp+K06/nwoy/HU++CXqI9EdVhC -oB8wHQYKKoZIhvcNAQkJFDEPDA1DdXJkbGUgQ2hhaXJzgSEAGb9ECWmEzf6FQbrB -Z9w7lshQhqowtrbLDFw4rXAxZuE= ------END PRIVATE KEY------ diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pubkey.der b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/examples/pubkey.der deleted file mode 100644 index d1002c4a4e624c322cc71015e6685a25808df374..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44 zcmXreGGJw6)=n*8R%DRe@4}hca`s=V -const TEST_1_SIGNATURE: [u8; Signature::BYTE_SIZE] = hex!( - "e5564300c360ac729086e2cc806e828a - 84877f1eb8e5d974d873e06522490155 - 5fb8821590a33bacc61e39701cf9b46b - d25bf5f0595bbe24655141438e7a100b" -); - -#[test] -fn display() { - let sig = Signature::from_bytes(&TEST_1_SIGNATURE); - assert_eq!(sig.to_string(), "E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B") -} - -#[test] -fn lower_hex() { - let sig = Signature::from_bytes(&TEST_1_SIGNATURE); - assert_eq!(format!("{:x}", sig), "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b") -} - -#[test] -fn upper_hex() { - let sig = Signature::from_bytes(&TEST_1_SIGNATURE); - assert_eq!(format!("{:X}", sig), "E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B") -} - -#[test] -fn from_str_lower() { - let sig = Signature::from_str("e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b").unwrap(); - assert_eq!(sig.to_bytes(), TEST_1_SIGNATURE); -} - -#[test] -fn from_str_upper() { - let sig = Signature::from_str("E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B").unwrap(); - assert_eq!(sig.to_bytes(), TEST_1_SIGNATURE); -} - -#[test] -fn from_str_rejects_mixed_case() { - let result = Signature::from_str("E5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b"); - assert!(result.is_err()); -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/pkcs8.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/pkcs8.rs deleted file mode 100644 index 729131180129..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/pkcs8.rs +++ /dev/null @@ -1,86 +0,0 @@ -//! PKCS#8 private key tests - -#![cfg(feature = "pkcs8")] - -use ed25519::pkcs8::{DecodePrivateKey, DecodePublicKey, KeypairBytes, PublicKeyBytes}; -use hex_literal::hex; - -#[cfg(feature = "alloc")] -use ed25519::pkcs8::{EncodePrivateKey, EncodePublicKey}; - -/// Ed25519 PKCS#8 v1 private key encoded as ASN.1 DER. -const PKCS8_V1_DER: &[u8] = include_bytes!("examples/pkcs8-v1.der"); - -/// Ed25519 PKCS#8 v2 private key + public key encoded as ASN.1 DER. -const PKCS8_V2_DER: &[u8] = include_bytes!("examples/pkcs8-v2.der"); - -/// Ed25519 SubjectPublicKeyInfo encoded as ASN.1 DER. -const PUBLIC_KEY_DER: &[u8] = include_bytes!("examples/pubkey.der"); - -#[test] -fn decode_pkcs8_v1() { - let keypair = KeypairBytes::from_pkcs8_der(PKCS8_V1_DER).unwrap(); - - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/pkcs8-v1.der - assert_eq!( - keypair.secret_key, - &hex!("D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F44755842")[..] - ); - - assert_eq!(keypair.public_key, None); -} - -#[test] -fn decode_pkcs8_v2() { - let keypair = KeypairBytes::from_pkcs8_der(PKCS8_V2_DER).unwrap(); - - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/pkcs8-v2.der - assert_eq!( - keypair.secret_key, - &hex!("D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F44755842")[..] - ); - - assert_eq!( - keypair.public_key.unwrap().0, - hex!("19BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1") - ); -} - -#[test] -fn decode_public_key() { - let public_key = PublicKeyBytes::from_public_key_der(PUBLIC_KEY_DER).unwrap(); - - // Extracted with: - // $ openssl pkey -inform der -in tests/examples/pkcs8-v1.der -pubout -text - assert_eq!( - public_key.as_ref(), - &hex!("19BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1") - ); -} - -#[cfg(feature = "alloc")] -#[test] -fn encode_pkcs8_v1() { - let pk = KeypairBytes::from_pkcs8_der(PKCS8_V1_DER).unwrap(); - let pk_der = pk.to_pkcs8_der().unwrap(); - assert_eq!(pk_der.as_bytes(), PKCS8_V1_DER); -} - -#[cfg(feature = "alloc")] -#[test] -fn encode_pkcs8_v2() { - let pk = KeypairBytes::from_pkcs8_der(PKCS8_V2_DER).unwrap(); - let pk2 = KeypairBytes::from_pkcs8_der(pk.to_pkcs8_der().unwrap().as_bytes()).unwrap(); - assert_eq!(pk.secret_key, pk2.secret_key); - assert_eq!(pk.public_key, pk2.public_key); -} - -#[cfg(feature = "alloc")] -#[test] -fn encode_public_key() { - let pk = PublicKeyBytes::from_public_key_der(PUBLIC_KEY_DER).unwrap(); - let pk_der = pk.to_public_key_der().unwrap(); - assert_eq!(pk_der.as_ref(), PUBLIC_KEY_DER); -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/serde.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/serde.rs deleted file mode 100644 index 93f0ebcea6ff..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/tests/serde.rs +++ /dev/null @@ -1,62 +0,0 @@ -//! Tests for serde serializers/deserializers - -#![cfg(feature = "serde")] - -use ed25519::{Signature, SignatureBytes}; -use hex_literal::hex; - -const EXAMPLE_SIGNATURE: SignatureBytes = hex!( - "3f3e3d3c3b3a393837363534333231302f2e2d2c2b2a29282726252423222120" - "1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100" -); - -#[test] -fn test_serialize() { - let signature = Signature::try_from(&EXAMPLE_SIGNATURE[..]).unwrap(); - dbg!(&signature); - let encoded_signature: Vec = bincode::serialize(&signature).unwrap(); - assert_eq!(&EXAMPLE_SIGNATURE[..], &encoded_signature[..]); -} - -#[test] -fn test_deserialize() { - let signature = bincode::deserialize::(&EXAMPLE_SIGNATURE).unwrap(); - assert_eq!(EXAMPLE_SIGNATURE, signature.to_bytes()); -} - -#[cfg(feature = "serde_bytes")] -#[test] -fn test_serialize_bytes() { - use bincode::Options; - - let signature = Signature::try_from(&EXAMPLE_SIGNATURE[..]).unwrap(); - - let mut encoded_signature = Vec::new(); - let options = bincode::DefaultOptions::new() - .with_fixint_encoding() - .allow_trailing_bytes(); - let mut serializer = bincode::Serializer::new(&mut encoded_signature, options); - serde_bytes::serialize(&signature, &mut serializer).unwrap(); - - let mut expected = Vec::from(Signature::BYTE_SIZE.to_le_bytes()); - expected.extend(&EXAMPLE_SIGNATURE[..]); - assert_eq!(&expected[..], &encoded_signature[..]); -} - -#[cfg(feature = "serde_bytes")] -#[test] -fn test_deserialize_bytes() { - use bincode::Options; - - let mut encoded_signature = Vec::from(Signature::BYTE_SIZE.to_le_bytes()); - encoded_signature.extend(&EXAMPLE_SIGNATURE[..]); - - let options = bincode::DefaultOptions::new() - .with_fixint_encoding() - .allow_trailing_bytes(); - let mut deserializer = bincode::de::Deserializer::from_slice(&encoded_signature[..], options); - - let signature: Signature = serde_bytes::deserialize(&mut deserializer).unwrap(); - - assert_eq!(EXAMPLE_SIGNATURE, signature.to_bytes()); -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.cargo_vcs_info.json deleted file mode 100644 index a5fefac65b05..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "4ac84dd0668b1d2e51654fcdffe4ae6a687bef00" - }, - "path_in_vcs": "ed25519-dalek" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.travis.yml b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.travis.yml deleted file mode 100644 index 72f94de7dc7c..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: rust - -rust: - - stable - - beta - - nightly - -env: - - TEST_COMMAND=test EXTRA_FLAGS='' FEATURES='' - -matrix: - include: - # We use the 64-bit optimised curve backend by default, so also test with - # the 32-bit backend (this also exercises testing with `no_std`): - - rust: nightly - env: TEST_COMMAND=build EXTRA_FLAGS='--no-default-features' FEATURES='u32_backend alloc' - # Also test the batch feature: - - rust: nightly - env: TEST_COMMAND=build EXTRA_FLAGS='--no-default-features' FEATURES='u64_backend alloc batch' - # Test any nightly gated features on nightly: - - rust: nightly - env: TEST_COMMAND=test EXTRA_FLAGS='' FEATURES='nightly' - # Test serde support on stable, assuming that if it works there it'll work everywhere: - - rust: stable - env: TEST_COMMAND=test EXTRA_FLAGS='' FEATURES='serde' - -script: - - cargo $TEST_COMMAND --features="$FEATURES" $EXTRA_FLAGS - -notifications: - slack: - rooms: - - dalek-cryptography:Xxv9WotKYWdSoKlgKNqXiHoD#dalek-bots diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/CHANGELOG.md b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/CHANGELOG.md deleted file mode 100644 index 9d1b65e6b94d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/CHANGELOG.md +++ /dev/null @@ -1,52 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -Entries are listed in reverse chronological order per undeprecated major series. - -# Unreleased - -# 2.x series - -## 2.1.1 - -* Fix nightly SIMD build - -## 2.1.0 - -* Add `SigningKey::to_scalar_bytes` for getting the unclamped scalar from a signing key -* Loosened `signature` dependency to allow version 2.2 - -## 2.0.0 - -### Breaking changes - -* Bump MSRV from 1.41 to 1.60.0 -* Bump Rust edition -* Bump `signature` dependency to 2.0 -* Make `digest` an optional dependency -* Make `zeroize` an optional dependency -* Make `rand_core` an optional dependency -* [curve25519 backends] are now automatically selected -* [curve25519 backends] are now overridable via cfg instead of using additive features -* Make all batch verification deterministic remove `batch_deterministic` (PR [#256](https://github.com/dalek-cryptography/ed25519-dalek/pull/256)) -* Rename `Keypair` → `SigningKey` and `PublicKey` → `VerifyingKey` -* Remove default-public `ExpandedSecretKey` API (PR [#205](https://github.com/dalek-cryptography/ed25519-dalek/pull/205)) -* Make `hazmat` feature to expose `ExpandedSecretKey`, `raw_sign()`, `raw_sign_prehashed()`, `raw_verify()`, and `raw_verify_prehashed()` - -[curve25519 backends]: https://github.com/dalek-cryptography/curve25519-dalek/#backends - -### Other changes - -* Add `Context` type for prehashed signing -* Add `VerifyingKey::{verify_prehash_strict, is_weak}` -* Add `pkcs` feature to support PKCS #8 (de)serialization of `SigningKey` and `VerifyingKey` -* Add `fast` feature to include basepoint tables -* Add tests for validation criteria -* Impl `DigestSigner`/`DigestVerifier` for `SigningKey`/`VerifyingKey`, respectively -* Impl `Hash` for `VerifyingKey` -* Impl `Clone`, `Drop`, and `ZeroizeOnDrop` for `SigningKey` -* Remove `rand` dependency -* Improve key deserialization diagnostics diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/Cargo.toml deleted file mode 100644 index 8381deb7ed75..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/Cargo.toml +++ /dev/null @@ -1,199 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -rust-version = "1.60" -name = "ed25519-dalek" -version = "2.1.1" -authors = [ - "isis lovecruft ", - "Tony Arcieri ", - "Michael Rosenberg ", -] -exclude = [ - ".gitignore", - "TESTVECTORS", - "VALIDATIONVECTORS", - "res/*", -] -description = "Fast and efficient ed25519 EdDSA key generations, signing, and verification in pure Rust." -homepage = "https://github.com/dalek-cryptography/curve25519-dalek" -documentation = "https://docs.rs/ed25519-dalek" -readme = "README.md" -keywords = [ - "cryptography", - "ed25519", - "curve25519", - "signature", - "ECC", -] -categories = [ - "cryptography", - "no-std", -] -license = "BSD-3-Clause" -repository = "https://github.com/dalek-cryptography/curve25519-dalek/tree/main/ed25519-dalek" - -[package.metadata.docs.rs] -features = [ - "batch", - "digest", - "hazmat", - "pem", - "serde", -] -rustdoc-args = [ - "--html-in-header", - "docs/assets/rustdoc-include-katex-header.html", - "--cfg", - "docsrs", -] - -[[bench]] -name = "ed25519_benchmarks" -harness = false -required-features = ["rand_core"] - -[dependencies.curve25519-dalek] -version = "4" -features = ["digest"] -default-features = false - -[dependencies.ed25519] -version = ">=2.2, <2.3" -default-features = false - -[dependencies.merlin] -version = "3" -optional = true -default-features = false - -[dependencies.rand_core] -version = "0.6.4" -optional = true -default-features = false - -[dependencies.serde] -version = "1.0" -optional = true -default-features = false - -[dependencies.sha2] -version = "0.10" -default-features = false - -[dependencies.signature] -version = ">=2.0, <2.3" -optional = true -default-features = false - -[dependencies.subtle] -version = "2.3.0" -default-features = false - -[dependencies.zeroize] -version = "1.5" -optional = true -default-features = false - -[dev-dependencies.bincode] -version = "1.0" - -[dev-dependencies.blake2] -version = "0.10" - -[dev-dependencies.criterion] -version = "0.5" -features = ["html_reports"] - -[dev-dependencies.curve25519-dalek] -version = "4" -features = [ - "digest", - "rand_core", -] -default-features = false - -[dev-dependencies.hex] -version = "0.4" - -[dev-dependencies.hex-literal] -version = "0.4" - -[dev-dependencies.rand] -version = "0.8" - -[dev-dependencies.rand_core] -version = "0.6.4" -default-features = false - -[dev-dependencies.serde] -version = "1.0" -features = ["derive"] - -[dev-dependencies.serde_json] -version = "1.0" - -[dev-dependencies.sha3] -version = "0.10" - -[dev-dependencies.toml] -version = "0.7" - -[dev-dependencies.x25519-dalek] -version = "2" -features = ["static_secrets"] -default-features = false - -[features] -alloc = [ - "curve25519-dalek/alloc", - "ed25519/alloc", - "serde?/alloc", - "zeroize/alloc", -] -asm = ["sha2/asm"] -batch = [ - "alloc", - "merlin", - "rand_core", -] -default = [ - "fast", - "std", - "zeroize", -] -digest = ["signature/digest"] -fast = ["curve25519-dalek/precomputed-tables"] -hazmat = [] -legacy_compatibility = ["curve25519-dalek/legacy_compatibility"] -pem = [ - "alloc", - "ed25519/pem", - "pkcs8", -] -pkcs8 = ["ed25519/pkcs8"] -rand_core = ["dep:rand_core"] -serde = [ - "dep:serde", - "ed25519/serde", -] -std = [ - "alloc", - "ed25519/std", - "serde?/std", - "sha2/std", -] -zeroize = [ - "dep:zeroize", - "curve25519-dalek/zeroize", -] diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/Cargo.toml.orig deleted file mode 100644 index 626b8da92acf..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/Cargo.toml.orig +++ /dev/null @@ -1,78 +0,0 @@ -[package] -name = "ed25519-dalek" -version = "2.1.1" -edition = "2021" -authors = [ - "isis lovecruft ", - "Tony Arcieri ", - "Michael Rosenberg " -] -readme = "README.md" -license = "BSD-3-Clause" -repository = "https://github.com/dalek-cryptography/curve25519-dalek/tree/main/ed25519-dalek" -homepage = "https://github.com/dalek-cryptography/curve25519-dalek" -documentation = "https://docs.rs/ed25519-dalek" -keywords = ["cryptography", "ed25519", "curve25519", "signature", "ECC"] -categories = ["cryptography", "no-std"] -description = "Fast and efficient ed25519 EdDSA key generations, signing, and verification in pure Rust." -exclude = [ ".gitignore", "TESTVECTORS", "VALIDATIONVECTORS", "res/*" ] -rust-version = "1.60" - -[package.metadata.docs.rs] -rustdoc-args = [ - "--html-in-header", "docs/assets/rustdoc-include-katex-header.html", - "--cfg", "docsrs", -] -features = ["batch", "digest", "hazmat", "pem", "serde"] - -[dependencies] -curve25519-dalek = { version = "4", path = "../curve25519-dalek", default-features = false, features = ["digest"] } -ed25519 = { version = ">=2.2, <2.3", default-features = false } -signature = { version = ">=2.0, <2.3", optional = true, default-features = false } -sha2 = { version = "0.10", default-features = false } -subtle = { version = "2.3.0", default-features = false } - -# optional features -merlin = { version = "3", default-features = false, optional = true } -rand_core = { version = "0.6.4", default-features = false, optional = true } -serde = { version = "1.0", default-features = false, optional = true } -zeroize = { version = "1.5", default-features = false, optional = true } - -[dev-dependencies] -curve25519-dalek = { version = "4", path = "../curve25519-dalek", default-features = false, features = ["digest", "rand_core"] } -x25519-dalek = { version = "2", path = "../x25519-dalek", default-features = false, features = ["static_secrets"] } -blake2 = "0.10" -sha3 = "0.10" -hex = "0.4" -bincode = "1.0" -serde_json = "1.0" -criterion = { version = "0.5", features = ["html_reports"] } -hex-literal = "0.4" -rand = "0.8" -rand_core = { version = "0.6.4", default-features = false } -serde = { version = "1.0", features = ["derive"] } -toml = { version = "0.7" } - -[[bench]] -name = "ed25519_benchmarks" -harness = false -required-features = ["rand_core"] - -[features] -default = ["fast", "std", "zeroize"] -alloc = ["curve25519-dalek/alloc", "ed25519/alloc", "serde?/alloc", "zeroize/alloc"] -std = ["alloc", "ed25519/std", "serde?/std", "sha2/std"] - -asm = ["sha2/asm"] -batch = ["alloc", "merlin", "rand_core"] -fast = ["curve25519-dalek/precomputed-tables"] -digest = ["signature/digest"] -# Exposes the hazmat module -hazmat = [] -# Turns off stricter checking for scalar malleability in signatures -legacy_compatibility = ["curve25519-dalek/legacy_compatibility"] -pkcs8 = ["ed25519/pkcs8"] -pem = ["alloc", "ed25519/pem", "pkcs8"] -rand_core = ["dep:rand_core"] -serde = ["dep:serde", "ed25519/serde"] -zeroize = ["dep:zeroize", "curve25519-dalek/zeroize"] diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/LICENSE b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/LICENSE deleted file mode 100644 index acf8498e2c4e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2017-2019 isis agora lovecruft. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/README.md b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/README.md deleted file mode 100644 index fbb30e9de4c2..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/README.md +++ /dev/null @@ -1,178 +0,0 @@ -# ed25519-dalek [![](https://img.shields.io/crates/v/ed25519-dalek.svg)](https://crates.io/crates/ed25519-dalek) [![](https://docs.rs/ed25519-dalek/badge.svg)](https://docs.rs/ed25519-dalek) [![CI](https://github.com/dalek-cryptography/curve25519-dalek/actions/workflows/ed25519-dalek.yml/badge.svg?branch=main)](https://github.com/dalek-cryptography/curve25519-dalek/actions/workflows/ed25519-dalek.yml) - -Fast and efficient Rust implementation of ed25519 key generation, signing, and -verification. - -# Use - -To import `ed25519-dalek`, add the following to the dependencies section of -your project's `Cargo.toml`: -```toml -ed25519-dalek = "2" -``` - -# Feature Flags - -This crate is `#[no_std]` compatible with `default-features = false`. - -| Feature | Default? | Description | -| :--- | :--- | :--- | -| `alloc` | ✓ | When `pkcs8` is enabled, implements `EncodePrivateKey`/`EncodePublicKey` for `SigningKey`/`VerifyingKey`, respectively. | -| `std` | ✓ | Implements `std::error::Error` for `SignatureError`. Also enables `alloc`. | -| `zeroize` | ✓ | Implements `Zeroize` and `ZeroizeOnDrop` for `SigningKey` | -| `rand_core` | | Enables `SigningKey::generate` | -| `batch` | | Enables `verify_batch` for verifying many signatures quickly. Also enables `rand_core`. | -| `digest` | | Enables `Context`, `SigningKey::{with_context, sign_prehashed}` and `VerifyingKey::{with_context, verify_prehashed, verify_prehashed_strict}` for Ed25519ph prehashed signatures | -| `asm` | | Enables assembly optimizations in the SHA-512 compression functions | -| `pkcs8` | | Enables [PKCS#8](https://en.wikipedia.org/wiki/PKCS_8) serialization/deserialization for `SigningKey` and `VerifyingKey` | -| `pem` | | Enables PEM serialization support for PKCS#8 private keys and SPKI public keys. Also enables `alloc`. | -| `legacy_compatibility` | | **Unsafe:** Disables certain signature checks. See [below](#malleability-and-the-legacy_compatibility-feature) | -| `hazmat` | | **Unsafe:** Exposes the `hazmat` module for raw signing/verifying. Misuse of these functions will expose the private key, as in the [signing oracle attack](https://github.com/MystenLabs/ed25519-unsafe-libs). | - -# Major Changes - -See [CHANGELOG.md](CHANGELOG.md) for a list of changes made in past version of this crate. - -## Breaking Changes in 2.0.0 - -* Bump MSRV from 1.41 to 1.60.0 -* Bump Rust edition -* Bump `signature` dependency to 2.0 -* Make `digest` an optional dependency -* Make `zeroize` an optional dependency -* Make `rand_core` an optional dependency -* Adopt [curve25519-backend selection](https://github.com/dalek-cryptography/curve25519-dalek/#backends) over features -* Make all batch verification deterministic remove `batch_deterministic` ([#256](https://github.com/dalek-cryptography/ed25519-dalek/pull/256)) -* Remove `ExpandedSecretKey` API ([#205](https://github.com/dalek-cryptography/ed25519-dalek/pull/205)) -* Rename `Keypair` → `SigningKey` and `PublicKey` → `VerifyingKey` -* Make `hazmat` feature to expose, `ExpandedSecretKey`, `raw_sign()`, `raw_sign_prehashed()`, `raw_verify()`, and `raw_verify_prehashed()` - -# Documentation - -Documentation is available [here](https://docs.rs/ed25519-dalek). - -# Compatibility Policies - -All on-by-default features of this library are covered by [semantic versioning](https://semver.org/spec/v2.0.0.html) (SemVer). -SemVer exemptions are outlined below for MSRV and public API. - -## Minimum Supported Rust Version - -| Releases | MSRV | -| :--- | :--- | -| 2.x | 1.60 | -| 1.x | 1.41 | - -From 2.x and on, MSRV changes will be accompanied by a minor version bump. - -## Public API SemVer Exemptions - -Breaking changes to SemVer-exempted components affecting the public API will be accompanied by some version bump. - -Below are the specific policies: - -| Releases | Public API Component(s) | Policy | -| :--- | :--- | :--- | -| 2.x | Dependencies `digest`, `pkcs8` and `rand_core` | Minor SemVer bump | - -# Safety - -`ed25519-dalek` is designed to prevent misuse. Signing is constant-time, all signing keys are zeroed when they go out of scope (unless `zeroize` is disabled), detached public keys [cannot](https://github.com/MystenLabs/ed25519-unsafe-libs/blob/main/README.md) be used for signing, and extra functions like [`VerifyingKey::verify_strict`](#weak-key-forgery-and-verify_strict) are made available to avoid known gotchas. - -Further, this crate has no—and in fact forbids—unsafe code. You can opt in to using some highly optimized unsafe code that resides in `curve25519-dalek`, though. See [below](#microarchitecture-specific-backends) for more information on backend selection. - -# Performance - -Performance is a secondary goal behind correctness, safety, and clarity, but we -aim to be competitive with other implementations. - -## Benchmarks - -Benchmarks are run using [criterion.rs](https://github.com/japaric/criterion.rs): - -```sh -cargo bench --features "batch" -# Uses avx2 or ifma only if compiled for an appropriate target. -export RUSTFLAGS='-C target_cpu=native' -cargo +nightly bench --features "batch" -``` - -On an Intel 10700K running at stock comparing between the `curve25519-dalek` backends. - -| Benchmark | u64 | simd +avx2 | fiat | -| :--- | :---- | :--- | :--- | -| signing | 15.017 µs | 13.906 µs -7.3967% | 15.877 μs +5.7268% | -| signature verification | 40.144 µs | 25.963 µs -35.603% | 42.118 μs +4.9173% | -| strict signature verification | 41.334 µs | 27.874 µs -32.660% | 43.985 μs +6.4136% | -| batch signature verification/4 | 109.44 µs | 81.778 µs -25.079% | 117.80 μs +7.6389% | -| batch signature verification/8 | 182.75 µs | 138.40 µs -23.871% | 195.86 μs +7.1737% | -| batch signature verification/16 | 328.67 µs | 251.39 µs -23.744% | 351.55 μs +6.9614% | -| batch signature verification/32 | 619.49 µs | 477.36 µs -23.053% | 669.41 μs +8.0582% | -| batch signature verification/64 | 1.2136 ms | 936.85 µs -22.543% | 1.3028 ms +7.3500% | -| batch signature verification/96 | 1.8677 ms | 1.2357 ms -33.936% | 2.0552 ms +10.039% | -| batch signature verification/128| 2.3281 ms | 1.5795 ms -31.996% | 2.5596 ms +9.9437% | -| batch signature verification/256| 4.1868 ms | 2.8864 ms -31.061% | 4.6494 μs +11.049% | -| keypair generation | 13.973 µs | 13.108 µs -6.5062% | 15.099 μs +8.0584% | - -## Batch Performance - -If your protocol or application is able to batch signatures for verification, -the [`verify_batch`][func_verify_batch] function has greatly improved performance. - -As you can see, there's an optimal batch size for each machine, so you'll likely -want to test the benchmarks on your target CPU to discover the best size. - -## (Micro)Architecture Specific Backends - -A _backend_ refers to an implementation of elliptic curve and scalar arithmetic. Different backends have different use cases. For example, if you demand formally verified code, you want to use the `fiat` backend (as it was generated from [Fiat Crypto][fiat]). - -Backend selection details and instructions can be found in the [curve25519-dalek docs](https://github.com/dalek-cryptography/curve25519-dalek#backends). - -# Contributing - -See [CONTRIBUTING.md](../CONTRIBUTING.md) - -# Batch Signature Verification - -The standard variants of batch signature verification (i.e. many signatures made with potentially many different public keys over potentially many different messages) is available via the `batch` feature. It uses deterministic randomness, i.e., it hashes the inputs (using [`merlin`](https://merlin.cool/), which handles transcript item separation) and uses the result to generate random coefficients. Batch verification requires allocation, so this won't function in heapless settings. - -# Validation Criteria - -The _validation criteria_ of a signature scheme are the criteria that signatures and public keys must satisfy in order to be accepted. Unfortunately, Ed25519 has some underspecified parts, leading to different validation criteria across implementations. For a very good overview of this, see [Henry's post][validation]. - -In this section, we mention some specific details about our validation criteria, and how to navigate them. - -## Malleability and the `legacy_compatibility` Feature - -A signature scheme is considered to produce _malleable signatures_ if a passive attacker with knowledge of a public key _A_, message _m_, and valid signature _σ'_ can produce a distinct _σ'_ such that _σ'_ is a valid signature of _m_ with respect to _A_. A scheme is only malleable if the attacker can do this _without_ knowledge of the private key corresponding to _A_. - -`ed25519-dalek` is not a malleable signature scheme. - -Some other Ed25519 implementations are malleable, though, such as [libsodium with `ED25519_COMPAT` enabled](https://github.com/jedisct1/libsodium/blob/24211d370a9335373f0715664271dfe203c7c2cd/src/libsodium/crypto_sign/ed25519/ref10/open.c#L30), [ed25519-donna](https://github.com/floodyberry/ed25519-donna/blob/8757bd4cd209cb032853ece0ce413f122eef212c/ed25519.c#L100), [NaCl's ref10 impl](https://github.com/floodyberry/ed25519-donna/blob/8757bd4cd209cb032853ece0ce413f122eef212c/fuzz/ed25519-ref10.c#L4627), and probably a lot more. -If you need to interoperate with such implementations and accept otherwise invalid signatures, you can enable the `legacy_compatibility` flag. **Do not enable `legacy_compatibility`** if you don't have to, because it will make your signatures malleable. - -Note: [CIRCL](https://github.com/cloudflare/circl/blob/fa6e0cca79a443d7be18ed241e779adf9ed2a301/sign/ed25519/ed25519.go#L358) has no scalar range check at all. We do not have a feature flag for interoperating with the larger set of RFC-disallowed signatures that CIRCL accepts. - -## Weak key Forgery and `verify_strict()` - -A _signature forgery_ is what it sounds like: it's when an attacker, given a public key _A_, creates a signature _σ_ and message _m_ such that _σ_ is a valid signature of _m_ with respect to _A_. Since this is the core security definition of any signature scheme, Ed25519 signatures cannot be forged. - -However, there's a much looser kind of forgery that Ed25519 permits, which we call _weak key forgery_. An attacker can produce a special public key _A_ (which we call a _weak_ public key) and a signature _σ_ such that _σ_ is a valid signature of _any_ message _m_, with respect to _A_, with high probability. This attack is acknowledged in the [Ed25519 paper](https://ed25519.cr.yp.to/ed25519-20110926.pdf), and caused an exploitable bug in the Scuttlebutt protocol ([paper](https://eprint.iacr.org/2019/526.pdf), section 7.1). The [`VerifyingKey::verify()`][method_verify] function permits weak keys. - -We provide [`VerifyingKey::verify_strict`][method_verify_strict] (and [`verify_strict_prehashed`][method_verify_strict_ph]) to help users avoid these scenarios. These functions perform an extra check on _A_, ensuring it's not a weak public key. In addition, we provide the [`VerifyingKey::is_weak`][method_is_weak] to allow users to perform this check before attempting signature verification. - -## Batch verification - -As mentioned above, weak public keys can be used to produce signatures for unknown messages with high probability. This means that sometimes a weak forgery attempt will fail. In fact, it can fail up to 7/8 of the time. If you call `verify()` twice on the same failed forgery, it will return an error both times, as expected. However, if you call `verify_batch()` twice on two distinct otherwise-valid batches, both of which contain the failed forgery, there's a 21% chance that one fails and the other succeeds. - -Why is this? It's because `verify_batch()` does not do the weak key testing of `verify_strict()`, and it multiplies each verification equation by some random coefficient. If the failed forgery gets multiplied by 8, then the weak key (which is a low-order point) becomes 0, and the verification equation on the attempted forgery will succeed. - -Since `verify_batch()` is intended to be high-throughput, we think it's best not to put weak key checks in it. If you want to prevent weird behavior due to weak public keys in your batches, you should call [`VerifyingKey::is_weak`][method_is_weak] on the inputs in advance. - -[fiat]: https://github.com/mit-plv/fiat-crypto -[validation]: https://hdevalence.ca/blog/2020-10-04-its-25519am -[func_verify_batch]: https://docs.rs/ed25519-dalek/latest/ed25519_dalek/fn.verify_batch.html -[method_verify]: https://docs.rs/ed25519-dalek/latest/ed25519_dalek/struct.VerifyingKey.html#method.verify -[method_verify_strict]: https://docs.rs/ed25519-dalek/latest/ed25519_dalek/struct.VerifyingKey.html#method.verify_strict -[method_verify_strict_ph]: https://docs.rs/ed25519-dalek/latest/ed25519_dalek/struct.VerifyingKey.html#method.verify_strict_prehashed -[method_is_weak]: https://docs.rs/ed25519-dalek/latest/ed25519_dalek/struct.VerifyingKey.html#method.is_weak diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/benches/ed25519_benchmarks.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/benches/ed25519_benchmarks.rs deleted file mode 100644 index efa419ceba81..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/benches/ed25519_benchmarks.rs +++ /dev/null @@ -1,100 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2018-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -use criterion::{criterion_group, Criterion}; - -mod ed25519_benches { - use super::*; - use ed25519_dalek::Signature; - use ed25519_dalek::Signer; - use ed25519_dalek::SigningKey; - use rand::prelude::ThreadRng; - use rand::thread_rng; - - fn sign(c: &mut Criterion) { - let mut csprng: ThreadRng = thread_rng(); - let keypair: SigningKey = SigningKey::generate(&mut csprng); - let msg: &[u8] = b""; - - c.bench_function("Ed25519 signing", move |b| b.iter(|| keypair.sign(msg))); - } - - fn verify(c: &mut Criterion) { - let mut csprng: ThreadRng = thread_rng(); - let keypair: SigningKey = SigningKey::generate(&mut csprng); - let msg: &[u8] = b""; - let sig: Signature = keypair.sign(msg); - - c.bench_function("Ed25519 signature verification", move |b| { - b.iter(|| keypair.verify(msg, &sig)) - }); - } - - fn verify_strict(c: &mut Criterion) { - let mut csprng: ThreadRng = thread_rng(); - let keypair: SigningKey = SigningKey::generate(&mut csprng); - let msg: &[u8] = b""; - let sig: Signature = keypair.sign(msg); - - c.bench_function("Ed25519 strict signature verification", move |b| { - b.iter(|| keypair.verify_strict(msg, &sig)) - }); - } - - #[cfg(feature = "batch")] - fn verify_batch_signatures(c: &mut Criterion) { - use ed25519_dalek::verify_batch; - - static BATCH_SIZES: [usize; 8] = [4, 8, 16, 32, 64, 96, 128, 256]; - - // Benchmark batch verification for all the above batch sizes - let mut group = c.benchmark_group("Ed25519 batch signature verification"); - for size in BATCH_SIZES { - let name = format!("size={size}"); - group.bench_function(name, |b| { - let mut csprng: ThreadRng = thread_rng(); - let keypairs: Vec = (0..size) - .map(|_| SigningKey::generate(&mut csprng)) - .collect(); - let msg: &[u8] = b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - let messages: Vec<&[u8]> = (0..size).map(|_| msg).collect(); - let signatures: Vec = keypairs.iter().map(|key| key.sign(msg)).collect(); - let verifying_keys: Vec<_> = - keypairs.iter().map(|key| key.verifying_key()).collect(); - - b.iter(|| verify_batch(&messages[..], &signatures[..], &verifying_keys[..])); - }); - } - } - - // If the above function isn't defined, make a placeholder function - #[cfg(not(feature = "batch"))] - fn verify_batch_signatures(_: &mut Criterion) {} - - fn key_generation(c: &mut Criterion) { - let mut csprng: ThreadRng = thread_rng(); - - c.bench_function("Ed25519 keypair generation", move |b| { - b.iter(|| SigningKey::generate(&mut csprng)) - }); - } - - criterion_group! { - name = ed25519_benches; - config = Criterion::default(); - targets = - sign, - verify, - verify_strict, - verify_batch_signatures, - key_generation, - } -} - -criterion::criterion_main!(ed25519_benches::ed25519_benches); diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/docs/assets/ed25519-malleability.png b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/docs/assets/ed25519-malleability.png deleted file mode 100644 index fe5896e99e3f912a8c924ee02bc687ba483eb9a2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44136 zcmb@ucOce(+dq8DmW1r=l}+}F?3q17Br>uxLiXO-d+)s>LfJwxLx}9`vJx_$L*MJV z@9VjL_wV`ZIsdr6t~xt?&d>Y(K91KqK4EGqayPKZun-8u4F!2=4FuxaEc`ryaSi@= z%b;c+{)6l!si1{{f$?=wbpe5(Mkq*2Xt`xHg_644oA_yUe8)hSl-SuvdPK72)Th$SdtT>r&1U;77>`2qlFnRi60lU{ij!S z*n7XghCk@VkKbKXEnNx5>C^o`w%ITxaPR-?HS)FOumOScuNMM09{<|km%rGxyUaAy ze_!jj{^O64{{Q~tl8+C4qj$wUPj+MXV!M`ikKg@>2}4Ng&}jB+c|GuYLh*zU|E?GP z)s-BlOT}#jcpAN{3jdBplsw^e4KI}2SGawqJFPwYxstZ__jyV9Mv4WT zu2R#C419-ak`EWB>nuhI?%jKD`?W#6RIB!6zRkyHu`{Tuio>m}s;brJ(z~>>Mz10# zhng|I-?Wy9O>g)7_q>v#R!n$!_{fMFQN+abbd%SgqtSf1h`|qw4ljOw8(iKyJ3mLi zNy(-_GHRpPtu`<+){cKKDm1ijc(_=N3B%u^$&i>hS-V^(F)=Yy#8u_Ng9kD)K?AEV zTwILaIv^oNzI|);`tu^?+w`>iN*|t)kx`G#%e|$Zz2)8w=hL&3gY)xq!s^|v#VuYV zGcz+;S+pR@$K0vOoW_i?@}_k%GBTBVwf@SCbQt(}c(qRl$yUQ@tUb+}mOBE_A3uKV zEbP@4d_yUT4KF>UcX@SXMNmYfytFjT_90UMx##ijN zH8wWRzGRkv`t*B${2c=WgJd@S*LHKw-|(gMk55h}CMO*QGkT+`e%rlqBs(t^Is;R51`|#oE-m+YzH0s^EclY-9S(uoZ zSXrOc(to=+*{W`%gx|T+A78FpZHhscb_4&`Eloqiiky<{lx!5$WDcX|7dtab$sBOc z?Up}8!B41&si`S)QMa11vd!^QO*Aw#xoFCu)Hn6@{{H?fEG(Own+E}Ib1Qd zPkP}OynX%pb#AT%GoklA&!D0f*Pq{F>Et>)I}d;TdSYry@6vd9=&Y%!$(@Rg2#t!O z5U|S_W5DBUeLcIlxLE6Rc>$|5w&AScUS-&{ztcERDei5k@mZ3T8dmw|d|NNGthV;V zdyn5ZRASf&w_lqRT_HDzGlT+)bCfF=s=EgVcXk)M%+1YV&tU0r$ZaXEHO_n2)z?WmW2@1*e89`cH#a+LXlRH) z9IOqaBMe(!L=CS+Jhij2G26D=X71Qm$=iNJ=ZAZf zT|z=aWaNOIuZ_qEF|X4=6)}1Gv4xI+VwFrXe0*-l6?ug=HFFvG@*h8b?Cg|ee&eML z_c!9ztE2t>JT)ed-#;o#OG&v*e5Y*m_4VN*c8|~h{EoAG#NuDFm$-_w)OJGvcq9`{EAXrDX`G;OX=t&DRWOvPeUc+ zPF1FjB_}7>(sGD8c-=s&$#C!1j-t8*%UnSO`NT)9f|8QHj~}t_-E;jxK4f5tTN^t~ z!Nkjam!Cga{8=ES9s)7*^{a84_s-^KxDj&pFtJCn3=Y?(`a43nMp0eoTpKo`XY;LI zA2rkxtUecQtgmjTKf|CZ9_sq(QxeDi+KjpPy#OYeL&&AH!DiJ6%hY_tHCVh=aB3cXs> zg?7K!SR>=(&KGAVX=!A(wmYw0;W#-RJV@tHO-=2eQG_Gp=;&x*a66<6389=V<^^xu zCH??=R*#J+zTfcu%U}De0}KkZ2|JUO25ZCFm;0;N5eu*d;AeCMl#P+eNq#Z03;0`y zRF;q~Oe`!%2L}YgX0G`c93u?>PZ>f^s~;0JTwpQNVL$%b`ZDnGW9!NH+bPGZ1IZKR zy7OXvm{A-D#6PeP-~F_6`pZ_xDc^H$G?G^B5l=U+A<(Mn+b^=`6KU zQW~&tJ1>HwSyuLO?cht5QN*|Y7-kiE{cZTtczAf)+S-lw^Ht^Lbu~4|zrGkVXq%dw zCnhDy7Jr8FYin(N3PtSIt5*W{-!Pav&A6c}x7p8&!P-6hQU$g7oyYH?4&~apMg(kU=x0hSg98Ht zp>Plr5owf;mzA*~+JkT0hHu4{X9`!UuC9JtzzzlB{Nly8CMS!p4YpGs!);M<6pux& z$ujt36%`cJOm7DVqvZ;AQ`wmIqHj+UZqt$DtU*_X{lv(~czSx8*T%yz5q(ckzEX#v zRHi#^Z&>_NSy2&gmL{y&%a_9b)D#pHm6eq?{C}XGx@}YQIVWP$Uaz)()X`>PKI}{5 z+q?X(7fFiCtKa#sO+Qipi1KJ!dm8@UOW>!73C8xl?a|BDGWR#DBSa<`vahHxRexvC z-^BL&)i_C7kIg&0f*S8fGga>zZz7S~-6s-D7QlxVO`5S!yQ)1{{wZ9!Md8IvSABe4 z{PTwWvhRttnRmHRh*XG1Z{|JzSjE%gOXHBflXSqi2JfDdtL>T#Rw9&T`ucgSxU{L% z`nz>IE=ner;^2b^gAWGFKKV~7d1eWk^dU?z&VK)~&@s#7D@iTSj25|kyIyM|wX0eo z2b~xR0VO=B7}@~r0CF5TV`HE7kz7wPs-nyN0Zz-<`g&ei;M3EWC=$n>t;NM_0DG@L2OGx+y z1W38N3n>o|4+Cl`9dG>{49hEYgn2c<5VL{E% z@YC`h7kQwZCRx!Cut5Fhp?U#PteGrF@_=dWr%#{!0|IiN!*a{cv-4FD)(A z*3u#%AXu<(EHA(6CD2h$_E&dvF%uPy8tsfcJUpD8>nkcN9=#_sdMoVuV|KACWNl?- z_U&_I1ea+yhG_LMmig!Lab7Mi-`@|Not>eG!E1r;00|iln^M%R!ygsl3uQGw_zFB% z=-188&hEBR^E{hmgPnVP?B@1zZ78$JX-$JE!TsR-#Q1o7&~#K()cR7<(9n?2<)3+0 z-Ks!=cmOJ@;^)rWQ?<}QYJU+E6N|g;<`fm7A#$p##Vv+1;_s*`;xh^eG}hL}4y<-+ zy1KfuvX)m>RY8Ft&KCC>FHz^3>+iP$hzSLZ@Xx?~8-}U4fdYa=#W!_zuyqGMeKKtG zzIWEY^!@u0REZR09Y1JjnHd?dz6bmJ@7}%h^zu45H~@I{%9tfGAtSAv0&adKi}@5D1zIo$RxcWMP(SYBQp zz`ClcSLb56;o(@#Y6+6L?XF)KnD_TrmBg~e;r1eYlai7uD|Y~kn&_u45w(dpOp3bi zn^{;`xNUE2Y%DFkezEfqMM6tkTP}*s{Mj?sQmavH0xTILqfBYq4rCV>7w%M1lXir? z{ZF7-*JXnm8eX`$9Ybl)Eq(kPKP=Ef1go~PZw9Yhhc<e|*>`w5PzK9`f zR+Pq!k9!W-o?Iwyc&)1x;ZLogpa5WyM21l{>kPJGr9mUmELdyUdL`xM$XESxukp{( z&exflhluvRSh`W^+qZ8c+M!06+sdr#&}8JCL616KjU_ZTHU@kO@0-F(9*7DH>o^#f z#l3Ok27JS%r6stJh<4yWi-X#N%YM&H?B`qW*?$vFxrAK+Kf5?PZ=Z6)5@Dku6A_!k zZv+&dFB`Sw*aWu<)(y^lT;TKP&r7SS8s5B_d*|*1-8rB`(0N_W+uQrmqpX&e7L%c{ zTX)1fj>*d(DE1ppKP?Q!YV_=)Ch1J{v(@-fkJRD=b~8u~>e2To{+;1dS4o zo5MIV;+^Noe#_6+fL;xXz+5XYuk(DlXcRsGI@a3Si9l(U854(1U(@Q~b!b0BM#l+! ziA1`rgJCnbH_ldnGX{$C=VI0J@^W>V0_$+Op&PgP3knN!DVdp>J5FBGsU-Y>8l+qM z?=@5_h~^a#xWmXel*%K=)i#1}Bl_$54IH;JLP={p{Sb-TXYU!NB{X7x+{g52j+HL} zaPV`kK*$BB%Jy4;KQp=V$KF8m;sn}LrHDC!I7H?Jq_Ogj7lDggLqH*O_= zugzmS!)s(TcYJ&-6@oMI2N9>6EOq7775Qw0lpuC@M5tU|Fm@V!O z14DlSfwVKa(DA|bs@L6|T;a8~wF}JNno5I0u0IT6lLITI5Ov!Hq6839P7YlZC$50m zlT%rZ5-25MGPBA`LrO&`3vGh`g>MqGT~Pa^(W|t@g-2Ri^v4GZ&!566vYD!Z*TTZW z(voRmn^>iDqhh#Js{h{tUq$OxP*Z~&>TD~tNnD1c`bJWoopx)AgGk{8Zf9@r9dU80 zd$9Koz7MAFHTp+6@~36;J=2kw$H-J^bJ^07kU;t%$&Ww)r8Bs3dVCB}m+;XA9WCub zn%Y?o@dDqo$w*Qj*`~^xX&Z#EqibAAS=meIr$DYp697Jfu+dUcafJhQs|=@GTscoU zDWiLz)-l+wQTP1=grlNc@m$N_VH;QR9s4O^6jmy+jw|Li1qDlf=`%(tS`2%)h6=t z@|wtVlxs|-z&q)=!bc*KuTDt3WG=J^Mp|0a;jDY0EI8btlV(K6M6y3IBdv9gTE}Bi%Jg&)3PDsEg@&QD-)DwZ#prNmiiHNbX zC#`KqZx*GziBN+goSDgfJWnGPtenn&15xAg+YV@fh=@pvO7Z8m%ZoqEnnj|X$7(aA}o8Qr41JjreTPynk_wNEZCF4ptARkJVZ zYAdF6e~x|rytqlk$M=OWnzM`rK@&I@mrfuG)yGF@d}CNcg=Hi z^tqgS^?6Po-;lSntMc>n8}VS`mdI5b5e9%XdI;r}C-oB?n+_Rd$1j`>geS8s3R>7^ zSo{jh0R@wU*l6&r>FDTa=rF#C##DQkPJC3CZt9}u|MBBT*0sYh1x&*;+PAn?!2Za{ z$e@BQ7wTiY{Dbsu3LP=q=0jCw_h)wz`J$!5jQa!@S&QXYwD`sSoeNl{xfa*0jg9`9 zk8oN?LoBW^jkY#FKmX;~n)q`pI?T5pP^-L{IXQ{nuVJR=eBSW41(pLS=)g@hgXg8- zB`(>or$ZT~u-z*wZ%{pz09nipKmx#yoUh`$CudM?Z3p4@2K8|yF^n9ixT*?A zWdanq$F!bqVMI_gGIDI$+1R#scA_anj(Vwla(Qw(rH@x0s)jYLgj0v`{L!w-gIIvYcd$UR42Pa+3r#jU7v(BLFzkdB9z*>dd zIyyQE?9#B=8M^I{P&_(d6;1#fKzoA5keZUhX3)UK$@#Oo?V=gr1kiY38C#p1OazMR z>Z5@7JUu<38;Rb#7li*nSsDHdM1+=(4!)`P)?{UOcehLg(O{;Ct~G0GYpa9%5ioxc z{(fw1xC4v?;G8aC4_c+e##mv?iyaM3&43+AcC72ySy@<$9;7p}e1ak>U5A7K2?x3| zXoMNDu^pzhfcNO@Y3D{pYD!Av<>V~jiq|FmBm&UPEi9axW(U&+@&&{{9e$!e=@}d2 z78E>&uk5dil53+0tY7eXp2<@{Z`ZF!z#4d-9+tj)cLr+?e3zhwF9XO*YU(r~wKs3x zq^G6D#l;={oTnlr{B`>489-ZrzCJ#e(0<{zwa<010$#JW1`G+{zpT6*N(*Sxz*9Ch zH_Iw3--9X&NGCEf^41-dGoW|kXS)G{(r1-91rJ z==!dJ(t-77WRRl;EPnsa7~k%5ak7@gZUEp&QAz3Z=g+XuN6;hU3O)`E5pmCf5L5WE zIzK-?J-r2#dR~1iSO@_+u+O>cu*3-=m$4q7m|clY?X~sx7E^IG zxlL|2o&ZuG9^Uh%?l4Z{R#A_mZ2+}@e*X+%9Yj5Uq@lqLojg|_?5(U$pbtX5QB_qPo}MPnzW{YdAprTsoAp*re`w+Tk?SNf`J=Dv>VOCD z{`9#N;paaBasWsjsv4EJcXz{;j)!Fw)b)V&wHJe6Bhi-~!3-`EY{vM~>S|8s%%o`e zG60DqysPz!bXq-6K;0dg=lz)X{yl{Rt^((&-Aug|a4HP}SF&eeZ|X0g3Fq-8BqoxQ zkc94h#qb9e2>!W}mnaZiSh5nWvcyEfFlhj|K=-#Lzr)8{T3g4-7wqplvLp%vuI>1O zhlk=0a4AT#wx*_CuP4grFH!GAR`J^#571=U&hQj#YiiOzG(M)Fmuulp)zT-@#G11p z66HHMIs5ogk)53#fIwl2f4`ZIj?ODGKE?IB4`gL!pFJzrXieiNCDfmTW>C6-$zQr0 zFg2Noj}1^fNFWAm2>|>HH)P!OV_Uqptyfv|W*^tAZ44^(>nf?J48g(QTw7}dteBCJ z0h<_Dr_| z2CL7E&IfWfT$2g7xVWD8NJvS&PWB6-oHRGT1Yh9&MM0$R{jk2HAyvld{1lAq); zE|U8AnQKWbb0yUG)0t5;Nbgga+*M2U7{G^LjEj3HVdmk9j98#MyJ;-uY38}Ty_v8a zz=v{7gA^w$V`Qv3uh**=BwZ26@Q)owcTf=M`_C&!_ZL^KW5spSfVH(XP@yU40wN-= zpSlNDhk%zv4%JYl7r5EU?fQ$)XC#YtLPS4CVoAt-JY)vwc*->>5 z4_AYA(X}Y*eMV9w&#eM4V4+~5pktGa%+9`Z+cOms>tLE8_g-=8)>XRXBBmuaPS?Owy|`R8E!n?*xs&ya`@W( zI>MwUoDgUs>`gGiz@Ji5R0N?pO~|PTKYfeSp=lPVA`ed;RAHuam0BF_f`7h1=})I7 zLlBanPg)F9Mv6*4o~1zhi39iyYNfM_%P2wZ2Y0w~;Hc1T7B<8$PgDg21PXcYVAe7w zZiYT8Zv1fKZOtJ>H9tN%30Mk?K_!K&qqo-rq=J3b*aQg>RFad4gCqfX+k*rG_S|mr z&SOGQD9a@)Iuh-!fE*s3Y`ZKA=uNW}D#FT0MKFY3g*23MdB} zz@f*CqC|xh;YQq?pI(po<{!8%Trphxp~25xN#2QY@$!NwL!gZJ>`EZHl0{`l#>U9R zz29l1#RuxeE4oNme>Pb56z5CMh_;71Eqx0lQIPcs;^i=*mb4GYXq0LJ#7q5nRD)$Y zc&tq`xp2>h2!vf=nPS*J<(6;(S*2Q3vPahWnA7%8WdMf_fWyOtE%+!g&S16Hi-7J%X}$m0rBy7p-Y* zgmSx)D%+-VdMp@9l`(h8x-oZeW76At>>GYdcG~s6=f(6iG>K={2rDhdiC z0|TW(4J+O>sQsS)zK=g_Z*K!G`n+)n<*ADg7i3Td1_oFVAT^+BTUlAb(JT180e_B- zM#sZ*OCkoegU-?1f&zL`QP1vBJh0hd&jEEO$q&|}Yxj9P{&{R{|Eql)xI@4K_fO8= zJo^H5ci_$u0B9g_5)uIsd`j?vKq^y}zdHy54S~xBBW9+~A{x45NZ0gx4}rs0a&Rbb zd~*nX)=J+)*f7{bJLwB26E06JmO&}$ZA*)BlOt-GEMt5$xsX2|SKfJ0zuA>{527Mi zXFxK*g>wJ>BQq*$u-RoR#{|9%I8e^Q6h&rFpYES{va?qL!!j{YE@Hx$u18ai&eL)N2N>@h;RgnTYMH8tbI!opfx#j=NcxrVZRE>aT`pg|PF zDFY~iA_1WCp@G4)%@G`#5q}c9PD>RwH)WPh4AHnyT7HuP;qvC@hxG&vQ+XQi-S#BK z){cCe2%5|Wf-54_1j%tCdcdg^cV5Sh=mAL>B;>2G!7TJ!Sey<%LtuCys;sWA?(&L@ z&wu-tC7Vx!(fPDaNl6Ln6@YgteEiO}13Z-J2HUToY}BH*m(&3w=rL_-X+cLpfhYv{ zE49ENc-=fax`^;l`a!v@G4azQ1Vjg?9S{{Riu=WxP@*Di9e`^PC!nD`iI0l|o`czA zX=}^J$M@d-ph$~na&mHWV*?chr9A@*B{~i{0`bo0l2QVfC?YXCySl21l7PVZ=ePGI zB}|C>E-rlj)Ua%@oB-i5{C7`00S7_uLV-JbUs$MJq$YjEIPcSyNpt zEeuk_3Vjl6S-1#1;}ZDuA#e7`gB?GAbxpvixIl|$93^k37O&_3>B0uM z3^9!p$fN`{|J`y`o__3d^wcSfQPlEIPIdYDPt45dMZL~X-?X%dH1BJT3mS4H_n5+$ zK}AQGLIn(TMfQoyP2Xa+2-TXTYsJwODAI-(_;$R|0S#eFgTyo@-b)ub+!e^LtWQvwLJDPdHHaD`eQ;=aSPnO^#}t%EWwm$X<62Pv6h0)Fp+vqs z_PnUK`uub_E9zq4%a<=8_-Y&D)W%-&2?px}nX~wm;+ORZP%f;usdhX{MuO+>IaiSv z+sAE}f5f4|$jQkabBaD^&~Z~Q5Y8(pv26E60(BO{pZwlSf^V*V@;69o_x|#2(u~YZ z0lQfyz3xw+l+{Q;KDV2F3)n6Xxn$vu{v;EAM2S@43k4JjpjcO)iNF7X)uTt0h@AR* zf~;?#uV0-1ag+}ooep~XBri^B=K@xB-t!=;;0I@^>-9IR#wG&OMQp^<|);D0#> zcIXJ3#CRo~1~4$BR6*PrrJb_t{G6djpGwe$r-)4={kpD3DJ(pSJ&}CQkZtZUhd$@D zW6nyVm%l*5J{Sr6`?GU%s65IUf_qT!cZ2aii9h{B;_SBwbQuYOjV7gW?zWi_9ucAB z;_?Pu0FVRYIYJHB{<_1xV-hf-7g8$Xif6f6 z4xJVL>f{0K8WkJm2M@AE-Ql4nW|BE{ zZlHIF`_G@(0#73Ebftp)hRE|JX(*)Nhdz6@b$LF2x%2J)AJ}iO+aUR&;+{yj=C-0< z^JiK5NBajV%&Em2O8s+pd;Av}-EJy34I=fwQnPE9cTB2y%&5)M(;~zlo}#pu(kly= z56G^bm*>CpHXsFo@P!`LAk#ERMG!a8~!>nLVYT`UZ4;UduerT&BE5! zNJAqoCWgyyR`6^L?89AXfKVqJ8X6G3|CX8A`XdpDT1`?KE9hBB2ueyyxQ}jT@mB>0 zZZraMJg?C~*Px|V7t?PhF5X55l8C4qmzbD098~TJx}+;vA35WBker+7D@%KOXc@5V zhEVN68z0F|;YN*|9ocY3_)h6MnMcvCF2P>3uy8#;b%DZm=T7leU=9!#1fYP%W(wG6 zdEzhq+|FZ~I!EnTpPR#*k~9esc&CJluB@z_Fh(A%@LZ9WXxle-h3)JyTF;M@ zSCbFEZ{n`Ys|%^rM$|@Oo&RQ=&7sIlvY6F9)}GHskv)DF1aI?^C5+YBeXk(K&jVU2+8546A-2^0fa(sMcwt~^|%m4Kfd9-M_vyZQROrSiL zjkzDiw-+y7fPNr(slD6C8JtdFh0~_6Cr``YHtvhJ#kQ@HXF9-==y~Yd)Ql{2hXEjP zRcR>_!t>%xAH13eArU)^wYj;A(629!m#+ksb^_r{Z$R>Jd^ef${79vP$5#Kz{zcLD7Xf)e*$9+uS9sLAtVpMZL;&qj1wih&aX2}pDw zD#$@}N-I3Aud9PMQi#gpqIly=?luOMyaMVW>asZwdugF1K`rth`MCdTbAoXBSI|{9 zH)mimu(V`4HO(bA4S;Ugpbs(~5!|^ay*M50>7dhtP`k3Wc1Pg>!BqVeX9zQEl`pRx z@XzzZ&#K@wLNefWeLeQgn>R5q`aXR^Ild-q^A58x^hGxGU(jo#t$1eu>2nyq&B@KB zd3Yyy7cd_bVoR*aN;C)!f!w*@v6WUsWCx42XAJVhz#M|Z}y?L*GZ7PL#RZr5$jFpofrrHJ46|b zgwBEZ$Y`|v`Xq(YJxRifeWQai8#qq=FZ+|wPbPbT1Kl9yre|Zbf#3&dI9xrwyFhLx%q!RJ?BO=Y)$ruxFG1IdRkFo)R#y{aVi1>!Sy^J>Xv7( zs#XyA>tN650l$Cvu=CDqxJ5v*x|zk#w6vwAyZ_06oKlv554 z4xlf9xrP=E;E02BPmSLmF(eP6=F8x~dvm4x(DLE0-LEQs4%VRe0RsbG~H^bO4eG5k%}P zY;4^aB#~}^ezg1?%DQKur}x&R;~K;SH8np2g@b*M#{byP?g!|y2gBmMy}cnpK~YrV zlwSF_-?SALu7b2vA%fUVnE&>%n&*NY7Kh{nCEUsAjD6AG?Y9a zp?qv>``&p&14UvII3q}i@S9gx38|w(;MqEOq-O_9x)5E3F+k&_ECK~s3Ta&Q6!jq5uw z1K331iU(HZn=T%lKuB7mEsg=R6wnj;ALIQn_CWf&g5qLez6O&syZPOEJsTJ_1!$2K zDe37{f)0=?8@1$pyMvyk5f>=_@{s8w>hVf`X{kaDrUIIlPKJ^s^BmPB_4J(IjSd|9 z}>K@sTkxKMYmo=W|CbA*nMuHs)_{1!Mq1e2@g` z%%sG484T$ffK`BR90W5!2RO48+nJn${!h)zdkB^a{C;TTP$ac>2Va51#c9-hxK-=p z>gq#V^9L`m?j^RV1}z1OgqY7oMP455Ti?{2JFqkmxbor&^3Ca8pZuYU@O*r$Fo$lrD`*u-R!o>P0UEzS# z2s+*$eN6vW@GY)I z%CEs10!hXw6!*O)8OSpV^dwHzbWkAxD_tjI+uhy0FaCK-VBbwt1^(zZ~L&x zv9O}8^kq99NGrR#RQ}Wu$KNc{F+*+n>2ti>@%8I%MFSlje&{bCqO4vY74c{|=QQMK z%**Ti^vMPoIhGE{#Fz-RC88v^lIm(I2-Yv$QLlRRUf8TJ2GXkA{tl{;sQU#y)uk@d zE!Kdz5cDUIuye}Gzjp0No_Z)_JqI9#K&ad~>Zl=*VT@9P<8((QgXwsbbd{FhW)~fi zJWx1l3GE*&osJ=Z86rJ}iMIc{vX+5G>Of2E2hp9@Rc!9sXnUU<2Y!>oapR$yI@ zo)q)w%PB8$Iy#7{fyIX+!C~BrjR46ZSYw8;Ky{Y+DrycoA++~*Wtg`ZfdWHLSaYw; z0i+k*3cW=rf-o467Y2}-E*?x4)ejsX)d7_T>7zwo_8n7R#8o^U})cz+H?u9YuO&w%NrQ9c&y-4@gF1K|C?TV2`QDSY3pat0D2MP zYu!zt98>(lBrH5LFc2Y`yFJ&^2+=lgXEL8HK?)jy|H#?{*!iHZR*{=vd2hS*>Jp)W zot~WRxxFJ~)gd4v8cO3+V&1_TyTizUTeuwyh&nSSX5styA~$V8W)2Q-NLoS+7xk6` zeH@5Gphskpoeq8X4d2Q$d^yK`&dV4i`0{WarYYp<3$N{f4)(kF;Px(#5x`M|{c zvrOlcKYrqjs4xKopsNw0*!=uSzgi{drT?D2A1f>40>8~a{4`{YCnYDJt?WGHnk&E? zVwS0%f(CY3Ut0^`7!45^5+Wif2qKt-HFIs=QOy|`apNN+zP(o(+;!}aGT*DQ!2LIR z=N79{jE;(Wmn0H21Qdx^l=raca{f^&WKrL@wnWT75_DWbg5?az83>CYBzuba?999Yms-qW0g(l%{8l(2{hNJ9SD-quoA z2UBX~^XC@FRmJ~r#kb+t%Khg?^i9~sbb{nVCkJcbhyj^_EaZu&Se9&9N&<>Mbw@{s z!{{miEwjvo&>KpK`@?cYIr5IrfD+Ij_1}2Lm;jKlnxHfX!x($Wn$SFk#eS-Z=|taBAf$38KqsObKtfrX82RyPe=3k28TYCqgSU4Ap8z)sUz5Oly?2=Mp+G1o#&NQjCksj8C2rDta!1b+)Kwgj$N_RozC zOmSzJC`--GR%MK*ASb^#J5bdd2K5JmhXVrxqiMZSx9_|aX8Yd~*SF3&qpmX6V2uVB zg9-)^6l(LkcZM)MQ5iD$G&v~=+GLe+n;1QP;P4t9#%s7hC|&v5<}jkLz7APE8jSt3 z6DO8LkhcN;fsG|4ini$3w2p-hUNDq>V7gPdDxdzB;B$uw7bv?5^kbZDXV-Sxm-iqe z@*$EG%5C@Z-mZY(EmW5d2U1Eo2pftB3q$qp{0veyq$QX2*A=@9=uMwI0X(u;3)WYd zbmwKii^AhDYWZO~#&B9P0AIP^Bsz{t>EZgXlH^rL#*_CiSxNZwkf&{Od*l%tawV0NOYc*Ua2PvaiD?>n+DtuP6VjG|C2?co4F2 zpeRp&`}T?m?~F5h7#ip-_|~JZ*qxCCp&GzMY75Y|SAe?NMQms4VPoW{0zwDjVbO9O z;uwb?0s{g9^7HA0bw2d;AR*K`AOr)|BY3g`{*dVoB`EEntwWG*FW|DYDT!v_%+LdY+V||A?5Alme`_L2u$Q*b< zkg-zB&?^*HR%&5Rc7nVGe98bsR?nD{Jv9Dn~XfZfecRB$6zb3f z^Tg-kARBftfP~qa#{rFvt{}p`dBcZ*u44uPDz{BA`ykkh@x5*nG~btQZcIwV*vS%H z212YsafM{jY>`CV=iM>q|M+aeag)^2{H}x3>wh>2an~Vi5dpgsd1a5BS~J5TMgz zQt>Zt)JgvPKsAFxv9`KOA?B&ab(O<`^{gx_^B*l?qZg9goT8=Lm&vctetc7hiIkM| zih8T46ls(?KBGr>R8d4Ac9BRFVMYW&&B<8}@sH8n*D#_)*6H!XYGa-AdTX3hY*Df`i zyv3G@ql1`~pS)T>7G69PFIkjIv6Em%TpWJNHM-o~+{ZxTxwV66NsqpIzu&;ey8-e8SObM0aUbd@khF!ig`4?6F5S&9 zses(^g4zIcZXgRo>zR5V|AD zaj{9L$}mblkAmq{Aa=mq*b+F5M_^21dTOemsOa_d_SJ|VI{Kf}Q+{6F1$QY8i8ZX} z(06~fT|Tnr#|nB4sxf%;keUQ}C+Da)zg4S{VB?Wj&r zT&Fa94TWP=8Wp`9(GiZ$R_!hFQbm(3=oGBQ07CL7hv z9mWMh*9oTBw&XMZbg%8HyFNZXmOF0;QU09;P(vV2v#cE)YGCh$g<)oJ=Kmw33emTL zHVCT<*qIC_9d6&=+S!S!Gl3Yug9lM+wEoo5l=mLKu})Ox#?Xh!72OeTsI*UEhMdDl z12k7%-Q?1z8BA5z8wLu98ev9-n;Q~c_{v(lUlw&q;$vWqNO_)OoFDp0H7UpAZ`YvQ z!%xL6v^0Z3TVC7&ih78hL2v+p_|If8<_AJFEMa2A{aiJ*FDu`_FR{IW36kTOgnqNm z+X$>9{ZI{-SOq$Ww1C!;TT3f0ZVWcaF48UUm6|(QwK6)pdKwiad12uc11PSAyv$m@5Ox)RO_bs+A~C$H6VAcl|vZWc5KE zfboWJpz?t01X&QlpDFje&ji`ocfjZL4}(Jwuw0O;D*sCQc!LcQdhhe*9P|GcTw$Ul zwX7!^PI?PAqp6_3WG>uU*ir2sgbQr~_TcCbUEJ@cFY5t|keI`eDFMgTD#2=`8%Jq` zE*3MPI2H_En0Pb6%F0RXhR6v@CaB4N9JY9l9LMvBm`%g&DFh;t@*dem;PKfB&xNfn z8#_DH%JN{dps&7sVFgaj?*bU<}YjEj2>xjVqMm{t9~U9R(9 zy88MjK=$S#Qv&aTYasG^ewT;GX|h6}TbuQk;wWmDxf{73bssb{h(EZ43y_kM0#e1X zbo;~v9|s3cz7dqDD<_BVSrWv`nww8S=p21>2s905b^sKEUd7GFXH;*g4vk66ehE{l zAe~OLiA+XX8e{_u2E|{cdJvaxg*-o;2S~&)+__^9v7^=zRx&`azKez#bMz3^?Tev- z%?OC&nT<`i{V;4;VId*R)|Keo)&e_*ve+dGW1T2)%t6uxH4LPChtoqV=#7DaD96>X z5}zP#r>bfX$^j%KTAbEijn7CM^fL2*fKIECuU?Vc&G_*yfTAa*nVEB-{zHP~&9h`^ z-_R0@i!Gq$_+u?eoKUSS|J5wPY{FH9b1n|JGrBi_)DkA3++MW#QlaOKT5|EgaLLwk zK|@eB&~7NgZ{wK*`^~<=+}{tG0HX$&UXj2BWh*}33GOHy768M2?3mHLtel+5W~nfj z4BGsFQIl3eVT4w)LeTIUR1t`{Q)7&QLGkF(H_!krwytdpx5cGs2?MTl_Az6Lg*+jQ zeffZo!({X-=NzaCfOGgv$OctZbhkYYc%3ouSKI~Ue?bcg6gSb)KCO4dEQR<&y#7ym z;Fg-r5G(3e=5sSm%?HI;E7azNKiKx`C=*$4sz&L$em|NoBp%kE%KKP?*9)Q&P#^Dc zMpHwr11&D77huF(z2@K-Y`pmWQ6D-dxY2Op*JY4STb(d5UM5qX9^LS#hVTSdtHCG* zgq{EZwYeY2a@9g=6o3GH;(G?d6@c`x6Tcsv!0ZU*R<*PfFSVJksfVT{q+i@l1zoG@ z#ZDS|dMi^z>rcaL{@;QEoiEE~;Atg+!NINYaZ*xGz*vXZT(g?7jwSC*Dvt%6mIaTm z;NsZudqBF~VIcewJ%r<-s{#)s$FTs&<8@MAd5%NNNSJFZ_ubg%+y!I?7|HmRgz%be zLP2@2q^hiVii+WXWt7Rt6smej6L=dVjHDmzYL5y$!5^!pDyd<)7LjJ~J{{~V`r2bPz{dd?jM|I?VJbv!`q#ih?*062B^Mn18XJR4h9KL(j*L;a!U;XlS73aFbw1eu8Md z6!a)jj#5sfOSFY~llCGc#;?k<7sC7L@8{da|GYn98}d0CaS>Y=Js&@;6lly+7I9x0 zrn_uDtELeNDM&2Lb-6MtCFeWgX)1cJ&B9(2YGZID8>p*4e)_ZlY(WKgaH#&tpn7Q3 z{0JUcZT0wF)mW$|W=cVJCCbLs+gE6uMa%_`ZMgjI&$X`}h@?_iZ!+Wn(SVy9(tN6% zm_gS^kCQifA zNT1i+mhq1;R^bU@@zx_I=}o(o^Jgu}qGsmizZx*+LSx!s%sZxDc z3j;oH1X?LBb{x7E1`UpBQNX0E`B=rXGq{Ry`ET_gI5RA$xyO3-vDq<8up;IIJ zo0NUqSa`g7KcQaE)W_LaJg$ie!`tJa1<9~!!kIT z!2AFlTR?9<$BXEZHvdF2&A3y$7U9`LE1(KOxEg@~BL^UXu8z)CTHwKh%DTE+Rcmo( z;r|(DwV!^Ciohix(9+Nto0%blaSBsYS_K47h!f0w!8Zl!076FxVapU$y8kJbuJe*g z^}+ni=*A&Du?e_0qmU3>11~>6;EgNp1j9y6Netr@#feeXr7%~Fe6jZ+R zvom>mjfW3sfG%%1zf@Dh4d?(LT^e@`OAF)-#%aJ;>^B?A z78i#c`s>$YFq{rV(v6LXf`VPA1G;|gk9e}pxFsZENk;Ur%?Jv#IJ4k43Rvtm^wa1T z_Z6)P479Y){~dSry)#tH&WV-9!KvU?n&sa|e0dx|by$9!?BeXt6uOyz+BrmbF{fg?D*Q`?g25kI_^Pby8^ED3{Afwg4>5We(Y>_kP}hbIfbb4~2+ z0h^T<6+MLrN%pWs-89%px9^%ttE=NRFuyglv$d^+#PR+6?LNHLRzg=A*aDoExX;tv6}!($LAh9$ZF=VKlg?gqzzUt3=fqQ1lV=`V;Vj06MBN(Z%zx98uw zpnuiMo*R&LFnfD?dPFHX|EDtB1Wz|Xk$^`ycza(>cc`h2Kq-Wn6+9VkVuBneq{nn) zYl}+QIrJ*k3-kLNHt$!6C}|ZWv1{I3#mF|-8M{lMun^bH zm%t(JkFbR)H7Pl{t1&`}7$CWtrQ@(Iq3yt<1(s^z;WKgcs0>Z2)+I{e=tAW5Wt(4*b&lJ)$c_-|3vJlqL;AVS7ExmS$}QhO!ExbDkTKD%`1EElUJnYau_ zJ}q=p2|=IY@i~&WwzuE8{(RIS4P#_Lg7@4+-Gm=^1_Cx-s!$s%Fne++8*j@fDyDj9 zd@wZJlHo!+Qy%|Sh}IJ2SU~XiF?pHaf59!Hrh~CX03#kd6xA$wYs1lY~F!+l;M?R}W6$grwi|;7?oH+Je&k5kzE+ z4bW!S*F&@ZDw|*nE^howEPM^E0;1kh|4Nx&NvY?$F!=^$nWQazmK5!l>m1ly-mAAo6hP(Dd}%X|&lscqmQKLxEYR z56WtSOv79n1`kr|cp{b!3J{$ol5|>2Aq!K#mxh!PFXhUMn4DI(1pGu&Rm(7$GA}Or zj?X3Z2jCib9}EiY_cRq`F<~lnM9X>Q9uw~;copbg!to5$Vp}zvRZT(;F+wM(GnPg;mK>706w@B9yH)N9NERj(J96JYw0>;mcY!GUVv z|Jn6U0_um2%9#ivy%i6tM-^)J)`v^p3(=nsZsLkDS`p9{occ=FMdqOynd|OD#nRdO zRD=5ZXFWYTYt*tT){&WyX^gXoj7i<4-u%(Ou6uZgeRw2o{Y5ocyM8f&aK151czJr# z5PcXuda##Z_jzs~#Vd`o7%0%(7F)+CB5D zb+YY&`@+mt(n0*$59t2S54e5rcow=OIFUQ8 z|M)4H9pMh!r`A8ACdj=kD~6l_33B)D{d~N>_Vq3I?HJCHu?D5q6YZ<_kRZZLI6)=z zB@*Ks5djF~tz1Y*h?!y%nQHTB%`g(1Y>XE==COZ&DEJ=ej{xv5!Pyuy^Bf)tq69$z zA3oHlKoPU{l5Qi9D8KX$Lw%)|D=JD#xKdyaUCUnL{-TYH_+cng{+5M+H3u@FuaH(D zk6~`&&BWkfDoDKPiG>|n-^FmO3A0yEJy?yq1Z+8`lJt+!jCUmHFB!B4n$TWgY>+hc zShb#eDb!Kso5Mn{n z>xTi13K{I%M@8>$1Hz{x5VQl4Z0pJ9-aa?rd6>uZysyVSvg}GFDP2aGRt;(&{wQW@ zLI;c#=6K0R7uM_{bawB~fxZdofsq(&gI<6~G*ZLs!5-=q0pu`gbtPjBw4D6UrGP=NdaNR0G;p>UCq)@rza_9=zuWpH6 z$3_r5KDNO(G&@g$sgt_)4EZQfYUYBo&B{`RQ-&v*n}-J!E&LF^8%ir1Iy>3dzCJMv z-mobj&VBIl{wFOY`Hc1@QZEed5I4|!5 zU_q0IuB%i8brW%HR67t-Nx)l;wx8c_s1=hG={963(<8!9pP-(k{%pJ4ij@(M^1Cn7 z?Gt`oQa%zd{g1n>yF7GpjYO+Nd|xsrAa9%wYasVTH+TbB#lF3JCB((+h0uz_QJoNe zXy?andl zES1;cgt36C~e++ue6j&NapwG=~A6={a{pHqRdfPH=#GADs?L} z1d)FMwgmKg+@6cjtN@HhCPOL&cVw4_Vrv)Ib%49aba%*g>4PuV4P8W9u;D|+!m*Cmday6RcmeVu;t zaBb1HMN8vjlj9@W_eXlad=C;nWx~=~sb&p2d~={I)Ly^{aAcuVJ96ZRZ!ZRVATS=z z&O?KPH{b-0ilWVY$~95Lk+7WSqwKWk%$LKj%|lu~>@Ie=Q`v5GW@=zy&bUT7`^O*M zZ&n{$7ibnTXA&M>3)j#OLk)k7>^!ShHFj_&HVq6c!uHX`%4nklhzx2;2$kSRq6V6+ zcMUvrXuFXSPB%stmJN`(1qK38n4+SWy;aYO_qCnPgzN*qbM@+bN51VPBJ%R~AZyX? z6;5{$?$G!N!yqXkfxB|EbSBVV2iUV<>@P7dgvb|d$XgKYxI6H82?(4!ckVcgcIfPt zJ9kv4YWBC_ZbqTOsEJq)#PbI`p!#Z^%Xj>zNQwrtp|<5(KUWnQih@Eavw1A(4MO2CVNcR>k$7)ZfBee!OO7?y(pcmBYh>EWF7=i$Cs zz-f$^js_IbG4|EL9O{+_6EH^NG(q9RSL0GHo^RGQ>IPk|jC5T?`WMvIg}RwjDfg|8 zTU;u8G`y3!LEB2%d{YVK(%F$secwDXPHW68)E@qD%H^wT`PaOVuddha7N4CtUmm>J zbMTfY%a8RVFlFJLy;|P!^q1ejVEK64YpYw5E@?hSbr4OfI(C zvEr?GCYfV2eFb?7Vxn*c#_EaRT)SFtri3Rcio7 zPE1T>k&AG!f`8{sH1NEGvU4OPgo=Xta4;@gw<9+u#fVapOQvgW*t)i7itfYm1a-#q zJtlGo#EF;rL+o=h$5yKrK95+;j#wukg5aNOdj4o5UoI zG#Say9d(l-sprrC(ObK?^QI=CAl!VDGtN%D#%C77SMZhuy&diY3RP59vpgrtBCmwK>-`PlN1z4 zvItkhw*iWDzG*wzN&~E4G_B;qg{Ho~kdg{lCth3X-|MU|pZ;OcC+kpEe(~aimXeZssKC&81LX!L2Fiqwi&La}aFQF9lgAp1;1Q@n8S(lCFV)0mKd9tK;p` zdQY&dl7|*jK~i!ICK2*x_zC_fOwnRyWu@w>1|&1d2=W-aZ+m9AGP=&}L;l@4dWNEc zEZ0G1%l7R_kIc+dB2~&+YLV&&9RMbL1jqDQ>=kyq)YhqW?}T$@7gBS$x!n&Q)ap*E zK3KQUCWTi~R7z@_Cqtsa(-$vV_Ld>cGDh`caWNe+{Pr!w!PmMvyVW6^1CDDpalJcq zoSAP~Mw}z-0q%>G@BWS!R&hxoc5b}%9y$dM^N3!1{0>2^$ZpDLHt$bB5sZ(I2PLwL0ew4AGF)Vi)o+fxKMxlYmAQUh869!^FdUtl0pnaV zi{$&o*HU$LJjdR3T02XhUH@L((7mLj*f7pHf}X1{7QwvKjI_Z)olp-$oBi^ZhZbdW z#~$VLV207Z+OR*F{N_=Bub&@cj916_G0?OHpaPm*uCKj|8uwqg%d=R##82!I%B(xY9zK&?0}03Td~^ zv+qSC&_V!p1swq!d%ePyva&;90eyQRR|CKY4F0bDL4Y)&6ZaWjA$00C268yeU+&8T zIb8}4T$o)WY+gZLz8w~BctyXAkB3YSMxwKVz0xn+8eJBGeNg7`lp=p%i-AG@D!*xZ z(bcg}EcgW@tgNl!>OYg6&9p2E)&k^8fqkxlQv zLG6L*7kVy5($ArIA**Y*y5uRm)j9xbQ-bhqdLqGq0=g2f z2>jZMmKKO>+5Fb*0cr)2T3$!Ir=_E#e0r;`>~pxzK!%hw(XNVhwnZ6-H-FEbyldAE z0&aQvihKOyN3ikV!xqu=S0Z)%#fzSvnf{)W=L5|vYPC@N1lLu5=0yn zAIvq;f&?`n5bvtVHfg}pCZQ_(SyvYfxL`sd`^utx;g%Evk5oCa_TQ9$$oOQgqw18#0E=qXfW ze<|s9`sp_!&KWl^$a^>jc;g)Ihx8x<2r%{~q4T#+{-p)DG>#HEeLT}h4C-2xN&u!e zkbEzrr6ovAqHRXKfLM#=2qd;ySvE+aeO(O;E(-Wmh`Lg9jGjn*BOkyqZ*MBp3O1F< zzk8SO>V`f;H#5Z;;|{=^sJXNRjNVNyeh?5LHW#8yfJeY&jl`&yA4rbyjyaei)bvvm zz}v%jy*c)Cg^Hk>Z(Uaxj8TzfSz*9Ou&}}M7L|iK4MA)eRLcX-$j579AtBfTe#a>u z1dQ%2V_{(#+G}ch62*f&QSUdEYz(OfkebxAw66aC6O+5q$2dC|oIKf%Y@A;QEvAQc zCTFc29ON>|zeJp6d)ok`^#x`QtW0j!D?k8+KR`ev+emWF&dn9ZTTbUz>2*IkhxR!% zB&5NuPT_dt5Q63q(J%d6H=*F6B$ouA+sX`!Z`}7USn(CfC7G34#uR!O@L6sw5+>8% zWGT2%Rm_`d8BYm)7Zs)U)`=J1WaOVF0R-PxdZ$(A9=}}rgHp0ww_^rEww}XqB*r-; z2XjN5kW=>1Norgb!toLxqMHaga%5YPMP+t+IvoKiwB!Iay8|54WSNhxE0w;w2X9%9 zudw$A%Z}qKk@n7kS8*LjrMWR&<6+~COEeH=jW4v=ow+TFaAvgYSX?}&l7se=C1|I$ zH7x-F)8Ht?fapnf7}BWZme)q{qvE~?VZAe$=kQ#rsduj@BH2OFTA zQnoi#n!tbRgJR?3@l?EJ)s0wBHLujn4<}R6r@+i9K%`&5BTn5%kpKk}lUHQ%0b#2M z6)o~VoOJv0bZ%y54`i)UtPJ({x9(tUev)P+hCEN)R&rA>aL>WjFw|x4dES1kD>ji( z)O8jcl?h24pe&0jv6Mb(q53G{_rqtUnp{Dquxb{ zV(Fxkqb7;hulv9>k7yuJ`haOrNQ2Om2T^6!y}h+F&v$bsUbuSI#KvY0?P-%MMplTI zE?oXu8+}q>6DKkF{(XE9?kvY4l zTvM2x@q&fawF10B2qHJCTBC%u2TBh_jKY{RhKqtO^ERLRF=j9E4_lUc~ zpKhzWv#5@-nVZL4!xn?{7JeC3!WX#=T7?76%`L7T;>%YEkc?t5bk_knk`c0dWs94a z|0PO7UvI_>x<<2sHGw3`e2h-?>0V>? z`?5yU?>g_*Z%%CbRg#h^r@A}b$pu;gB_zr0I~yZsjW2KVT2Dr)23P{2nW1PGZUu~a z$TmHqkqdb~PG3OlyB!_BjE>S1m=EEDWIoV_U;`Qg{VD21d8~&LZd(n(lw1Z(!pK!v z!@&VduLWA4tgQGwA|-~dJ?ak|lRvR{tiWZP@fk<_g9KB6Cf*;i2Ea1meM4cbJwF%? zIS=MtD$!+oBVx7^A>f2gV5wB5En}=+%ra4LmDNONPft;9(vk$`5DAF~-QCmaJG7A1 z7so=Ic??N#$q5Pbm_mSjlDmfP>RI&UV|9l*uCg2R%T;>Lc@!yui0tTdW&Cc=xh*^M{m+pRup zgf-$hp(UW#8VFzd1M`2W)eoGc!7qDp+&S+hh+M6s%-WszCXh4)QyJL93}}mAP{r;1 zPd$FuW)yuDb@d+@yul4Ohvv4D zkEMl$WdJ%cpF@s=0j#zGE=i|=(`{$EJCx^dRR;mFLY-uqnS(iC~44Hbgk%N#z!PE{ZmGEqg%_H*acj=rNEJDV&;3@I?QM_3hZ|M z>5M2zz9xBT@>4=HKv;*tYNdx*qwu+`53&_db0$0v12~UVoZjAbT+A?=Iu+W=9^Ah_ z`tsv1Uk<)tT#9O7i^+Ru=i5qEBIEOf(sS@YFhOJ+pFVTO!_~FWLVujDV5_+o&bb$T zeGvRn4-BO9fQP_i@HFWr&_GP`5qao%;qa~xKladKe1%#$P<*6rA<@bHHXVVv0NJ6o zvT-X*$jv`~{w!Sz-zL6|U6@obT!;FJaH84S!1?!I&@Cd55YK+k5B>X{b*QG1+XugWhdauE$zP>`XFfR!e-B+a?BkY}E42)e=Kk_TtiK-o zVET<%1A?%#O6Cj0s`#u?q@mH0($F|3SyoikjAkEV8R@OX9%yV$&Z*rjDq2o}gFggu zt@PUAfoBE@kDg%t$^cF~96JcNh};eG3&BCl!e@(J)+kO(v#eb4vdM674J9jMw7{N) zFG0O%Sh9jPCf9;pJo<&9;kJr)clPP-NXf7Wl4QdxX^}$}aT~5)ED3e@#wZQCA7L#p zk)Yq|y|RmL!lPLMz|nt)aX!KJ3~?XknG^gQy^z|7G2(XxMT-7J&Cf5Oa`4gc$l19; zU58?VI5x=lbhB~$V@5W`t{)@|oIEKppi#;dLMOEbQ&Navox&B&Qz+EH2kUsPHTr zOuT;&l~}adC%i)(Ag(uU@q4LmWEq)4id>(easye}pa^R#=ui}g_9Ys)`1qvkOIg3LA#FoP7QiTdp+Ebwzg-WxdKRr zHk|q)-ND3sboS-G8@pj<1x&yupq84OE4Xqc9Exko+k?-bDk20q(fNhyn=r)mAjBVI z4zTKy`Kv$%;B)mqp&^K{$Lt?%mW;2YLatLNF1S262QWx{8XMDLE2d8R_2$`|l(IqJ zyP`}306>|A9}cu=p~rcbu^|y@7E7rFCURGp;d+s;W~Q2kCEcaut);7lGpUuYB~T>e zLQs;f@fvBCJlTA%eTK`Du04Nle3=O+2F#5EZ{DoWBm+&sp(Mu1=~82$3i zvuBpOcfWf1lBw3pJPQ$g@I_;u1OojFJhRarY7dax;w*e>8N*fl!*x^ib^&dej*h3K z01<<&R_lshDXp}tNG2K6LW@|5o3J#kTv>VfG^T)^Rr}$6_F54`t!7B205c-T#oWVh z#mZ0ZOs*8-0(G{pD5B+vEoBUeYA7GkU!l91?66{|sZ_%BmI*z{QXZ>|tV&k&C}Zmy z>&|BdD2yt;k8S|A3PUXSo_;NOV}MOyjAu=>CV35wjBxSseb-+4rmcUqg_?)c^($L` z83B!IKN6p&XEN=nWTNU1VM1d`yZ@qtgBh6vBv! zs4lu!RAeZ|dEmtjnt>bb3g_-ZiUt`g{sg2akVWMoeuhG0I$YM`L4A7Iv=@94XVAx4 z!VOE=V%Jt7gjE6Ab}9)d=uo&Ls;T*h(9-jlUtoMd;68E#k&&TH9DqLvPCPc|G|TwnjTM zJEV{5eeIgc8l@|XOd*=Q39|h8+umm;*WBh3T+GBhcjO)OzEr-kAC%!GnjYQO?YB#) zv8Pylf(KkaYqg-@;y~y`{VZA=fH-g)@bUA54_WmWj&m!pTp8B5UX)s}VHXilnBEFe zX6gJ16=YzDal%^w8P;A5#zX|(I=U_lpyS@nu+l6Cj$U}>$`izQ;K2rL6BziVuY%=sIzBz*Vc-mj)VYBLbyxxbp$A}w z5~#?xlF3QHqM%=)8rXh}BgR1{bMZnO&Smt^2x`;*`Kb)j7Vwry&BM5+Q2Uw}Zs7<$ zwc@Iz?*9)#JmzRK9%wiN{w(n4>;V8LH*E#rN9E_I?pH!%2azSpEwTyN&qqhMiJ{u z^>_arJWTn-=^wJw_#&Hd9xumAi9T05*>hNXQt<4!i)@q26tW+&qs$YP9jn10xS*%_ z`HSfHAEpFJ7>;deT=G~`PF&PN96fGvAc~C&SMJ?=1;#9E&#}mRI3vv@@qxd-=^76R zhdGwYk>YkCHCEco=d{T~HHl|kvth!3hE@pPyu3c!r zkdeAN&e`U=Bbs@*#DGRt1y6~_Iirc4ou2mg@Q66SN#JCBJOfe%hG|HRpx199)K|Ko zo+Hr!;~-$(Jz-OZNGB|J2Z91s(%L|Ml8Hn;mYi+a@C~R3Zyd%&-qow&(`FUa8x1s+ z!I6e84ZuUq;*b4mRaVj_rlz^do)$=Hvy$HF#U+~DDQHaw>u4rPVr0aW#mO9NwjxHr z;A?(iN?@{u)x{W5w{0?MMzFgAXiJoeF*`#ZE!j*5@&FGgvccggeSrkGf53(>^hO=| z2lSVvxj3Ziu9dgiB35=2i$Fk?5)rsgH*H@(dsc?<)0HdJA-4t`&6$XPb|bKG%rpU8 zw^}Lc3EdLVH$LN$;(5o{>LOpJtwzXn%j3r~nwo14qT;R-7Ouk$S9GXz-KwHaqje$s zER_1kz6%vZTj!TaMmj&(e++&^C@{qXZ```ocR%#ba3uK^$5S^YY9<>Xj_4p(Ha0xw z@$2Nm%%Sn0ZeFzqq1>cd4(3>_M58WhNs*S9S5Z_%<%rDjR@sc*evJxgMomM$Tr>F2 zD@eIA5^LD4;xll3b{lXq{9fORwkJ<~my2;?y6?b>#qFPJ@wQ;z@JJwsKef%!fs+)I z?c|{_u&)F$N0(WUN&aWhj(7PT89PM)mUy~`b8x!=-m>z{aN#MPR)`83II<5rIJ@6T zng|+9@2oPEl735JRQJT~oY=lqlBBzj^*&!+VV{#NAu=;T4Y12G=>j&T+(jkx1?b8G9{UOktvwqb#`2dE|#cyAs*zP$7X zAnNq&EMyuDtN{H1*%1WFKT4@#CKzv=M%Y0K6^0Ei_p4X;pfWG#rj68*&K&-Vp_Xd+ zR7Ly^gza6-gpQNbAh?4;pFMpu>o^d@gd#iig@2R37?FSH&Z>!ge~%(gkjRs)m?2|m zcUC#1{fShq0YM9@)VR?&Q}8)Opr|!EL2Jbw!cHpE)b8$^R1W61Cla0%WZeYz>aQ<3 zn|5gZiV1U)Xq9|RzQd&ijxH5Ml*%FR1+EI-I2uCUv3hJ`B7C@sN%B2pzc8>~_}42< zCwYNSln3rQbs(SM%@h6rfjiZ4HqSnR)R&!Md?#|UcC_>E#U>CfVAtg3Pqyv7clR#S zGTP?w{&LZ)&}9+|A=4h!WdPh^>8m;NZ$J^`oCJXx27vWsE(R=vO~|NY%tVwT;s@|2 zM-fm99V>z-pdc?;`uuYweFuu#GTQppKGoEb0Wr{^qS zFiP@xz}dgOF_bGh;TnsQvf?>!gG?29KxLQ=Ky1R%(cj;{=h*jmXn(+80%wJA=v{k# z_f{LbW{;z2OEO1!MdvyNpM?yW#mMsDwGl@GI~PXu+&bGYxK*vlT113Yul`?PGo8k+o~QA$4}&!XcYP_)yg1WfZgBOPM)fHF)F;=r9r6a{ zr%bJ=*UIzplG{d8wu+^iNE@504)=KMSc%{t(^3l&Z`Qg|#ZcQu@EFeDO#1BM3Ec(o zi^oKNBi<;;xXD$fuqz_43k~eBIX z4M_XPB-ny2TepJR(ZCV{G{2a5n}fdp{0Tt`yjUxLBDoE45^90;qLqOpmka+JwXHrL zN@I8bKwGnlaT&D8&wG1?6kV2OMsk%ges&(0=sf-F(d|r5w%e9$W-DI4k6KP#o?4V{ z9+n2QrQ9~3p)Z&_XMP#DvZFB|r2meuY*up%NR zNn7UhUy3m#Qb;d0$;F~MLVI=e$A@B%m0Up9{F*&TE3_Z~dW^5lKi&M#_>+CnCiZ4o zy-;4c6K6u@}j`8S$am~v0~9@Y0ZoM4Ur|r z8w_NDG=dWa);6{34CAsWGypekNvqWDHr>@x-nK5FgL>xE1; zTs+R18nm01#*y62%*2FRTCea4_bbLkCMG6y3n-Sj(Rt&B7@z=JZ&wbj6_i@F{@B#;@;GM=K_3tZxVsEq+rcAJ1+gd`8ki#F9IJ8WKKxa^2V{9< z)YJek?RwYA$n@UaYtAxAkr9XE|e~h3o8w%kKw_y^Ld|SuWvfcBTl6$DTsuZ z&tmbJ;Yn`BNhcNvChY#vpDGJky6*SLp1{B`MQRA{kQ4u~Cf4}{KBAvLe-D#^9S@hV&gbA zi(lHfY*(O&#uXl~)&jw!6|X4=?Mv3l8OCn3+TnTJ?H91M55bSQI36I)nBT~?;)LCE zYo(TgnUH$jS9l_~T?yiUc6Rhf>N{TbxfTr-o!Ds4)V&5wkfGuA{hB~=uEY8~voiOA z?#~fXhR@WINStzasddzOMZsN3AY%Wb&WfPl`JJ(Jh?Mg1C-SjMCggel(gF;=M;o8{ zxMt`{s==O>j+JFdM{QI)R;-|fZT`ZITgJn7`Ks0(;_ zl9&6uJ?QC)=>};$qCg5=T%bmQoW8#0*qStIYS*$_`-P2znaPVX#R`r4nbPC+ zANzjOE|YYIo)=%dJPN%TR6q(}B$hLVOjJ;pj;`@W#IAq-$E|}jc@Gr3?G~~q^D&|H zaYOWZ9X8(+{6vkdH&h=Z)l)`brrf^lnabnIG0l6S-blulsT6fx;&U z%P3>zur*V|f2nEj2=R;WaHI6!b&1$3DDAQ*#cqp&#=e;)_sP6odZF0O7-Nwfc1sIn zH5QV#?WG#RZ$mNgTPx;L8Tl5ov~$_ZCWaBD70gGoX(0^cAha5TAN7&c-SEyIXCmU- z)w`<}gm8004uUEboa_<@eWoAC%z3&~ON(>0c)IqxA5Jv*I#^G4cT1m?`V})-O+&8p zI{?UQHL<~kCr+54 z69m_VHE379HeYC@!SRiKt(gC*nB0xqx3NrK^tR;Q7E}sAaei&PWS^tnS15%*hz<4Y z2*2k)eFl*wYDKI8 z>i+$sSn5Qk!|DeYY@Pv9Q*ZOBHYu`1JyHh(f&74*B)4j5*5a%CpaX=75xg_Nj#622 z-K5(2YH2?{=^M_6u6A7JmZ}IxUXawb?b~7U$H|PT4@Zwu_VH$yt9xn(ux_641<{2` z5efNFa)Z94BaqDnLLLqP^n;N3`kM2`p-V!N*WAnuc8MVw9-B@i*OWspuBDaR@g82# zcsv93ukKY> zhTQ?5;QtP^>4dhb1$_}9oM5Xb&jEkK0u1Etfaw5Lh^U3B?+YDTKfUp9agMs&tb}Jv zLSio#{mzS!Gp(eld)1&m_!qe$*W0K->eAJJ=*lcpS^yr7$Z|3+Lx{og#%*c$V1YPNQ)exAoo4woxppuv5JEq)iz5~=-TmP$5(2?IqAaiAh8 z^!rzL2Y&NE|Gm7d6(2J9LmZg{&$fgJaKIxuwXC^&tk>#)abx;{!5EGzn4(#8L zmi?@f`y=E%&4(R>2o2K#5}M+iac4&ZOTB%3=cPn)D954YGo{Cqly6xq7u!%kzUg0I zWQ#RpnNWj3`9vG(ggSt`4l_6OHi)!2O)f$whn!!_i^jSyO1jy{S1#XGSs_@81f^RU z`V48(Zxw zS`&F{GuF{Df$7PYx(oz1WFK#Dv6CASyBJ)79mq(zP}sOp+%fFoJO7v7fzHk%ub;HG zPR-1STfXY*;;8*}5ET&vC|*0pVcs}MYt+=$0a&~8N~E`f!+>B`frQ{5>{03N>iUj8 z1bIXXq;zr-mi}P*7#29={dsJ?j~#VH1a9)wfHSay62xA8WDjCYShXiC?c6!p^i~DZ zD~R)8X`F0#BTF~Doq|1pCDw_T{`##4CC$r+ERgkq5YGi1E##i`=qJeDsfD=_x4R4P z^JmXou^Q#e>rKJb3~3ZXXJ%*K2SdJyD*);${|%%xRKw_&eZN8PkKum4;pi^iH zbK1c6vNOl(6-+`yh728XLACX0c4~uMbgFl%2)mT{Zs5NIu z98&8uF6v}t*!4g|c=5U&CH%B@(BmE5Nm&PR)SL}UDGra!4P%ss^h=5vJFQ`K&+q{soHEHa zrpDxg796CWVQ{*&K4+e%fFb{oyuK!Q_7k7?s$amTc%KDowTnyC8~zP{;*g=Jm&lAx z^lw9SNSi7Rfenl6b}>{+;)aUM!L`K)S-A)V9qzn1vUuX(6^jqF*A7Pomi`vcUA59w z%CI{;J!W1V4Tuzc01);6(dJG5sm+T=lDA2o*7+CI^cny6hAweVOLsXTFwoRI|3b)l zy~eh;+%@QhaQJdEU{0svyOdUg ze&HR6ET=eU(X@odAyUjuvbooKmuqIKUpzc{<3z~Znkz4z>l}$nmhXY$1~gM$2l6DI zJUQ-BXeIr}hvGa48(O>#R#W^BOAkE{xiDhE>U_4Uv-%=ZEaHP(u_v<~bvbNieCPZ} zc0vc5zH7A*na_2A;*JS zxLy^FpYUi_(kX-g47i4^7nPTGz?#G2 zUmqnB^?s=r#WL!!zfndeQJ;>WrK7uUf0uT{IG%AF*=hIOULZrq&!AkZ$t31J>L2R9 z&;6OxD0chz!w`!ESPs2gPerWwm#6C57$7nTl0qCgbqXZH7qLp<&M@27-G}ZW^0B@2 zTMMZj0!i&Q%ghJ8ipniY&XgVuALmP+D=v}a19HYjB2^zlFg>1dhkNuwaa*Qtaf<#8 zOrD5Tu$F5XWe)M%`a~na!muO8>XuwpnfK^!i)WE~BrLUcb zSVIm6?2k-ZX|;tc|E{yJB=-528hp?sA|Fu!4KYm9Vmc}4yC7_?F`Zqpy@bfey<1$&Fp+)wbli5_qqERs0FZ#l4pwGF)Ejl3 z!)OfE8+GgFTqX!vRb^$=nW)O9w45dy0;UXnQ2!aj)vQXv$WGrcTLQFoYt_^0Jig1d4&~C!t9-uM|KyP-!PQB{=Y%6 zLl)7)mEB#Zza>(iDH%hD4W9A(o)5g1LyrCa8;p7f4#;^&J~k0d**cZO#^DkX_uBTV zvAc8;ja%uZb4)$wJK6ux{yvh9!WpSE`CzpVdad$1ch>K|O%fq4monfw=DEsyLk3$md6Ukr(!L8=8-Eq5xI?(jt;m z;7|KE1z=L+AD?}~U)>K4^7EU5IGt+_?ok*n5Xbx)31mfZ<#6IIJ%n^Id3l~h0}yv6 z*lW(l_I@gu9Ih|=AU1A$MeJXS!554|#f;(GqO>=A&e0?@hGIhdcaLq$$Zs$1o|_Iu z=E{@*i|e=VE#y{hpB+91rvdBO5GkxYgRffIX> zQrSc+6y_Q!9V&9R$w4Z?V&{H|ZX})O;~?E?U;y77Z1oVE7hLz;`ItSkWc9%VhF-!N zOv-n~ZNF5o0Oq-K>sCW}ff7|}sA`~zW#2_HkdbhR=OZV*qO2@h#y~(m3*4${AY*lj z8q6&N16oQ-oR{AJ%{6OeHUF=u>;UU}vgqpe{(epD0=aO(z;v6Do?aBfj?oM4%psd> zI|rT}kRE|OeO*5%YWJ9#31^b0auX^$eM@go;@($L!FVsB;{OW>o^OQ5{2qWddxjOY zWv5<-Li_<&EETM7XC)#qcQvrh9|(ZtC3tqADj+%6Tp2o>U62LCgn~dXG+(=9t!-^> zt*v?D8|&RI__D}HhC2hbD0Mw#&-^Dt<5fYz4Z4OqlmH4NiA`$mGf%F=m>fBQbn>Ro znoyDP2WwVT*W_HW>e^5cxG8kj`|#mubh+@-Ap312$ltrHW9iHL*fR?)ndUmTkmbhK zld&5MKG}sQ@BDFwz6X9Z{N^XxILxAiwkz)}-Zfq9`rS}nGss5*q;+@a5J$eqo?T5Q z^VAigPEM&%M6J*wgGO>C2S=oD7aX{d<=zLiBbXAe>cR{CWH8Dvx~tfE%QKXlgKzdY zmr8CElaflD@9%|PU{RV#_0zq_RUpVmW=q>2$qC{m=yP8HL}ti*t8;*W0{w!N6w@N3 zCtfcG@bl+ags0LGe*w0}vH>n}k~AaCG# zBQ~02p_vJA0;9?-BtfkejSmMeotpy+@$TAe>V7^(*Gx*cqnxR`hv($zT7y#2y?U8N z#r{envv(>gkSWm*A{O;m-k}OL(~t{t9v4iWNT5_&y^}vm@H`n~fmE|tH~;jt6cFs# zIr+JEappSoX~1yMo(#|J)Po4_?{?jf0l)0J5o-pH&h?{QQP&;deuY?c5UDH)obddE ze?Y1=$``I_*oUX$l^;e%rr|6b>WAbKM|jv^T_k1?w6yR-NL~tolMx&q@cf{lIk28C zytDAr!h??F7tG_hnxsb4^XgRhF8(hBg^274+NTuf{2S+$xQ+4=3^gEt?G=6IE;obG zcOl7G4TfCkjj&#qn%}|2walkK2B|549qN#Ai@}u&K`+chXNQ8V3OF1(O@w{-TS+su zwzpHa9ANMVW&t-ebXS81Jh|Rd#w?P?IdlcSVyO!pKKYj}dBM(znHPK!%ph=u<{C@j z2DXJ~0ptM=PcSx!85n7TZ2Ir`?{(~>q~gCC&Q5WIx+vhgaErt_gU-VWHt0411~u7m zNSPD>+kjf~8&=>#af#~{2D}ZE4MJ@&1`nA7Q%9P*sfkH{rJpMnGHq$Gbx9IEP8r%s zJ$?TNn0|9FDCLE2(FP7rVVe*(?wDZV*+9Z& zWF*Z1U|nSS;bj+bO3Gh?3=FF!3x>jrJT?KcKnasxieIZQ%)U^&G`9qh6SFj28G~yn z71zW@@ZPbf2t61qlMs$kBPx4)vsOl(OulVTrXw}t5c2_BKQeMbS;&b2)dRR1w)If) z%f}CiiCZXY)?BZ~_d1l`Ao{lhxhLDd}?<6dZb!{L!2x^A7 zxw=L#6<}U2P_`KJE6pgji1gaD2k^oU6{YygA04m8M^ke38+2B)jP+e^-WGSoYG->) z-!L@uXd%EOKA3QT1O^`h{8&`%1viTmHjWL$;p4%p=dki{WxR$3SC@zRSE_{5&c(6XRH%pUDqHj@(0G_}X8=l0MrNmC z4VqvIL+vwK0=3E@jGjbC3ux^>2syO`juilfiIF#vc$6)VVN*Non2n@ZifuvlZtobacAQ_s|+X ztFO+3X4%)eso7AACpnc`^z`4opmFiA45{SqzPxkub)H5S^Wlk!T5#4-;ewl^!uRti zaq!MS@HcfDkJKOU)`!2uYT}!(;2nU50o!tKqkcmcjD^e7yML5Cd-LY{yqA2DdUcX< zt_F2s1D>L$JKUV+)3u^t6Ht?XiBN-@J(m~d+9VHUKlOLpw{L0cq0rgd^g!SIQ*3nc zj}G_9>kINXbMlU4oVIkr>q})A+qlno@-2;-uI@W&(eccQ_o8z9pP)4s zfmZ9S{FwUlkS`Z6Yk`PNq%KRO#qu}}8sXo62G8cWlFkG_y7kT~Tl&le)nH)g$FOo5 zf)z+#o;0an!4L9%<>d8W&Q6La?hkYxX?=}dMo@FY$bbY2+C339m?H5XaR~_^xYXp5 zJ+*=a`|8!;s9*K>pNBej-#&(v&*S4i@L6Nv$2A6X3zZMzEfO0*k|A4f9cN;&hNH3Z z6QpTmj8oCSyb*N_K$C_LP4j@p z6n8IbDRP;h$c(mG5ZO|Eip^hmA%(v22D(D9L%`=TVq@-uI?*NmKd5p)Se$zD&BLZp zx48VNfEuDs@C-Y10ptWRj*Z_a$JV$+H*KrkAM@ZbOX885*{P>TOUjFmrfW{z`N5a# z5Xqdj{3AyJcLVbQZk9~KeCm?Gv|cp!75rzhZ^$;!F9q9)C?n4z4&BQl@#N*~h3Rc2 z(-QiI<$}WW;!a+_aZs7`)(wejQbbI_mn;)2ud3^P`#ASwh&Dta39$JWFcZSK7aV|5+PU+x&2m% z#^&IZL^VX*YoP~Y8s81m3ygyUc#3;^w424=0$Sy@q0TJ2>A z`~mvo$w$2cUi{??Amk-%yB?Is8PCNGFo5b}6^AKTriaFvBRiShG1hc5_L~vZC4sU$ za}cW{XcDeskR=l7Alfl};pw?nRmHEVo*7oB;0<$jrJTpoT5NWPgZ*B>N1oSEzEIO- zAnBQ6MNAOxY#@=majkB*(3Zk+RzzvhNKrXW%9JuWO$Y1*M=%lLQ}dnvOD4GpbsS(L zx)6)fj4HzjrdXWEN zr4B!v86-Z~-U>l-k%g4riCPT*_8x%f)7@pr|B#{oEwJV|; z<_9JxeW6>cjzIMtIQH{E*al2(1lAixn>_&e^7!%gFR5rnhu0u8jmku6Zx`bf63PQ# zcv{jKg#+D*nH~x@)sh{GkwzlOVtQ`w;SLHrhzHQOVH+Ti#Yd~8q5sx$1Z4;XoSfn9 z?p_f(chK;%-x@1BgHh3P8;n2T77)AtI%aM&*6h@`f#}M;9-+xW5G*6x40Nru!*hqn z62cHY*qGhaY+8fcmD@b~ z>6ifCF1ETb)*OKc3hj7j8DlX5y|MOUJ}U{x3bwX)h`N;su%@{taCY7h>^8)?^Ppvr*QT0z(lo}~Syx zmnci_KogJ`c% z;{km}gaScTIy7pWRJiu5E^E@_x<*8!Rq}Cieg#krrjw394&jld#iJ-Gi{WpFhPt3m zfAPY|TrGd^6^l-(6YY^G&ftR3!d0SU3r(h>* ze2bz1lZS1}xVp1&k~{XA;^~}E_-)yi_;`hrzn~xi4_QhI8&L;G3O4VlJk1Snu{cZ4 zmAq6SpAco?$#J4JwWV%(LgasUU^gsP=~DrDf>$#{d4Pg@!o@}J)7l^}8p247v)r~> zf5gt02~Q+J+~t5ViNJWsEJz(h8b|>;Io@t=-Pq2zYSqKNWe@@{qotYIE-CDhj3LvB zWySvqs2t-ey>yAT@0<3ygD3*9Hof_$P{GX?ii$YiQaJk_P|l~cN21lhCMAT&H3C*f z2;m~sWK1>z<#Jf!5~j6BmIrIo8h9$dApS9-Oe%Az<%vN?MBGftwUzV~TYxH>IIw^M zU^xSB31r5cnz3TK-)XkBE4}=^kkTsi#Dvl1CmGqflRb>%QX^T}=}z_~pMqKt$3KS7 zG^4{XtKf%GGXR|~)YHYES^1aAIkD=jlaCJ@G4}D}T9t;ah3aZ*b?cq`j#^0fjo^$# ziWK}SuiM&I5LAag1UgFQD5bztvi2M7zK}Qy#s-cJ7*R2o;kghBo1|tHK@o?Ub(O5G zPUzvLD-7$8_MBdd)e|8IN0Sf#BYZ6qVGcPKVSl2X22uv_e~>1+A>bXNEKsL$pQmLT z6ufbGVTf3ldj{tS)#tf*yEu^!7^1W0rOQ1!24*{UtQQp>2HXWvV<=X*;$i>LTCj$H zT(Z5R`@K+6dWxu(C}mo?fHR4?WMko_X5nQCG+RG&VUZo?>%XV#afMIk78HosYwIPX zi~y*mf|PG;d=b?f`g6%=;+X!~;I~A?o4T@Hy#{y6I4*md7l>WC_TR#U8Bf2W&{s07x*b{=SW4Er1 z?9M(v7R+e4W$hNM1C8lpGc-rG+X1b`*esV|IIxX7C3cA(fPG-BixB8JMrX#SB#zM z8tiV?VN=p8V6SPhG#5>xz!wTeM*I$QXRX)Q#GMZQj0H?$F9kD4y)yY9WA@cApe6_- zs-@iSYSsA?EoCl4fZkhF6tg*>-;Y_B=h51o?m^xlT)eSVVu>hlzP(LiF3a+n58B_P z>XD7v#$zD~loG^$F4Rbxb75bg=^vq+^q!SJemAUk^8JzOsK@Ub4!!SmHLBh{ogKDS zaa7`zcrY7%bOFi?;)7~65G07>3}sl6r2h<2391kM<{2L2Wwo><2s5T-;vie@5WDhg z#F7}-5$G<_F~bkxaaWiT&7fXn!}=p|Y;1YUbZl{<^w|f>Hy!!3@eB{kFu~4PALLI=dmg&~LLc1nMarVKdUfzHxdw8s&Nkt1nU5|-XW9D242*K%7 z@azM|(Y<9a5dnl^CCkIor~qgXxK7tgVQ*^g_{*2yVfe(q143WeWxIR#&!I*JbFRjr z$-26T9+TkZ|7g?5?fjNUwX#DMW-!q!tXxNpf9zPOc46VP~oOR~pedgl*Br%X=gMH=O3cILjQ9#nr&8&T^O=oFfj-0^95aH|U)89q*Hmv~WI1w-<8xVq&<^IHb_= zjnoL-YU5sZuASImy5mU6%IA^3YM9n*`>Wz(&)5VpRw8VV$!r~vRwO^1K zHC1=@EL>sJ%1e3w9m*jyt^kBX&)zo83{S2#c01LmvSk;@vxUjeh+aq_{L3mn(Yp zyr-x16*uvL=|Kj8FJZZo@8>zG|0^ORn)+h|@st*S2w$l@`FMl)7v;q7@3^ph?9ZRk zDaMK~g7BnK2WdnQMl79DH27~FyNG}N6^k^M$E&aKGc%r`e&aSnQ-f=IPEr34zYI23 diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/docs/assets/rustdoc-include-katex-header.html b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/docs/assets/rustdoc-include-katex-header.html deleted file mode 100644 index d240432aa173..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/docs/assets/rustdoc-include-katex-header.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/batch.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/batch.rs deleted file mode 100644 index ed2618d6cb7a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/batch.rs +++ /dev/null @@ -1,242 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2017-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -//! Batch signature verification. - -use alloc::vec::Vec; - -use core::convert::TryFrom; -use core::iter::once; - -use curve25519_dalek::constants; -use curve25519_dalek::edwards::EdwardsPoint; -use curve25519_dalek::scalar::Scalar; -use curve25519_dalek::traits::IsIdentity; -use curve25519_dalek::traits::VartimeMultiscalarMul; - -pub use curve25519_dalek::digest::Digest; - -use merlin::Transcript; - -use rand_core::RngCore; - -use sha2::Sha512; - -use crate::errors::InternalError; -use crate::errors::SignatureError; -use crate::signature::InternalSignature; -use crate::VerifyingKey; - -/// An implementation of `rand_core::RngCore` which does nothing. This is necessary because merlin -/// demands an `Rng` as input to `TranscriptRngBuilder::finalize()`. Using this with `finalize()` -/// yields a PRG whose input is the hashed transcript. -struct ZeroRng; - -impl rand_core::RngCore for ZeroRng { - fn next_u32(&mut self) -> u32 { - rand_core::impls::next_u32_via_fill(self) - } - - fn next_u64(&mut self) -> u64 { - rand_core::impls::next_u64_via_fill(self) - } - - /// A no-op function which leaves the destination bytes for randomness unchanged. - /// - /// In this case, the internal merlin code is initialising the destination - /// by doing `[0u8; …]`, which means that when we call - /// `merlin::TranscriptRngBuilder.finalize()`, rather than rekeying the - /// STROBE state based on external randomness, we're doing an - /// `ENC_{state}(00000000000000000000000000000000)` operation, which is - /// identical to the STROBE `MAC` operation. - fn fill_bytes(&mut self, _dest: &mut [u8]) {} - - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { - self.fill_bytes(dest); - Ok(()) - } -} - -// `TranscriptRngBuilder::finalize()` requires a `CryptoRng` -impl rand_core::CryptoRng for ZeroRng {} - -// We write our own gen() function so we don't need to pull in the rand crate -fn gen_u128(rng: &mut R) -> u128 { - let mut buf = [0u8; 16]; - rng.fill_bytes(&mut buf); - u128::from_le_bytes(buf) -} - -/// Verify a batch of `signatures` on `messages` with their respective `verifying_keys`. -/// -/// # Inputs -/// -/// * `messages` is a slice of byte slices, one per signed message. -/// * `signatures` is a slice of `Signature`s. -/// * `verifying_keys` is a slice of `VerifyingKey`s. -/// -/// # Returns -/// -/// * A `Result` whose `Ok` value is an empty tuple and whose `Err` value is a -/// `SignatureError` containing a description of the internal error which -/// occurred. -/// -/// ## On Deterministic Nonces -/// -/// The nonces for batch signature verification are derived purely from the inputs to this function -/// themselves. -/// -/// In any sigma protocol it is wise to include as much context pertaining -/// to the public state in the protocol as possible, to avoid malleability -/// attacks where an adversary alters publics in an algebraic manner that -/// manages to satisfy the equations for the protocol in question. -/// -/// For ed25519 batch verification we include the following as scalars in the protocol transcript: -/// -/// * All of the computed `H(R||A||M)`s to the protocol transcript, and -/// * All of the `s` components of each signature. -/// -/// The former, while not quite as elegant as adding the `R`s, `A`s, and -/// `M`s separately, saves us a bit of context hashing since the -/// `H(R||A||M)`s need to be computed for the verification equation anyway. -/// -/// The latter prevents a malleability attack wherein an adversary, without access -/// to the signing key(s), can take any valid signature, `(s,R)`, and swap -/// `s` with `s' = -z1`. This doesn't constitute a signature forgery, merely -/// a vulnerability, as the resulting signature will not pass single -/// signature verification. (Thanks to Github users @real_or_random and -/// @jonasnick for pointing out this malleability issue.) -/// -/// # Examples -/// -/// ``` -/// use ed25519_dalek::{ -/// verify_batch, SigningKey, VerifyingKey, Signer, Signature, -/// }; -/// use rand::rngs::OsRng; -/// -/// # fn main() { -/// let mut csprng = OsRng; -/// let signing_keys: Vec<_> = (0..64).map(|_| SigningKey::generate(&mut csprng)).collect(); -/// let msg: &[u8] = b"They're good dogs Brant"; -/// let messages: Vec<_> = (0..64).map(|_| msg).collect(); -/// let signatures: Vec<_> = signing_keys.iter().map(|key| key.sign(&msg)).collect(); -/// let verifying_keys: Vec<_> = signing_keys.iter().map(|key| key.verifying_key()).collect(); -/// -/// let result = verify_batch(&messages, &signatures, &verifying_keys); -/// assert!(result.is_ok()); -/// # } -/// ``` -#[allow(non_snake_case)] -pub fn verify_batch( - messages: &[&[u8]], - signatures: &[ed25519::Signature], - verifying_keys: &[VerifyingKey], -) -> Result<(), SignatureError> { - // Return an Error if any of the vectors were not the same size as the others. - if signatures.len() != messages.len() - || signatures.len() != verifying_keys.len() - || verifying_keys.len() != messages.len() - { - return Err(InternalError::ArrayLength { - name_a: "signatures", - length_a: signatures.len(), - name_b: "messages", - length_b: messages.len(), - name_c: "verifying_keys", - length_c: verifying_keys.len(), - } - .into()); - } - - // Make a transcript which logs all inputs to this function - let mut transcript: Transcript = Transcript::new(b"ed25519 batch verification"); - - // We make one optimization in the transcript: since we will end up computing H(R || A || M) - // for each (R, A, M) triplet, we will feed _that_ into our transcript rather than each R, A, M - // individually. Since R and A are fixed-length, this modification is secure so long as SHA-512 - // is collision-resistant. - // It suffices to take `verifying_keys[i].as_bytes()` even though a `VerifyingKey` has two - // fields, and `as_bytes()` only returns the bytes of the first. This is because of an - // invariant guaranteed by `VerifyingKey`: the second field is always the (unique) - // decompression of the first. Thus, the serialized first field is a unique representation of - // the entire `VerifyingKey`. - let hrams: Vec<[u8; 64]> = (0..signatures.len()) - .map(|i| { - // Compute H(R || A || M), where - // R = sig.R - // A = verifying key - // M = msg - let mut h: Sha512 = Sha512::default(); - h.update(signatures[i].r_bytes()); - h.update(verifying_keys[i].as_bytes()); - h.update(messages[i]); - *h.finalize().as_ref() - }) - .collect(); - - // Update transcript with the hashes above. This covers verifying_keys, messages, and the R - // half of signatures - for hram in hrams.iter() { - transcript.append_message(b"hram", hram); - } - // Update transcript with the rest of the data. This covers the s half of the signatures - for sig in signatures { - transcript.append_message(b"sig.s", sig.s_bytes()); - } - - // All function inputs have now been hashed into the transcript. Finalize it and use it as - // randomness for the batch verification. - let mut rng = transcript.build_rng().finalize(&mut ZeroRng); - - // Convert all signatures to `InternalSignature` - let signatures = signatures - .iter() - .map(InternalSignature::try_from) - .collect::, _>>()?; - // Convert the H(R || A || M) values into scalars - let hrams: Vec = hrams - .iter() - .map(Scalar::from_bytes_mod_order_wide) - .collect(); - - // Select a random 128-bit scalar for each signature. - let zs: Vec = signatures - .iter() - .map(|_| Scalar::from(gen_u128(&mut rng))) - .collect(); - - // Compute the basepoint coefficient, ∑ s[i]z[i] (mod l) - let B_coefficient: Scalar = signatures - .iter() - .map(|sig| sig.s) - .zip(zs.iter()) - .map(|(s, z)| z * s) - .sum(); - - // Multiply each H(R || A || M) by the random value - let zhrams = hrams.iter().zip(zs.iter()).map(|(hram, z)| hram * z); - - let Rs = signatures.iter().map(|sig| sig.R.decompress()); - let As = verifying_keys.iter().map(|pk| Some(pk.point)); - let B = once(Some(constants::ED25519_BASEPOINT_POINT)); - - // Compute (-∑ z[i]s[i] (mod l)) B + ∑ z[i]R[i] + ∑ (z[i]H(R||A||M)[i] (mod l)) A[i] = 0 - let id = EdwardsPoint::optional_multiscalar_mul( - once(-B_coefficient).chain(zs.iter().cloned()).chain(zhrams), - B.chain(Rs).chain(As), - ) - .ok_or(InternalError::Verify)?; - - if id.is_identity() { - Ok(()) - } else { - Err(InternalError::Verify.into()) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/constants.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/constants.rs deleted file mode 100644 index 4dc48a04bfc3..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/constants.rs +++ /dev/null @@ -1,32 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2017-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -//! Common constants such as buffer sizes for keypairs and signatures. - -/// The length of a ed25519 `Signature`, in bytes. -pub const SIGNATURE_LENGTH: usize = 64; - -/// The length of a ed25519 `SecretKey`, in bytes. -pub const SECRET_KEY_LENGTH: usize = 32; - -/// The length of an ed25519 `PublicKey`, in bytes. -pub const PUBLIC_KEY_LENGTH: usize = 32; - -/// The length of an ed25519 `Keypair`, in bytes. -pub const KEYPAIR_LENGTH: usize = SECRET_KEY_LENGTH + PUBLIC_KEY_LENGTH; - -/// The length of the "key" portion of an "expanded" ed25519 secret key, in bytes. -const EXPANDED_SECRET_KEY_KEY_LENGTH: usize = 32; - -/// The length of the "nonce" portion of an "expanded" ed25519 secret key, in bytes. -const EXPANDED_SECRET_KEY_NONCE_LENGTH: usize = 32; - -/// The length of an "expanded" ed25519 key, `ExpandedSecretKey`, in bytes. -pub const EXPANDED_SECRET_KEY_LENGTH: usize = - EXPANDED_SECRET_KEY_KEY_LENGTH + EXPANDED_SECRET_KEY_NONCE_LENGTH; diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/context.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/context.rs deleted file mode 100644 index 2a27edd9d69e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/context.rs +++ /dev/null @@ -1,112 +0,0 @@ -use crate::{InternalError, SignatureError}; - -/// Ed25519 contexts as used by Ed25519ph. -/// -/// Contexts are domain separator strings that can be used to isolate uses of -/// the algorithm between different protocols (which is very hard to reliably do -/// otherwise) and between different uses within the same protocol. -/// -/// To create a context, call either of the following: -/// -/// - [`SigningKey::with_context`](crate::SigningKey::with_context) -/// - [`VerifyingKey::with_context`](crate::VerifyingKey::with_context) -/// -/// For more information, see [RFC8032 § 8.3](https://www.rfc-editor.org/rfc/rfc8032#section-8.3). -/// -/// # Example -/// -#[cfg_attr(all(feature = "digest", feature = "rand_core"), doc = "```")] -#[cfg_attr( - any(not(feature = "digest"), not(feature = "rand_core")), - doc = "```ignore" -)] -/// # fn main() { -/// use ed25519_dalek::{Signature, SigningKey, VerifyingKey, Sha512}; -/// # use curve25519_dalek::digest::Digest; -/// # use rand::rngs::OsRng; -/// use ed25519_dalek::{DigestSigner, DigestVerifier}; -/// -/// # let mut csprng = OsRng; -/// # let signing_key = SigningKey::generate(&mut csprng); -/// # let verifying_key = signing_key.verifying_key(); -/// let context_str = b"Local Channel 3"; -/// let prehashed_message = Sha512::default().chain_update(b"Stay tuned for more news at 7"); -/// -/// // Signer -/// let signing_context = signing_key.with_context(context_str).unwrap(); -/// let signature = signing_context.sign_digest(prehashed_message.clone()); -/// -/// // Verifier -/// let verifying_context = verifying_key.with_context(context_str).unwrap(); -/// let verified: bool = verifying_context -/// .verify_digest(prehashed_message, &signature) -/// .is_ok(); -/// -/// # assert!(verified); -/// # } -/// ``` -#[derive(Clone, Debug)] -pub struct Context<'k, 'v, K> { - /// Key this context is being used with. - key: &'k K, - - /// Context value: a bytestring no longer than 255 octets. - value: &'v [u8], -} - -impl<'k, 'v, K> Context<'k, 'v, K> { - /// Maximum length of the context value in octets. - pub const MAX_LENGTH: usize = 255; - - /// Create a new Ed25519ph context. - pub(crate) fn new(key: &'k K, value: &'v [u8]) -> Result { - if value.len() <= Self::MAX_LENGTH { - Ok(Self { key, value }) - } else { - Err(SignatureError::from(InternalError::PrehashedContextLength)) - } - } - - /// Borrow the key. - pub fn key(&self) -> &'k K { - self.key - } - - /// Borrow the context string value. - pub fn value(&self) -> &'v [u8] { - self.value - } -} - -#[cfg(all(test, feature = "digest"))] -mod test { - #![allow(clippy::unwrap_used)] - - use crate::{Signature, SigningKey, VerifyingKey}; - use curve25519_dalek::digest::Digest; - use ed25519::signature::{DigestSigner, DigestVerifier}; - use rand::rngs::OsRng; - use sha2::Sha512; - - #[test] - fn context_correctness() { - let mut csprng = OsRng; - let signing_key: SigningKey = SigningKey::generate(&mut csprng); - let verifying_key: VerifyingKey = signing_key.verifying_key(); - - let context_str = b"Local Channel 3"; - let prehashed_message = Sha512::default().chain_update(b"Stay tuned for more news at 7"); - - // Signer - let signing_context = signing_key.with_context(context_str).unwrap(); - let signature: Signature = signing_context.sign_digest(prehashed_message.clone()); - - // Verifier - let verifying_context = verifying_key.with_context(context_str).unwrap(); - let verified: bool = verifying_context - .verify_digest(prehashed_message, &signature) - .is_ok(); - - assert!(verified); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/errors.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/errors.rs deleted file mode 100644 index 7cba06db5c9b..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/errors.rs +++ /dev/null @@ -1,119 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2017-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -//! Errors which may occur when parsing keys and/or signatures to or from wire formats. - -// rustc seems to think the typenames in match statements (e.g. in -// Display) should be snake cased, for some reason. -#![allow(non_snake_case)] - -use core::fmt; -use core::fmt::Display; - -#[cfg(feature = "std")] -use std::error::Error; - -/// Internal errors. Most application-level developers will likely not -/// need to pay any attention to these. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] -pub(crate) enum InternalError { - PointDecompression, - ScalarFormat, - /// An error in the length of bytes handed to a constructor. - /// - /// To use this, pass a string specifying the `name` of the type which is - /// returning the error, and the `length` in bytes which its constructor - /// expects. - BytesLength { - name: &'static str, - length: usize, - }, - /// The verification equation wasn't satisfied - Verify, - /// Two arrays did not match in size, making the called signature - /// verification method impossible. - #[cfg(feature = "batch")] - ArrayLength { - name_a: &'static str, - length_a: usize, - name_b: &'static str, - length_b: usize, - name_c: &'static str, - length_c: usize, - }, - /// An ed25519ph signature can only take up to 255 octets of context. - #[cfg(feature = "digest")] - PrehashedContextLength, - /// A mismatched (public, secret) key pair. - MismatchedKeypair, -} - -impl Display for InternalError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self { - InternalError::PointDecompression => write!(f, "Cannot decompress Edwards point"), - InternalError::ScalarFormat => write!(f, "Cannot use scalar with high-bit set"), - InternalError::BytesLength { name: n, length: l } => { - write!(f, "{} must be {} bytes in length", n, l) - } - InternalError::Verify => write!(f, "Verification equation was not satisfied"), - #[cfg(feature = "batch")] - InternalError::ArrayLength { - name_a: na, - length_a: la, - name_b: nb, - length_b: lb, - name_c: nc, - length_c: lc, - } => write!( - f, - "Arrays must be the same length: {} has length {}, - {} has length {}, {} has length {}.", - na, la, nb, lb, nc, lc - ), - #[cfg(feature = "digest")] - InternalError::PrehashedContextLength => write!( - f, - "An ed25519ph signature can only take up to 255 octets of context" - ), - InternalError::MismatchedKeypair => write!(f, "Mismatched Keypair detected"), - } - } -} - -#[cfg(feature = "std")] -impl Error for InternalError {} - -/// Errors which may occur while processing signatures and keypairs. -/// -/// This error may arise due to: -/// -/// * Being given bytes with a length different to what was expected. -/// -/// * A problem decompressing `r`, a curve point, in the `Signature`, or the -/// curve point for a `PublicKey`. -/// -/// * A problem with the format of `s`, a scalar, in the `Signature`. This -/// is only raised if the high-bit of the scalar was set. (Scalars must -/// only be constructed from 255-bit integers.) -/// -/// * Failure of a signature to satisfy the verification equation. -pub type SignatureError = ed25519::signature::Error; - -impl From for SignatureError { - #[cfg(not(feature = "std"))] - fn from(_err: InternalError) -> SignatureError { - SignatureError::new() - } - - #[cfg(feature = "std")] - fn from(err: InternalError) -> SignatureError { - SignatureError::from_source(err) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/hazmat.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/hazmat.rs deleted file mode 100644 index 784961304251..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/hazmat.rs +++ /dev/null @@ -1,266 +0,0 @@ -//! Low-level interfaces to ed25519 functions -//! -//! # ⚠️ Warning: Hazmat -//! -//! These primitives are easy-to-misuse low-level interfaces. -//! -//! If you are an end user / non-expert in cryptography, **do not use any of these functions**. -//! Failure to use them correctly can lead to catastrophic failures including **full private key -//! recovery.** - -// Permit dead code because 1) this module is only public when the `hazmat` feature is set, and 2) -// even without `hazmat` we still need this module because this is where `ExpandedSecretKey` is -// defined. -#![allow(dead_code)] - -use crate::{InternalError, SignatureError}; - -use curve25519_dalek::scalar::{clamp_integer, Scalar}; - -#[cfg(feature = "zeroize")] -use zeroize::{Zeroize, ZeroizeOnDrop}; - -// These are used in the functions that are made public when the hazmat feature is set -use crate::{Signature, VerifyingKey}; -use curve25519_dalek::digest::{generic_array::typenum::U64, Digest}; - -/// Contains the secret scalar and domain separator used for generating signatures. -/// -/// This is used internally for signing. -/// -/// In the usual Ed25519 signing algorithm, `scalar` and `hash_prefix` are defined such that -/// `scalar || hash_prefix = H(sk)` where `sk` is the signing key and `H` is SHA-512. -/// **WARNING:** Deriving the values for these fields in any other way can lead to full key -/// recovery, as documented in [`raw_sign`] and [`raw_sign_prehashed`]. -/// -/// Instances of this secret are automatically overwritten with zeroes when they fall out of scope. -pub struct ExpandedSecretKey { - /// The secret scalar used for signing - pub scalar: Scalar, - /// The domain separator used when hashing the message to generate the pseudorandom `r` value - pub hash_prefix: [u8; 32], -} - -#[cfg(feature = "zeroize")] -impl Drop for ExpandedSecretKey { - fn drop(&mut self) { - self.scalar.zeroize(); - self.hash_prefix.zeroize() - } -} - -#[cfg(feature = "zeroize")] -impl ZeroizeOnDrop for ExpandedSecretKey {} - -// Some conversion methods for `ExpandedSecretKey`. The signing methods are defined in -// `signing.rs`, since we need them even when `not(feature = "hazmat")` -impl ExpandedSecretKey { - /// Construct an `ExpandedSecretKey` from an array of 64 bytes. In the spec, the bytes are the - /// output of a SHA-512 hash. This clamps the first 32 bytes and uses it as a scalar, and uses - /// the second 32 bytes as a domain separator for hashing. - pub fn from_bytes(bytes: &[u8; 64]) -> Self { - // TODO: Use bytes.split_array_ref once it’s in MSRV. - let mut scalar_bytes: [u8; 32] = [0u8; 32]; - let mut hash_prefix: [u8; 32] = [0u8; 32]; - scalar_bytes.copy_from_slice(&bytes[00..32]); - hash_prefix.copy_from_slice(&bytes[32..64]); - - // For signing, we'll need the integer, clamped, and converted to a Scalar. See - // PureEdDSA.keygen in RFC 8032 Appendix A. - let scalar = Scalar::from_bytes_mod_order(clamp_integer(scalar_bytes)); - - ExpandedSecretKey { - scalar, - hash_prefix, - } - } - - /// Construct an `ExpandedSecretKey` from a slice of 64 bytes. - /// - /// # Returns - /// - /// A `Result` whose okay value is an EdDSA `ExpandedSecretKey` or whose error value is an - /// `SignatureError` describing the error that occurred, namely that the given slice's length - /// is not 64. - pub fn from_slice(bytes: &[u8]) -> Result { - // Try to coerce bytes to a [u8; 64] - bytes.try_into().map(Self::from_bytes).map_err(|_| { - InternalError::BytesLength { - name: "ExpandedSecretKey", - length: 64, - } - .into() - }) - } -} - -impl TryFrom<&[u8]> for ExpandedSecretKey { - type Error = SignatureError; - - fn try_from(bytes: &[u8]) -> Result { - Self::from_slice(bytes) - } -} - -/// Compute an ordinary Ed25519 signature over the given message. `CtxDigest` is the digest used to -/// calculate the pseudorandomness needed for signing. According to the Ed25519 spec, `CtxDigest = -/// Sha512`. -/// -/// # ⚠️ Unsafe -/// -/// Do NOT use this function unless you absolutely must. Using the wrong values in -/// `ExpandedSecretKey` can leak your signing key. See -/// [here](https://github.com/MystenLabs/ed25519-unsafe-libs) for more details on this attack. -pub fn raw_sign( - esk: &ExpandedSecretKey, - message: &[u8], - verifying_key: &VerifyingKey, -) -> Signature -where - CtxDigest: Digest, -{ - esk.raw_sign::(message, verifying_key) -} - -/// Compute a signature over the given prehashed message, the Ed25519ph algorithm defined in -/// [RFC8032 §5.1][rfc8032]. `MsgDigest` is the digest function used to hash the signed message. -/// `CtxDigest` is the digest function used to calculate the pseudorandomness needed for signing. -/// According to the Ed25519 spec, `MsgDigest = CtxDigest = Sha512`. -/// -/// # ⚠️ Unsafe -// -/// Do NOT use this function unless you absolutely must. Using the wrong values in -/// `ExpandedSecretKey` can leak your signing key. See -/// [here](https://github.com/MystenLabs/ed25519-unsafe-libs) for more details on this attack. -/// -/// # Inputs -/// -/// * `esk` is the [`ExpandedSecretKey`] being used for signing -/// * `prehashed_message` is an instantiated hash digest with 512-bits of -/// output which has had the message to be signed previously fed into its -/// state. -/// * `verifying_key` is a [`VerifyingKey`] which corresponds to this secret key. -/// * `context` is an optional context string, up to 255 bytes inclusive, -/// which may be used to provide additional domain separation. If not -/// set, this will default to an empty string. -/// -/// `scalar` and `hash_prefix` are usually selected such that `scalar || hash_prefix = H(sk)` where -/// `sk` is the signing key -/// -/// # Returns -/// -/// A `Result` whose `Ok` value is an Ed25519ph [`Signature`] on the -/// `prehashed_message` if the context was 255 bytes or less, otherwise -/// a `SignatureError`. -/// -/// [rfc8032]: https://tools.ietf.org/html/rfc8032#section-5.1 -#[cfg(feature = "digest")] -#[allow(non_snake_case)] -pub fn raw_sign_prehashed( - esk: &ExpandedSecretKey, - prehashed_message: MsgDigest, - verifying_key: &VerifyingKey, - context: Option<&[u8]>, -) -> Result -where - MsgDigest: Digest, - CtxDigest: Digest, -{ - esk.raw_sign_prehashed::(prehashed_message, verifying_key, context) -} - -/// The ordinary non-batched Ed25519 verification check, rejecting non-canonical R -/// values.`CtxDigest` is the digest used to calculate the pseudorandomness needed for signing. -/// According to the Ed25519 spec, `CtxDigest = Sha512`. -pub fn raw_verify( - vk: &VerifyingKey, - message: &[u8], - signature: &ed25519::Signature, -) -> Result<(), SignatureError> -where - CtxDigest: Digest, -{ - vk.raw_verify::(message, signature) -} - -/// The batched Ed25519 verification check, rejecting non-canonical R values. `MsgDigest` is the -/// digest used to hash the signed message. `CtxDigest` is the digest used to calculate the -/// pseudorandomness needed for signing. According to the Ed25519 spec, `MsgDigest = CtxDigest = -/// Sha512`. -#[cfg(feature = "digest")] -#[allow(non_snake_case)] -pub fn raw_verify_prehashed( - vk: &VerifyingKey, - prehashed_message: MsgDigest, - context: Option<&[u8]>, - signature: &ed25519::Signature, -) -> Result<(), SignatureError> -where - MsgDigest: Digest, - CtxDigest: Digest, -{ - vk.raw_verify_prehashed::(prehashed_message, context, signature) -} - -#[cfg(test)] -mod test { - #![allow(clippy::unwrap_used)] - - use super::*; - - use rand::{rngs::OsRng, CryptoRng, RngCore}; - - // Pick distinct, non-spec 512-bit hash functions for message and sig-context hashing - type CtxDigest = blake2::Blake2b512; - type MsgDigest = sha3::Sha3_512; - - impl ExpandedSecretKey { - // Make a random expanded secret key for testing purposes. This is NOT how you generate - // expanded secret keys IRL. They're the hash of a seed. - fn random(mut rng: R) -> Self { - let mut bytes = [0u8; 64]; - rng.fill_bytes(&mut bytes); - ExpandedSecretKey::from_bytes(&bytes) - } - } - - // Check that raw_sign and raw_verify work when a non-spec CtxDigest is used - #[test] - fn sign_verify_nonspec() { - // Generate the keypair - let rng = OsRng; - let esk = ExpandedSecretKey::random(rng); - let vk = VerifyingKey::from(&esk); - - let msg = b"Then one day, a piano fell on my head"; - - // Sign and verify - let sig = raw_sign::(&esk, msg, &vk); - raw_verify::(&vk, msg, &sig).unwrap(); - } - - // Check that raw_sign_prehashed and raw_verify_prehashed work when distinct, non-spec - // MsgDigest and CtxDigest are used - #[cfg(feature = "digest")] - #[test] - fn sign_verify_prehashed_nonspec() { - use curve25519_dalek::digest::Digest; - - // Generate the keypair - let rng = OsRng; - let esk = ExpandedSecretKey::random(rng); - let vk = VerifyingKey::from(&esk); - - // Hash the message - let msg = b"And then I got trampled by a herd of buffalo"; - let mut h = MsgDigest::new(); - h.update(msg); - - let ctx_str = &b"consequences"[..]; - - // Sign and verify prehashed - let sig = raw_sign_prehashed::(&esk, h.clone(), &vk, Some(ctx_str)) - .unwrap(); - raw_verify_prehashed::(&vk, h, Some(ctx_str), &sig).unwrap(); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/lib.rs deleted file mode 100644 index a7cfac4885ab..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/lib.rs +++ /dev/null @@ -1,293 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2017-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -//! A Rust implementation of ed25519 key generation, signing, and verification. -//! -//! # Example -//! -//! Creating an ed25519 signature on a message is simple. -//! -//! First, we need to generate a `SigningKey`, which includes both public and -//! secret halves of an asymmetric key. To do so, we need a cryptographically -//! secure pseudorandom number generator (CSPRNG). For this example, we'll use -//! the operating system's builtin PRNG: -//! -#![cfg_attr(feature = "rand_core", doc = "```")] -#![cfg_attr(not(feature = "rand_core"), doc = "```ignore")] -//! # fn main() { -//! use rand::rngs::OsRng; -//! use ed25519_dalek::SigningKey; -//! use ed25519_dalek::Signature; -//! -//! let mut csprng = OsRng; -//! let signing_key: SigningKey = SigningKey::generate(&mut csprng); -//! # } -//! ``` -//! -//! We can now use this `signing_key` to sign a message: -//! -#![cfg_attr(feature = "rand_core", doc = "```")] -#![cfg_attr(not(feature = "rand_core"), doc = "```ignore")] -//! # fn main() { -//! # use rand::rngs::OsRng; -//! # use ed25519_dalek::SigningKey; -//! # let mut csprng = OsRng; -//! # let signing_key: SigningKey = SigningKey::generate(&mut csprng); -//! use ed25519_dalek::{Signature, Signer}; -//! let message: &[u8] = b"This is a test of the tsunami alert system."; -//! let signature: Signature = signing_key.sign(message); -//! # } -//! ``` -//! -//! As well as to verify that this is, indeed, a valid signature on -//! that `message`: -//! -#![cfg_attr(feature = "rand_core", doc = "```")] -#![cfg_attr(not(feature = "rand_core"), doc = "```ignore")] -//! # fn main() { -//! # use rand::rngs::OsRng; -//! # use ed25519_dalek::{SigningKey, Signature, Signer}; -//! # let mut csprng = OsRng; -//! # let signing_key: SigningKey = SigningKey::generate(&mut csprng); -//! # let message: &[u8] = b"This is a test of the tsunami alert system."; -//! # let signature: Signature = signing_key.sign(message); -//! use ed25519_dalek::Verifier; -//! assert!(signing_key.verify(message, &signature).is_ok()); -//! # } -//! ``` -//! -//! Anyone else, given the `public` half of the `signing_key` can also easily -//! verify this signature: -//! -#![cfg_attr(feature = "rand_core", doc = "```")] -#![cfg_attr(not(feature = "rand_core"), doc = "```ignore")] -//! # fn main() { -//! # use rand::rngs::OsRng; -//! # use ed25519_dalek::SigningKey; -//! # use ed25519_dalek::Signature; -//! # use ed25519_dalek::Signer; -//! use ed25519_dalek::{VerifyingKey, Verifier}; -//! # let mut csprng = OsRng; -//! # let signing_key: SigningKey = SigningKey::generate(&mut csprng); -//! # let message: &[u8] = b"This is a test of the tsunami alert system."; -//! # let signature: Signature = signing_key.sign(message); -//! -//! let verifying_key: VerifyingKey = signing_key.verifying_key(); -//! assert!(verifying_key.verify(message, &signature).is_ok()); -//! # } -//! ``` -//! -//! ## Serialisation -//! -//! `VerifyingKey`s, `SecretKey`s, `SigningKey`s, and `Signature`s can be serialised -//! into byte-arrays by calling `.to_bytes()`. It's perfectly acceptable and -//! safe to transfer and/or store those bytes. (Of course, never transfer your -//! secret key to anyone else, since they will only need the public key to -//! verify your signatures!) -//! -#![cfg_attr(feature = "rand_core", doc = "```")] -#![cfg_attr(not(feature = "rand_core"), doc = "```ignore")] -//! # fn main() { -//! # use rand::rngs::OsRng; -//! # use ed25519_dalek::{SigningKey, Signature, Signer, VerifyingKey}; -//! use ed25519_dalek::{PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, KEYPAIR_LENGTH, SIGNATURE_LENGTH}; -//! # let mut csprng = OsRng; -//! # let signing_key: SigningKey = SigningKey::generate(&mut csprng); -//! # let message: &[u8] = b"This is a test of the tsunami alert system."; -//! # let signature: Signature = signing_key.sign(message); -//! -//! let verifying_key_bytes: [u8; PUBLIC_KEY_LENGTH] = signing_key.verifying_key().to_bytes(); -//! let secret_key_bytes: [u8; SECRET_KEY_LENGTH] = signing_key.to_bytes(); -//! let signing_key_bytes: [u8; KEYPAIR_LENGTH] = signing_key.to_keypair_bytes(); -//! let signature_bytes: [u8; SIGNATURE_LENGTH] = signature.to_bytes(); -//! # } -//! ``` -//! -//! And similarly, decoded from bytes with `::from_bytes()`: -//! -#![cfg_attr(feature = "rand_core", doc = "```")] -#![cfg_attr(not(feature = "rand_core"), doc = "```ignore")] -//! # use core::convert::{TryFrom, TryInto}; -//! # use rand::rngs::OsRng; -//! # use ed25519_dalek::{SigningKey, Signature, Signer, VerifyingKey, SecretKey, SignatureError}; -//! # use ed25519_dalek::{PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, KEYPAIR_LENGTH, SIGNATURE_LENGTH}; -//! # fn do_test() -> Result<(SigningKey, VerifyingKey, Signature), SignatureError> { -//! # let mut csprng = OsRng; -//! # let signing_key_orig: SigningKey = SigningKey::generate(&mut csprng); -//! # let message: &[u8] = b"This is a test of the tsunami alert system."; -//! # let signature_orig: Signature = signing_key_orig.sign(message); -//! # let verifying_key_bytes: [u8; PUBLIC_KEY_LENGTH] = signing_key_orig.verifying_key().to_bytes(); -//! # let signing_key_bytes: [u8; SECRET_KEY_LENGTH] = signing_key_orig.to_bytes(); -//! # let signature_bytes: [u8; SIGNATURE_LENGTH] = signature_orig.to_bytes(); -//! # -//! let verifying_key: VerifyingKey = VerifyingKey::from_bytes(&verifying_key_bytes)?; -//! let signing_key: SigningKey = SigningKey::from_bytes(&signing_key_bytes); -//! let signature: Signature = Signature::try_from(&signature_bytes[..])?; -//! # -//! # Ok((signing_key, verifying_key, signature)) -//! # } -//! # fn main() { -//! # do_test(); -//! # } -//! ``` -//! -//! ### PKCS#8 Key Encoding -//! -//! PKCS#8 is a private key format with support for multiple algorithms. -//! It can be encoded as binary (DER) or text (PEM). -//! -//! You can recognize PEM-encoded PKCS#8 keys by the following: -//! -//! ```text -//! -----BEGIN PRIVATE KEY----- -//! ``` -//! -//! To use PKCS#8, you need to enable the `pkcs8` crate feature. -//! -//! The following traits can be used to decode/encode [`SigningKey`] and -//! [`VerifyingKey`] as PKCS#8. Note that [`pkcs8`] is re-exported from the -//! toplevel of the crate: -//! -//! - [`pkcs8::DecodePrivateKey`]: decode private keys from PKCS#8 -//! - [`pkcs8::EncodePrivateKey`]: encode private keys to PKCS#8 -//! - [`pkcs8::DecodePublicKey`]: decode public keys from PKCS#8 -//! - [`pkcs8::EncodePublicKey`]: encode public keys to PKCS#8 -//! -//! #### Example -//! -//! NOTE: this requires the `pem` crate feature. -//! -#![cfg_attr(feature = "pem", doc = "```")] -#![cfg_attr(not(feature = "pem"), doc = "```ignore")] -//! use ed25519_dalek::{VerifyingKey, pkcs8::DecodePublicKey}; -//! -//! let pem = "-----BEGIN PUBLIC KEY----- -//! MCowBQYDK2VwAyEAGb9ECWmEzf6FQbrBZ9w7lshQhqowtrbLDFw4rXAxZuE= -//! -----END PUBLIC KEY-----"; -//! -//! let verifying_key = VerifyingKey::from_public_key_pem(pem) -//! .expect("invalid public key PEM"); -//! ``` -//! -//! ### Using Serde -//! -//! If you prefer the bytes to be wrapped in another serialisation format, all -//! types additionally come with built-in [serde](https://serde.rs) support by -//! building `ed25519-dalek` via: -//! -//! ```bash -//! $ cargo build --features="serde" -//! ``` -//! -//! They can be then serialised into any of the wire formats which serde supports. -//! For example, using [bincode](https://github.com/TyOverby/bincode): -//! -#![cfg_attr(all(feature = "rand_core", feature = "serde"), doc = "```")] -#![cfg_attr(not(all(feature = "rand_core", feature = "serde")), doc = "```ignore")] -//! # fn main() { -//! # use rand::rngs::OsRng; -//! # use ed25519_dalek::{SigningKey, Signature, Signer, Verifier, VerifyingKey}; -//! use bincode::serialize; -//! # let mut csprng = OsRng; -//! # let signing_key: SigningKey = SigningKey::generate(&mut csprng); -//! # let message: &[u8] = b"This is a test of the tsunami alert system."; -//! # let signature: Signature = signing_key.sign(message); -//! # let verifying_key: VerifyingKey = signing_key.verifying_key(); -//! # let verified: bool = verifying_key.verify(message, &signature).is_ok(); -//! -//! let encoded_verifying_key: Vec = serialize(&verifying_key).unwrap(); -//! let encoded_signature: Vec = serialize(&signature).unwrap(); -//! # } -//! ``` -//! -//! After sending the `encoded_verifying_key` and `encoded_signature`, the -//! recipient may deserialise them and verify: -//! -#![cfg_attr(all(feature = "rand_core", feature = "serde"), doc = "```")] -#![cfg_attr(not(all(feature = "rand_core", feature = "serde")), doc = "```ignore")] -//! # fn main() { -//! # use rand::rngs::OsRng; -//! # use ed25519_dalek::{SigningKey, Signature, Signer, Verifier, VerifyingKey}; -//! # use bincode::serialize; -//! use bincode::deserialize; -//! -//! # let mut csprng = OsRng; -//! # let signing_key: SigningKey = SigningKey::generate(&mut csprng); -//! let message: &[u8] = b"This is a test of the tsunami alert system."; -//! # let signature: Signature = signing_key.sign(message); -//! # let verifying_key: VerifyingKey = signing_key.verifying_key(); -//! # let verified: bool = verifying_key.verify(message, &signature).is_ok(); -//! # let encoded_verifying_key: Vec = serialize(&verifying_key).unwrap(); -//! # let encoded_signature: Vec = serialize(&signature).unwrap(); -//! let decoded_verifying_key: VerifyingKey = deserialize(&encoded_verifying_key).unwrap(); -//! let decoded_signature: Signature = deserialize(&encoded_signature).unwrap(); -//! -//! # assert_eq!(verifying_key, decoded_verifying_key); -//! # assert_eq!(signature, decoded_signature); -//! # -//! let verified: bool = decoded_verifying_key.verify(&message, &decoded_signature).is_ok(); -//! -//! assert!(verified); -//! # } -//! ``` - -#![no_std] -#![warn(future_incompatible, rust_2018_idioms)] -#![deny(missing_docs)] // refuse to compile if documentation is missing -#![deny(clippy::unwrap_used)] // don't allow unwrap -#![cfg_attr(not(test), forbid(unsafe_code))] -#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg, doc_cfg_hide))] -#![cfg_attr(docsrs, doc(cfg_hide(docsrs)))] - -#[cfg(feature = "batch")] -extern crate alloc; - -#[cfg(any(feature = "std", test))] -#[macro_use] -extern crate std; - -pub use ed25519; - -#[cfg(feature = "batch")] -mod batch; -mod constants; -#[cfg(feature = "digest")] -mod context; -mod errors; -mod signature; -mod signing; -mod verifying; - -#[cfg(feature = "hazmat")] -pub mod hazmat; -#[cfg(not(feature = "hazmat"))] -mod hazmat; - -#[cfg(feature = "digest")] -pub use curve25519_dalek::digest::Digest; -#[cfg(feature = "digest")] -pub use sha2::Sha512; - -#[cfg(feature = "batch")] -pub use crate::batch::*; -pub use crate::constants::*; -#[cfg(feature = "digest")] -pub use crate::context::Context; -pub use crate::errors::*; -pub use crate::signing::*; -pub use crate::verifying::*; - -// Re-export the `Signer` and `Verifier` traits from the `signature` crate -#[cfg(feature = "digest")] -pub use ed25519::signature::{DigestSigner, DigestVerifier}; -pub use ed25519::signature::{Signer, Verifier}; -pub use ed25519::Signature; - -#[cfg(feature = "pkcs8")] -pub use ed25519::pkcs8; diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signature.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signature.rs deleted file mode 100644 index 36174c8d67d8..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signature.rs +++ /dev/null @@ -1,178 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2017-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -//! An ed25519 signature. - -use core::convert::TryFrom; -use core::fmt::Debug; - -use curve25519_dalek::edwards::CompressedEdwardsY; -use curve25519_dalek::scalar::Scalar; - -use crate::constants::*; -use crate::errors::*; - -/// An ed25519 signature. -/// -/// # Note -/// -/// These signatures, unlike the ed25519 signature reference implementation, are -/// "detached"—that is, they do **not** include a copy of the message which has -/// been signed. -#[allow(non_snake_case)] -#[derive(Copy, Eq, PartialEq)] -pub(crate) struct InternalSignature { - /// `R` is an `EdwardsPoint`, formed by using an hash function with - /// 512-bits output to produce the digest of: - /// - /// - the nonce half of the `ExpandedSecretKey`, and - /// - the message to be signed. - /// - /// This digest is then interpreted as a `Scalar` and reduced into an - /// element in ℤ/lℤ. The scalar is then multiplied by the distinguished - /// basepoint to produce `R`, and `EdwardsPoint`. - pub(crate) R: CompressedEdwardsY, - - /// `s` is a `Scalar`, formed by using an hash function with 512-bits output - /// to produce the digest of: - /// - /// - the `r` portion of this `Signature`, - /// - the `PublicKey` which should be used to verify this `Signature`, and - /// - the message to be signed. - /// - /// This digest is then interpreted as a `Scalar` and reduced into an - /// element in ℤ/lℤ. - pub(crate) s: Scalar, -} - -impl Clone for InternalSignature { - fn clone(&self) -> Self { - *self - } -} - -impl Debug for InternalSignature { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "Signature( R: {:?}, s: {:?} )", &self.R, &self.s) - } -} - -/// Ensures that the scalar `s` of a signature is within the bounds [0, 2^253). -/// -/// **Unsafe**: This version of `check_scalar` permits signature malleability. See README. -#[cfg(feature = "legacy_compatibility")] -#[inline(always)] -fn check_scalar(bytes: [u8; 32]) -> Result { - // The highest 3 bits must not be set. No other checking for the - // remaining 2^253 - 2^252 + 27742317777372353535851937790883648493 - // potential non-reduced scalars is performed. - // - // This is compatible with ed25519-donna and libsodium when - // -DED25519_COMPAT is NOT specified. - if bytes[31] & 224 != 0 { - return Err(InternalError::ScalarFormat.into()); - } - - // You cannot do arithmetic with scalars construct with Scalar::from_bits. We only use this - // scalar for EdwardsPoint::vartime_double_scalar_mul_basepoint, which is an accepted usecase. - // The `from_bits` method is deprecated because it's unsafe. We know this. - #[allow(deprecated)] - Ok(Scalar::from_bits(bytes)) -} - -/// Ensures that the scalar `s` of a signature is within the bounds [0, ℓ) -#[cfg(not(feature = "legacy_compatibility"))] -#[inline(always)] -fn check_scalar(bytes: [u8; 32]) -> Result { - match Scalar::from_canonical_bytes(bytes).into() { - None => Err(InternalError::ScalarFormat.into()), - Some(x) => Ok(x), - } -} - -impl InternalSignature { - /// Construct a `Signature` from a slice of bytes. - /// - /// # Scalar Malleability Checking - /// - /// As originally specified in the ed25519 paper (cf. the "Malleability" - /// section of the README in this repo), no checks whatsoever were performed - /// for signature malleability. - /// - /// Later, a semi-functional, hacky check was added to most libraries to - /// "ensure" that the scalar portion, `s`, of the signature was reduced `mod - /// \ell`, the order of the basepoint: - /// - /// ```ignore - /// if signature.s[31] & 224 != 0 { - /// return Err(); - /// } - /// ``` - /// - /// This bit-twiddling ensures that the most significant three bits of the - /// scalar are not set: - /// - /// ```python,ignore - /// >>> 0b00010000 & 224 - /// 0 - /// >>> 0b00100000 & 224 - /// 32 - /// >>> 0b01000000 & 224 - /// 64 - /// >>> 0b10000000 & 224 - /// 128 - /// ``` - /// - /// However, this check is hacky and insufficient to check that the scalar is - /// fully reduced `mod \ell = 2^252 + 27742317777372353535851937790883648493` as - /// it leaves us with a guanteed bound of 253 bits. This means that there are - /// `2^253 - 2^252 + 2774231777737235353585193779088364849311` remaining scalars - /// which could cause malleabilllity. - /// - /// RFC8032 [states](https://tools.ietf.org/html/rfc8032#section-5.1.7): - /// - /// > To verify a signature on a message M using public key A, [...] - /// > first split the signature into two 32-octet halves. Decode the first - /// > half as a point R, and the second half as an integer S, in the range - /// > 0 <= s < L. Decode the public key A as point A'. If any of the - /// > decodings fail (including S being out of range), the signature is - /// > invalid. - /// - /// However, by the time this was standardised, most libraries in use were - /// only checking the most significant three bits. (See also the - /// documentation for [`crate::VerifyingKey::verify_strict`].) - #[inline] - #[allow(non_snake_case)] - pub fn from_bytes(bytes: &[u8; SIGNATURE_LENGTH]) -> Result { - // TODO: Use bytes.split_array_ref once it’s in MSRV. - let mut R_bytes: [u8; 32] = [0u8; 32]; - let mut s_bytes: [u8; 32] = [0u8; 32]; - R_bytes.copy_from_slice(&bytes[00..32]); - s_bytes.copy_from_slice(&bytes[32..64]); - - Ok(InternalSignature { - R: CompressedEdwardsY(R_bytes), - s: check_scalar(s_bytes)?, - }) - } -} - -impl TryFrom<&ed25519::Signature> for InternalSignature { - type Error = SignatureError; - - fn try_from(sig: &ed25519::Signature) -> Result { - InternalSignature::from_bytes(&sig.to_bytes()) - } -} - -impl From for ed25519::Signature { - fn from(sig: InternalSignature) -> ed25519::Signature { - ed25519::Signature::from_components(*sig.R.as_bytes(), *sig.s.as_bytes()) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signing.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signing.rs deleted file mode 100644 index e2818fea7b92..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signing.rs +++ /dev/null @@ -1,908 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2017-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -//! ed25519 signing keys. - -use core::fmt::Debug; - -#[cfg(feature = "pkcs8")] -use ed25519::pkcs8; - -#[cfg(any(test, feature = "rand_core"))] -use rand_core::CryptoRngCore; - -#[cfg(feature = "serde")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; - -use sha2::Sha512; -use subtle::{Choice, ConstantTimeEq}; - -use curve25519_dalek::{ - digest::{generic_array::typenum::U64, Digest}, - edwards::{CompressedEdwardsY, EdwardsPoint}, - scalar::Scalar, -}; - -use ed25519::signature::{KeypairRef, Signer, Verifier}; - -#[cfg(feature = "digest")] -use crate::context::Context; -#[cfg(feature = "digest")] -use signature::DigestSigner; - -#[cfg(feature = "zeroize")] -use zeroize::{Zeroize, ZeroizeOnDrop}; - -use crate::{ - constants::{KEYPAIR_LENGTH, SECRET_KEY_LENGTH}, - errors::{InternalError, SignatureError}, - hazmat::ExpandedSecretKey, - signature::InternalSignature, - verifying::VerifyingKey, - Signature, -}; - -/// ed25519 secret key as defined in [RFC8032 § 5.1.5]: -/// -/// > The private key is 32 octets (256 bits, corresponding to b) of -/// > cryptographically secure random data. -/// -/// [RFC8032 § 5.1.5]: https://www.rfc-editor.org/rfc/rfc8032#section-5.1.5 -pub type SecretKey = [u8; SECRET_KEY_LENGTH]; - -/// ed25519 signing key which can be used to produce signatures. -// Invariant: `verifying_key` is always the public key of -// `secret_key`. This prevents the signing function oracle attack -// described in https://github.com/MystenLabs/ed25519-unsafe-libs -#[derive(Clone)] -pub struct SigningKey { - /// The secret half of this signing key. - pub(crate) secret_key: SecretKey, - /// The public half of this signing key. - pub(crate) verifying_key: VerifyingKey, -} - -/// # Example -/// -/// ``` -/// # extern crate ed25519_dalek; -/// # -/// use ed25519_dalek::SigningKey; -/// use ed25519_dalek::SECRET_KEY_LENGTH; -/// use ed25519_dalek::SignatureError; -/// -/// # fn doctest() -> Result { -/// let secret_key_bytes: [u8; SECRET_KEY_LENGTH] = [ -/// 157, 097, 177, 157, 239, 253, 090, 096, -/// 186, 132, 074, 244, 146, 236, 044, 196, -/// 068, 073, 197, 105, 123, 050, 105, 025, -/// 112, 059, 172, 003, 028, 174, 127, 096, ]; -/// -/// let signing_key: SigningKey = SigningKey::from_bytes(&secret_key_bytes); -/// assert_eq!(signing_key.to_bytes(), secret_key_bytes); -/// -/// # Ok(signing_key) -/// # } -/// # -/// # fn main() { -/// # let result = doctest(); -/// # assert!(result.is_ok()); -/// # } -/// ``` -impl SigningKey { - /// Construct a [`SigningKey`] from a [`SecretKey`] - /// - #[inline] - pub fn from_bytes(secret_key: &SecretKey) -> Self { - let verifying_key = VerifyingKey::from(&ExpandedSecretKey::from(secret_key)); - Self { - secret_key: *secret_key, - verifying_key, - } - } - - /// Convert this [`SigningKey`] into a [`SecretKey`] - #[inline] - pub fn to_bytes(&self) -> SecretKey { - self.secret_key - } - - /// Convert this [`SigningKey`] into a [`SecretKey`] reference - #[inline] - pub fn as_bytes(&self) -> &SecretKey { - &self.secret_key - } - - /// Construct a [`SigningKey`] from the bytes of a `VerifyingKey` and `SecretKey`. - /// - /// # Inputs - /// - /// * `bytes`: an `&[u8]` of length [`KEYPAIR_LENGTH`], representing the - /// scalar for the secret key, and a compressed Edwards-Y coordinate of a - /// point on curve25519, both as bytes. (As obtained from - /// [`SigningKey::to_bytes`].) - /// - /// # Returns - /// - /// A `Result` whose okay value is an EdDSA [`SigningKey`] or whose error value - /// is an `SignatureError` describing the error that occurred. - #[inline] - pub fn from_keypair_bytes(bytes: &[u8; 64]) -> Result { - let (secret_key, verifying_key) = bytes.split_at(SECRET_KEY_LENGTH); - let signing_key = SigningKey::try_from(secret_key)?; - let verifying_key = VerifyingKey::try_from(verifying_key)?; - - if signing_key.verifying_key() != verifying_key { - return Err(InternalError::MismatchedKeypair.into()); - } - - Ok(signing_key) - } - - /// Convert this signing key to a 64-byte keypair. - /// - /// # Returns - /// - /// An array of bytes, `[u8; KEYPAIR_LENGTH]`. The first - /// `SECRET_KEY_LENGTH` of bytes is the `SecretKey`, and the next - /// `PUBLIC_KEY_LENGTH` bytes is the `VerifyingKey` (the same as other - /// libraries, such as [Adam Langley's ed25519 Golang - /// implementation](https://github.com/agl/ed25519/)). It is guaranteed that - /// the encoded public key is the one derived from the encoded secret key. - pub fn to_keypair_bytes(&self) -> [u8; KEYPAIR_LENGTH] { - let mut bytes: [u8; KEYPAIR_LENGTH] = [0u8; KEYPAIR_LENGTH]; - - bytes[..SECRET_KEY_LENGTH].copy_from_slice(&self.secret_key); - bytes[SECRET_KEY_LENGTH..].copy_from_slice(self.verifying_key.as_bytes()); - bytes - } - - /// Get the [`VerifyingKey`] for this [`SigningKey`]. - pub fn verifying_key(&self) -> VerifyingKey { - self.verifying_key - } - - /// Create a signing context that can be used for Ed25519ph with - /// [`DigestSigner`]. - #[cfg(feature = "digest")] - pub fn with_context<'k, 'v>( - &'k self, - context_value: &'v [u8], - ) -> Result, SignatureError> { - Context::new(self, context_value) - } - - /// Generate an ed25519 signing key. - /// - /// # Example - /// - #[cfg_attr(feature = "rand_core", doc = "```")] - #[cfg_attr(not(feature = "rand_core"), doc = "```ignore")] - /// # fn main() { - /// use rand::rngs::OsRng; - /// use ed25519_dalek::{Signature, SigningKey}; - /// - /// let mut csprng = OsRng; - /// let signing_key: SigningKey = SigningKey::generate(&mut csprng); - /// # } - /// ``` - /// - /// # Input - /// - /// A CSPRNG with a `fill_bytes()` method, e.g. `rand_os::OsRng`. - /// - /// The caller must also supply a hash function which implements the - /// `Digest` and `Default` traits, and which returns 512 bits of output. - /// The standard hash function used for most ed25519 libraries is SHA-512, - /// which is available with `use sha2::Sha512` as in the example above. - /// Other suitable hash functions include Keccak-512 and Blake2b-512. - #[cfg(any(test, feature = "rand_core"))] - pub fn generate(csprng: &mut R) -> SigningKey { - let mut secret = SecretKey::default(); - csprng.fill_bytes(&mut secret); - Self::from_bytes(&secret) - } - - /// Sign a `prehashed_message` with this [`SigningKey`] using the - /// Ed25519ph algorithm defined in [RFC8032 §5.1][rfc8032]. - /// - /// # Inputs - /// - /// * `prehashed_message` is an instantiated hash digest with 512-bits of - /// output which has had the message to be signed previously fed into its - /// state. - /// * `context` is an optional context string, up to 255 bytes inclusive, - /// which may be used to provide additional domain separation. If not - /// set, this will default to an empty string. - /// - /// # Returns - /// - /// An Ed25519ph [`Signature`] on the `prehashed_message`. - /// - /// # Note - /// - /// The RFC only permits SHA-512 to be used for prehashing, i.e., `MsgDigest = Sha512`. This - /// function technically works, and is probably safe to use, with any secure hash function with - /// 512-bit digests, but anything outside of SHA-512 is NOT specification-compliant. We expose - /// [`crate::Sha512`] for user convenience. - /// - /// # Examples - /// - #[cfg_attr(all(feature = "rand_core", feature = "digest"), doc = "```")] - #[cfg_attr( - any(not(feature = "rand_core"), not(feature = "digest")), - doc = "```ignore" - )] - /// use ed25519_dalek::Digest; - /// use ed25519_dalek::SigningKey; - /// use ed25519_dalek::Signature; - /// use sha2::Sha512; - /// use rand::rngs::OsRng; - /// - /// # fn main() { - /// let mut csprng = OsRng; - /// let signing_key: SigningKey = SigningKey::generate(&mut csprng); - /// let message: &[u8] = b"All I want is to pet all of the dogs."; - /// - /// // Create a hash digest object which we'll feed the message into: - /// let mut prehashed: Sha512 = Sha512::new(); - /// - /// prehashed.update(message); - /// # } - /// ``` - /// - /// If you want, you can optionally pass a "context". It is generally a - /// good idea to choose a context and try to make it unique to your project - /// and this specific usage of signatures. - /// - /// For example, without this, if you were to [convert your OpenPGP key - /// to a Bitcoin key][terrible_idea] (just as an example, and also Don't - /// Ever Do That) and someone tricked you into signing an "email" which was - /// actually a Bitcoin transaction moving all your magic internet money to - /// their address, it'd be a valid transaction. - /// - /// By adding a context, this trick becomes impossible, because the context - /// is concatenated into the hash, which is then signed. So, going with the - /// previous example, if your bitcoin wallet used a context of - /// "BitcoinWalletAppTxnSigning" and OpenPGP used a context (this is likely - /// the least of their safety problems) of "GPGsCryptoIsntConstantTimeLol", - /// then the signatures produced by both could never match the other, even - /// if they signed the exact same message with the same key. - /// - /// Let's add a context for good measure (remember, you'll want to choose - /// your own!): - /// - #[cfg_attr(all(feature = "rand_core", feature = "digest"), doc = "```")] - #[cfg_attr( - any(not(feature = "rand_core"), not(feature = "digest")), - doc = "```ignore" - )] - /// # use ed25519_dalek::Digest; - /// # use ed25519_dalek::SigningKey; - /// # use ed25519_dalek::Signature; - /// # use ed25519_dalek::SignatureError; - /// # use sha2::Sha512; - /// # use rand::rngs::OsRng; - /// # - /// # fn do_test() -> Result { - /// # let mut csprng = OsRng; - /// # let signing_key: SigningKey = SigningKey::generate(&mut csprng); - /// # let message: &[u8] = b"All I want is to pet all of the dogs."; - /// # let mut prehashed: Sha512 = Sha512::new(); - /// # prehashed.update(message); - /// # - /// let context: &[u8] = b"Ed25519DalekSignPrehashedDoctest"; - /// - /// let sig: Signature = signing_key.sign_prehashed(prehashed, Some(context))?; - /// # - /// # Ok(sig) - /// # } - /// # fn main() { - /// # do_test(); - /// # } - /// ``` - /// - /// [rfc8032]: https://tools.ietf.org/html/rfc8032#section-5.1 - /// [terrible_idea]: https://github.com/isislovecruft/scripts/blob/master/gpgkey2bc.py - #[cfg(feature = "digest")] - pub fn sign_prehashed( - &self, - prehashed_message: MsgDigest, - context: Option<&[u8]>, - ) -> Result - where - MsgDigest: Digest, - { - ExpandedSecretKey::from(&self.secret_key).raw_sign_prehashed::( - prehashed_message, - &self.verifying_key, - context, - ) - } - - /// Verify a signature on a message with this signing key's public key. - pub fn verify(&self, message: &[u8], signature: &Signature) -> Result<(), SignatureError> { - self.verifying_key.verify(message, signature) - } - - /// Verify a `signature` on a `prehashed_message` using the Ed25519ph algorithm. - /// - /// # Inputs - /// - /// * `prehashed_message` is an instantiated hash digest with 512-bits of - /// output which has had the message to be signed previously fed into its - /// state. - /// * `context` is an optional context string, up to 255 bytes inclusive, - /// which may be used to provide additional domain separation. If not - /// set, this will default to an empty string. - /// * `signature` is a purported Ed25519ph [`Signature`] on the `prehashed_message`. - /// - /// # Returns - /// - /// Returns `true` if the `signature` was a valid signature created by this - /// [`SigningKey`] on the `prehashed_message`. - /// - /// # Note - /// - /// The RFC only permits SHA-512 to be used for prehashing, i.e., `MsgDigest = Sha512`. This - /// function technically works, and is probably safe to use, with any secure hash function with - /// 512-bit digests, but anything outside of SHA-512 is NOT specification-compliant. We expose - /// [`crate::Sha512`] for user convenience. - /// - /// # Examples - /// - #[cfg_attr(all(feature = "rand_core", feature = "digest"), doc = "```")] - #[cfg_attr( - any(not(feature = "rand_core"), not(feature = "digest")), - doc = "```ignore" - )] - /// use ed25519_dalek::Digest; - /// use ed25519_dalek::SigningKey; - /// use ed25519_dalek::Signature; - /// use ed25519_dalek::SignatureError; - /// use sha2::Sha512; - /// use rand::rngs::OsRng; - /// - /// # fn do_test() -> Result<(), SignatureError> { - /// let mut csprng = OsRng; - /// let signing_key: SigningKey = SigningKey::generate(&mut csprng); - /// let message: &[u8] = b"All I want is to pet all of the dogs."; - /// - /// let mut prehashed: Sha512 = Sha512::new(); - /// prehashed.update(message); - /// - /// let context: &[u8] = b"Ed25519DalekSignPrehashedDoctest"; - /// - /// let sig: Signature = signing_key.sign_prehashed(prehashed, Some(context))?; - /// - /// // The sha2::Sha512 struct doesn't implement Copy, so we'll have to create a new one: - /// let mut prehashed_again: Sha512 = Sha512::default(); - /// prehashed_again.update(message); - /// - /// let verified = signing_key.verifying_key().verify_prehashed(prehashed_again, Some(context), &sig); - /// - /// assert!(verified.is_ok()); - /// - /// # verified - /// # } - /// # - /// # fn main() { - /// # do_test(); - /// # } - /// ``` - /// - /// [rfc8032]: https://tools.ietf.org/html/rfc8032#section-5.1 - #[cfg(feature = "digest")] - pub fn verify_prehashed( - &self, - prehashed_message: MsgDigest, - context: Option<&[u8]>, - signature: &Signature, - ) -> Result<(), SignatureError> - where - MsgDigest: Digest, - { - self.verifying_key - .verify_prehashed(prehashed_message, context, signature) - } - - /// Strictly verify a signature on a message with this signing key's public key. - /// - /// # On The (Multiple) Sources of Malleability in Ed25519 Signatures - /// - /// This version of verification is technically non-RFC8032 compliant. The - /// following explains why. - /// - /// 1. Scalar Malleability - /// - /// The authors of the RFC explicitly stated that verification of an ed25519 - /// signature must fail if the scalar `s` is not properly reduced mod \ell: - /// - /// > To verify a signature on a message M using public key A, with F - /// > being 0 for Ed25519ctx, 1 for Ed25519ph, and if Ed25519ctx or - /// > Ed25519ph is being used, C being the context, first split the - /// > signature into two 32-octet halves. Decode the first half as a - /// > point R, and the second half as an integer S, in the range - /// > 0 <= s < L. Decode the public key A as point A'. If any of the - /// > decodings fail (including S being out of range), the signature is - /// > invalid.) - /// - /// All `verify_*()` functions within ed25519-dalek perform this check. - /// - /// 2. Point malleability - /// - /// The authors of the RFC added in a malleability check to step #3 in - /// §5.1.7, for small torsion components in the `R` value of the signature, - /// *which is not strictly required*, as they state: - /// - /// > Check the group equation \[8\]\[S\]B = \[8\]R + \[8\]\[k\]A'. It's - /// > sufficient, but not required, to instead check \[S\]B = R + \[k\]A'. - /// - /// # History of Malleability Checks - /// - /// As originally defined (cf. the "Malleability" section in the README of - /// this repo), ed25519 signatures didn't consider *any* form of - /// malleability to be an issue. Later the scalar malleability was - /// considered important. Still later, particularly with interests in - /// cryptocurrency design and in unique identities (e.g. for Signal users, - /// Tor onion services, etc.), the group element malleability became a - /// concern. - /// - /// However, libraries had already been created to conform to the original - /// definition. One well-used library in particular even implemented the - /// group element malleability check, *but only for batch verification*! - /// Which meant that even using the same library, a single signature could - /// verify fine individually, but suddenly, when verifying it with a bunch - /// of other signatures, the whole batch would fail! - /// - /// # "Strict" Verification - /// - /// This method performs *both* of the above signature malleability checks. - /// - /// It must be done as a separate method because one doesn't simply get to - /// change the definition of a cryptographic primitive ten years - /// after-the-fact with zero consideration for backwards compatibility in - /// hardware and protocols which have it already have the older definition - /// baked in. - /// - /// # Return - /// - /// Returns `Ok(())` if the signature is valid, and `Err` otherwise. - #[allow(non_snake_case)] - pub fn verify_strict( - &self, - message: &[u8], - signature: &Signature, - ) -> Result<(), SignatureError> { - self.verifying_key.verify_strict(message, signature) - } - - /// Convert this signing key into a byte representation of an unreduced, unclamped Curve25519 - /// scalar. This is NOT the same thing as `self.to_scalar().to_bytes()`, since `to_scalar()` - /// performs a clamping step, which changes the value of the resulting scalar. - /// - /// This can be used for performing X25519 Diffie-Hellman using Ed25519 keys. The bytes output - /// by this function are a valid corresponding [`StaticSecret`](https://docs.rs/x25519-dalek/2.0.0/x25519_dalek/struct.StaticSecret.html#impl-From%3C%5Bu8;+32%5D%3E-for-StaticSecret) - /// for the X25519 public key given by `self.verifying_key().to_montgomery()`. - /// - /// # Note - /// - /// We do NOT recommend using a signing/verifying key for encryption. Signing keys are usually - /// long-term keys, while keys used for key exchange should rather be ephemeral. If you can - /// help it, use a separate key for encryption. - /// - /// For more information on the security of systems which use the same keys for both signing - /// and Diffie-Hellman, see the paper - /// [On using the same key pair for Ed25519 and an X25519 based KEM](https://eprint.iacr.org/2021/509). - pub fn to_scalar_bytes(&self) -> [u8; 32] { - // Per the spec, the ed25519 secret key sk is expanded to - // (scalar_bytes, hash_prefix) = SHA-512(sk) - // where the two outputs are both 32 bytes. scalar_bytes is what we return. Its clamped and - // reduced form is what we use for signing (see impl ExpandedSecretKey) - let mut buf = [0u8; 32]; - let scalar_and_hash_prefix = Sha512::default().chain_update(self.secret_key).finalize(); - buf.copy_from_slice(&scalar_and_hash_prefix[..32]); - buf - } - - /// Convert this signing key into a Curve25519 scalar. This is computed by clamping and - /// reducing the output of [`Self::to_scalar_bytes`]. - /// - /// This can be used anywhere where a Curve25519 scalar is used as a private key, e.g., in - /// [`crypto_box`](https://docs.rs/crypto_box/0.9.1/crypto_box/struct.SecretKey.html#impl-From%3CScalar%3E-for-SecretKey). - /// - /// # Note - /// - /// We do NOT recommend using a signing/verifying key for encryption. Signing keys are usually - /// long-term keys, while keys used for key exchange should rather be ephemeral. If you can - /// help it, use a separate key for encryption. - /// - /// For more information on the security of systems which use the same keys for both signing - /// and Diffie-Hellman, see the paper - /// [On using the same key pair for Ed25519 and an X25519 based KEM](https://eprint.iacr.org/2021/509). - pub fn to_scalar(&self) -> Scalar { - // Per the spec, the ed25519 secret key sk is expanded to - // (scalar_bytes, hash_prefix) = SHA-512(sk) - // where the two outputs are both 32 bytes. To use for signing, scalar_bytes must be - // clamped and reduced (see ExpandedSecretKey::from_bytes). We return the clamped and - // reduced form. - ExpandedSecretKey::from(&self.secret_key).scalar - } -} - -impl AsRef for SigningKey { - fn as_ref(&self) -> &VerifyingKey { - &self.verifying_key - } -} - -impl Debug for SigningKey { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("SigningKey") - .field("verifying_key", &self.verifying_key) - .finish_non_exhaustive() // avoids printing `secret_key` - } -} - -impl KeypairRef for SigningKey { - type VerifyingKey = VerifyingKey; -} - -impl Signer for SigningKey { - /// Sign a message with this signing key's secret key. - fn try_sign(&self, message: &[u8]) -> Result { - let expanded: ExpandedSecretKey = (&self.secret_key).into(); - Ok(expanded.raw_sign::(message, &self.verifying_key)) - } -} - -/// Equivalent to [`SigningKey::sign_prehashed`] with `context` set to [`None`]. -/// -/// # Note -/// -/// The RFC only permits SHA-512 to be used for prehashing. This function technically works, and is -/// probably safe to use, with any secure hash function with 512-bit digests, but anything outside -/// of SHA-512 is NOT specification-compliant. We expose [`crate::Sha512`] for user convenience. -#[cfg(feature = "digest")] -impl DigestSigner for SigningKey -where - D: Digest, -{ - fn try_sign_digest(&self, msg_digest: D) -> Result { - self.sign_prehashed(msg_digest, None) - } -} - -/// Equivalent to [`SigningKey::sign_prehashed`] with `context` set to [`Some`] -/// containing `self.value()`. -/// -/// # Note -/// -/// The RFC only permits SHA-512 to be used for prehashing. This function technically works, and is -/// probably safe to use, with any secure hash function with 512-bit digests, but anything outside -/// of SHA-512 is NOT specification-compliant. We expose [`crate::Sha512`] for user convenience. -#[cfg(feature = "digest")] -impl DigestSigner for Context<'_, '_, SigningKey> -where - D: Digest, -{ - fn try_sign_digest(&self, msg_digest: D) -> Result { - self.key().sign_prehashed(msg_digest, Some(self.value())) - } -} - -impl Verifier for SigningKey { - /// Verify a signature on a message with this signing key's public key. - fn verify(&self, message: &[u8], signature: &Signature) -> Result<(), SignatureError> { - self.verifying_key.verify(message, signature) - } -} - -impl From for SigningKey { - #[inline] - fn from(secret: SecretKey) -> Self { - Self::from_bytes(&secret) - } -} - -impl From<&SecretKey> for SigningKey { - #[inline] - fn from(secret: &SecretKey) -> Self { - Self::from_bytes(secret) - } -} - -impl TryFrom<&[u8]> for SigningKey { - type Error = SignatureError; - - fn try_from(bytes: &[u8]) -> Result { - SecretKey::try_from(bytes) - .map(|bytes| Self::from_bytes(&bytes)) - .map_err(|_| { - InternalError::BytesLength { - name: "SecretKey", - length: SECRET_KEY_LENGTH, - } - .into() - }) - } -} - -impl ConstantTimeEq for SigningKey { - fn ct_eq(&self, other: &Self) -> Choice { - self.secret_key.ct_eq(&other.secret_key) - } -} - -impl PartialEq for SigningKey { - fn eq(&self, other: &Self) -> bool { - self.ct_eq(other).into() - } -} - -impl Eq for SigningKey {} - -#[cfg(feature = "zeroize")] -impl Drop for SigningKey { - fn drop(&mut self) { - self.secret_key.zeroize(); - } -} - -#[cfg(feature = "zeroize")] -impl ZeroizeOnDrop for SigningKey {} - -#[cfg(all(feature = "alloc", feature = "pkcs8"))] -impl pkcs8::EncodePrivateKey for SigningKey { - fn to_pkcs8_der(&self) -> pkcs8::Result { - pkcs8::KeypairBytes::from(self).to_pkcs8_der() - } -} - -#[cfg(feature = "pkcs8")] -impl TryFrom for SigningKey { - type Error = pkcs8::Error; - - fn try_from(pkcs8_key: pkcs8::KeypairBytes) -> pkcs8::Result { - SigningKey::try_from(&pkcs8_key) - } -} - -#[cfg(feature = "pkcs8")] -impl TryFrom<&pkcs8::KeypairBytes> for SigningKey { - type Error = pkcs8::Error; - - fn try_from(pkcs8_key: &pkcs8::KeypairBytes) -> pkcs8::Result { - let signing_key = SigningKey::from_bytes(&pkcs8_key.secret_key); - - // Validate the public key in the PKCS#8 document if present - if let Some(public_bytes) = &pkcs8_key.public_key { - let expected_verifying_key = VerifyingKey::from_bytes(public_bytes.as_ref()) - .map_err(|_| pkcs8::Error::KeyMalformed)?; - - if signing_key.verifying_key() != expected_verifying_key { - return Err(pkcs8::Error::KeyMalformed); - } - } - - Ok(signing_key) - } -} - -#[cfg(feature = "pkcs8")] -impl From for pkcs8::KeypairBytes { - fn from(signing_key: SigningKey) -> pkcs8::KeypairBytes { - pkcs8::KeypairBytes::from(&signing_key) - } -} - -#[cfg(feature = "pkcs8")] -impl From<&SigningKey> for pkcs8::KeypairBytes { - fn from(signing_key: &SigningKey) -> pkcs8::KeypairBytes { - pkcs8::KeypairBytes { - secret_key: signing_key.to_bytes(), - public_key: Some(pkcs8::PublicKeyBytes(signing_key.verifying_key.to_bytes())), - } - } -} - -#[cfg(feature = "pkcs8")] -impl TryFrom> for SigningKey { - type Error = pkcs8::Error; - - fn try_from(private_key: pkcs8::PrivateKeyInfo<'_>) -> pkcs8::Result { - pkcs8::KeypairBytes::try_from(private_key)?.try_into() - } -} - -#[cfg(feature = "serde")] -impl Serialize for SigningKey { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_bytes(&self.secret_key) - } -} - -#[cfg(feature = "serde")] -impl<'d> Deserialize<'d> for SigningKey { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'d>, - { - struct SigningKeyVisitor; - - impl<'de> serde::de::Visitor<'de> for SigningKeyVisitor { - type Value = SigningKey; - - fn expecting(&self, formatter: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(formatter, concat!("An ed25519 signing (private) key")) - } - - fn visit_bytes(self, bytes: &[u8]) -> Result { - SigningKey::try_from(bytes).map_err(E::custom) - } - - fn visit_seq(self, mut seq: A) -> Result - where - A: serde::de::SeqAccess<'de>, - { - let mut bytes = [0u8; 32]; - #[allow(clippy::needless_range_loop)] - for i in 0..32 { - bytes[i] = seq - .next_element()? - .ok_or_else(|| serde::de::Error::invalid_length(i, &"expected 32 bytes"))?; - } - - let remaining = (0..) - .map(|_| seq.next_element::()) - .take_while(|el| matches!(el, Ok(Some(_)))) - .count(); - - if remaining > 0 { - return Err(serde::de::Error::invalid_length( - 32 + remaining, - &"expected 32 bytes", - )); - } - - SigningKey::try_from(bytes).map_err(serde::de::Error::custom) - } - } - - deserializer.deserialize_bytes(SigningKeyVisitor) - } -} - -/// The spec-compliant way to define an expanded secret key. This computes `SHA512(sk)`, clamps the -/// first 32 bytes and uses it as a scalar, and uses the second 32 bytes as a domain separator for -/// hashing. -impl From<&SecretKey> for ExpandedSecretKey { - #[allow(clippy::unwrap_used)] - fn from(secret_key: &SecretKey) -> ExpandedSecretKey { - let hash = Sha512::default().chain_update(secret_key).finalize(); - ExpandedSecretKey::from_bytes(hash.as_ref()) - } -} - -// -// Signing functions. These are pub(crate) so that the `hazmat` module can use them -// - -impl ExpandedSecretKey { - /// The plain, non-prehashed, signing function for Ed25519. `CtxDigest` is the digest used to - /// calculate the pseudorandomness needed for signing. According to the spec, `CtxDigest = - /// Sha512`, and `self` is derived via the method defined in `impl From<&SigningKey> for - /// ExpandedSecretKey`. - /// - /// This definition is loose in its parameters so that end-users of the `hazmat` module can - /// change how the `ExpandedSecretKey` is calculated and which hash function to use. - #[allow(non_snake_case)] - #[inline(always)] - pub(crate) fn raw_sign( - &self, - message: &[u8], - verifying_key: &VerifyingKey, - ) -> Signature - where - CtxDigest: Digest, - { - let mut h = CtxDigest::new(); - - h.update(self.hash_prefix); - h.update(message); - - let r = Scalar::from_hash(h); - let R: CompressedEdwardsY = EdwardsPoint::mul_base(&r).compress(); - - h = CtxDigest::new(); - h.update(R.as_bytes()); - h.update(verifying_key.as_bytes()); - h.update(message); - - let k = Scalar::from_hash(h); - let s: Scalar = (k * self.scalar) + r; - - InternalSignature { R, s }.into() - } - - /// The prehashed signing function for Ed25519 (i.e., Ed25519ph). `CtxDigest` is the digest - /// function used to calculate the pseudorandomness needed for signing. `MsgDigest` is the - /// digest function used to hash the signed message. According to the spec, `MsgDigest = - /// CtxDigest = Sha512`, and `self` is derived via the method defined in `impl - /// From<&SigningKey> for ExpandedSecretKey`. - /// - /// This definition is loose in its parameters so that end-users of the `hazmat` module can - /// change how the `ExpandedSecretKey` is calculated and which `CtxDigest` function to use. - #[cfg(feature = "digest")] - #[allow(non_snake_case)] - #[inline(always)] - pub(crate) fn raw_sign_prehashed( - &self, - prehashed_message: MsgDigest, - verifying_key: &VerifyingKey, - context: Option<&[u8]>, - ) -> Result - where - CtxDigest: Digest, - MsgDigest: Digest, - { - let mut prehash: [u8; 64] = [0u8; 64]; - - let ctx: &[u8] = context.unwrap_or(b""); // By default, the context is an empty string. - - if ctx.len() > 255 { - return Err(SignatureError::from(InternalError::PrehashedContextLength)); - } - - let ctx_len: u8 = ctx.len() as u8; - - // Get the result of the pre-hashed message. - prehash.copy_from_slice(prehashed_message.finalize().as_slice()); - - // This is the dumbest, ten-years-late, non-admission of fucking up the - // domain separation I have ever seen. Why am I still required to put - // the upper half "prefix" of the hashed "secret key" in here? Why - // can't the user just supply their own nonce and decide for themselves - // whether or not they want a deterministic signature scheme? Why does - // the message go into what's ostensibly the signature domain separation - // hash? Why wasn't there always a way to provide a context string? - // - // ... - // - // This is a really fucking stupid bandaid, and the damned scheme is - // still bleeding from malleability, for fuck's sake. - let mut h = CtxDigest::new() - .chain_update(b"SigEd25519 no Ed25519 collisions") - .chain_update([1]) // Ed25519ph - .chain_update([ctx_len]) - .chain_update(ctx) - .chain_update(self.hash_prefix) - .chain_update(&prehash[..]); - - let r = Scalar::from_hash(h); - let R: CompressedEdwardsY = EdwardsPoint::mul_base(&r).compress(); - - h = CtxDigest::new() - .chain_update(b"SigEd25519 no Ed25519 collisions") - .chain_update([1]) // Ed25519ph - .chain_update([ctx_len]) - .chain_update(ctx) - .chain_update(R.as_bytes()) - .chain_update(verifying_key.as_bytes()) - .chain_update(&prehash[..]); - - let k = Scalar::from_hash(h); - let s: Scalar = (k * self.scalar) + r; - - Ok(InternalSignature { R, s }.into()) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/verifying.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/verifying.rs deleted file mode 100644 index b7e12978801d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/verifying.rs +++ /dev/null @@ -1,674 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2017-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -//! ed25519 public keys. - -use core::convert::TryFrom; -use core::fmt::Debug; -use core::hash::{Hash, Hasher}; - -use curve25519_dalek::{ - digest::{generic_array::typenum::U64, Digest}, - edwards::{CompressedEdwardsY, EdwardsPoint}, - montgomery::MontgomeryPoint, - scalar::Scalar, -}; - -use ed25519::signature::Verifier; - -use sha2::Sha512; - -#[cfg(feature = "pkcs8")] -use ed25519::pkcs8; - -#[cfg(feature = "serde")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; - -#[cfg(feature = "digest")] -use crate::context::Context; -#[cfg(feature = "digest")] -use signature::DigestVerifier; - -use crate::{ - constants::PUBLIC_KEY_LENGTH, - errors::{InternalError, SignatureError}, - hazmat::ExpandedSecretKey, - signature::InternalSignature, - signing::SigningKey, -}; - -/// An ed25519 public key. -/// -/// # Note -/// -/// The `Eq` and `Hash` impls here use the compressed Edwards y encoding, _not_ the algebraic -/// representation. This means if this `VerifyingKey` is non-canonically encoded, it will be -/// considered unequal to the other equivalent encoding, despite the two representing the same -/// point. More encoding details can be found -/// [here](https://hdevalence.ca/blog/2020-10-04-its-25519am). -/// If you want to make sure that signatures produced with respect to those sorts of public keys -/// are rejected, use [`VerifyingKey::verify_strict`]. -// Invariant: VerifyingKey.1 is always the decompression of VerifyingKey.0 -#[derive(Copy, Clone, Default, Eq)] -pub struct VerifyingKey { - /// Serialized compressed Edwards-y point. - pub(crate) compressed: CompressedEdwardsY, - - /// Decompressed Edwards point used for curve arithmetic operations. - pub(crate) point: EdwardsPoint, -} - -impl Debug for VerifyingKey { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "VerifyingKey({:?}), {:?})", self.compressed, self.point) - } -} - -impl AsRef<[u8]> for VerifyingKey { - fn as_ref(&self) -> &[u8] { - self.as_bytes() - } -} - -impl Hash for VerifyingKey { - fn hash(&self, state: &mut H) { - self.as_bytes().hash(state); - } -} - -impl PartialEq for VerifyingKey { - fn eq(&self, other: &VerifyingKey) -> bool { - self.as_bytes() == other.as_bytes() - } -} - -impl From<&ExpandedSecretKey> for VerifyingKey { - /// Derive this public key from its corresponding `ExpandedSecretKey`. - fn from(expanded_secret_key: &ExpandedSecretKey) -> VerifyingKey { - VerifyingKey::from(EdwardsPoint::mul_base(&expanded_secret_key.scalar)) - } -} - -impl From<&SigningKey> for VerifyingKey { - fn from(signing_key: &SigningKey) -> VerifyingKey { - signing_key.verifying_key() - } -} - -impl From for VerifyingKey { - fn from(point: EdwardsPoint) -> VerifyingKey { - VerifyingKey { - point, - compressed: point.compress(), - } - } -} - -impl VerifyingKey { - /// Convert this public key to a byte array. - #[inline] - pub fn to_bytes(&self) -> [u8; PUBLIC_KEY_LENGTH] { - self.compressed.to_bytes() - } - - /// View this public key as a byte array. - #[inline] - pub fn as_bytes(&self) -> &[u8; PUBLIC_KEY_LENGTH] { - &(self.compressed).0 - } - - /// Construct a `VerifyingKey` from a slice of bytes. - /// - /// # Warning - /// - /// The caller is responsible for ensuring that the bytes passed into this - /// method actually represent a `curve25519_dalek::curve::CompressedEdwardsY` - /// and that said compressed point is actually a point on the curve. - /// - /// # Example - /// - /// ``` - /// use ed25519_dalek::VerifyingKey; - /// use ed25519_dalek::PUBLIC_KEY_LENGTH; - /// use ed25519_dalek::SignatureError; - /// - /// # fn doctest() -> Result { - /// let public_key_bytes: [u8; PUBLIC_KEY_LENGTH] = [ - /// 215, 90, 152, 1, 130, 177, 10, 183, 213, 75, 254, 211, 201, 100, 7, 58, - /// 14, 225, 114, 243, 218, 166, 35, 37, 175, 2, 26, 104, 247, 7, 81, 26]; - /// - /// let public_key = VerifyingKey::from_bytes(&public_key_bytes)?; - /// # - /// # Ok(public_key) - /// # } - /// # - /// # fn main() { - /// # doctest(); - /// # } - /// ``` - /// - /// # Returns - /// - /// A `Result` whose okay value is an EdDSA `VerifyingKey` or whose error value - /// is a `SignatureError` describing the error that occurred. - #[inline] - pub fn from_bytes(bytes: &[u8; PUBLIC_KEY_LENGTH]) -> Result { - let compressed = CompressedEdwardsY(*bytes); - let point = compressed - .decompress() - .ok_or(InternalError::PointDecompression)?; - - // Invariant: VerifyingKey.1 is always the decompression of VerifyingKey.0 - Ok(VerifyingKey { compressed, point }) - } - - /// Create a verifying context that can be used for Ed25519ph with - /// [`DigestVerifier`]. - #[cfg(feature = "digest")] - pub fn with_context<'k, 'v>( - &'k self, - context_value: &'v [u8], - ) -> Result, SignatureError> { - Context::new(self, context_value) - } - - /// Returns whether this is a _weak_ public key, i.e., if this public key has low order. - /// - /// A weak public key can be used to generate a signature that's valid for almost every - /// message. [`Self::verify_strict`] denies weak keys, but if you want to check for this - /// property before verification, then use this method. - pub fn is_weak(&self) -> bool { - self.point.is_small_order() - } - - // A helper function that computes `H(R || A || M)` where `H` is the 512-bit hash function - // given by `CtxDigest` (this is SHA-512 in spec-compliant Ed25519). If `context.is_some()`, - // this does the prehashed variant of the computation using its contents. - #[allow(non_snake_case)] - fn compute_challenge( - context: Option<&[u8]>, - R: &CompressedEdwardsY, - A: &CompressedEdwardsY, - M: &[u8], - ) -> Scalar - where - CtxDigest: Digest, - { - let mut h = CtxDigest::new(); - if let Some(c) = context { - h.update(b"SigEd25519 no Ed25519 collisions"); - h.update([1]); // Ed25519ph - h.update([c.len() as u8]); - h.update(c); - } - h.update(R.as_bytes()); - h.update(A.as_bytes()); - h.update(M); - - Scalar::from_hash(h) - } - - // Helper function for verification. Computes the _expected_ R component of the signature. The - // caller compares this to the real R component. If `context.is_some()`, this does the - // prehashed variant of the computation using its contents. - // Note that this returns the compressed form of R and the caller does a byte comparison. This - // means that all our verification functions do not accept non-canonically encoded R values. - // See the validation criteria blog post for more details: - // https://hdevalence.ca/blog/2020-10-04-its-25519am - #[allow(non_snake_case)] - fn recompute_R( - &self, - context: Option<&[u8]>, - signature: &InternalSignature, - M: &[u8], - ) -> CompressedEdwardsY - where - CtxDigest: Digest, - { - let k = Self::compute_challenge::(context, &signature.R, &self.compressed, M); - let minus_A: EdwardsPoint = -self.point; - // Recall the (non-batched) verification equation: -[k]A + [s]B = R - EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(minus_A), &signature.s).compress() - } - - /// The ordinary non-batched Ed25519 verification check, rejecting non-canonical R values. (see - /// [`Self::recompute_R`]). `CtxDigest` is the digest used to calculate the pseudorandomness - /// needed for signing. According to the spec, `CtxDigest = Sha512`. - /// - /// This definition is loose in its parameters so that end-users of the `hazmat` module can - /// change how the `ExpandedSecretKey` is calculated and which hash function to use. - #[allow(non_snake_case)] - pub(crate) fn raw_verify( - &self, - message: &[u8], - signature: &ed25519::Signature, - ) -> Result<(), SignatureError> - where - CtxDigest: Digest, - { - let signature = InternalSignature::try_from(signature)?; - - let expected_R = self.recompute_R::(None, &signature, message); - if expected_R == signature.R { - Ok(()) - } else { - Err(InternalError::Verify.into()) - } - } - - /// The prehashed non-batched Ed25519 verification check, rejecting non-canonical R values. - /// (see [`Self::recompute_R`]). `CtxDigest` is the digest used to calculate the - /// pseudorandomness needed for signing. `MsgDigest` is the digest used to hash the signed - /// message. According to the spec, `MsgDigest = CtxDigest = Sha512`. - /// - /// This definition is loose in its parameters so that end-users of the `hazmat` module can - /// change how the `ExpandedSecretKey` is calculated and which hash function to use. - #[cfg(feature = "digest")] - #[allow(non_snake_case)] - pub(crate) fn raw_verify_prehashed( - &self, - prehashed_message: MsgDigest, - context: Option<&[u8]>, - signature: &ed25519::Signature, - ) -> Result<(), SignatureError> - where - CtxDigest: Digest, - MsgDigest: Digest, - { - let signature = InternalSignature::try_from(signature)?; - - let ctx: &[u8] = context.unwrap_or(b""); - debug_assert!( - ctx.len() <= 255, - "The context must not be longer than 255 octets." - ); - - let message = prehashed_message.finalize(); - let expected_R = self.recompute_R::(Some(ctx), &signature, &message); - - if expected_R == signature.R { - Ok(()) - } else { - Err(InternalError::Verify.into()) - } - } - - /// Verify a `signature` on a `prehashed_message` using the Ed25519ph algorithm. - /// - /// # Inputs - /// - /// * `prehashed_message` is an instantiated hash digest with 512-bits of - /// output which has had the message to be signed previously fed into its - /// state. - /// * `context` is an optional context string, up to 255 bytes inclusive, - /// which may be used to provide additional domain separation. If not - /// set, this will default to an empty string. - /// * `signature` is a purported Ed25519ph signature on the `prehashed_message`. - /// - /// # Returns - /// - /// Returns `true` if the `signature` was a valid signature created by this - /// [`SigningKey`] on the `prehashed_message`. - /// - /// # Note - /// - /// The RFC only permits SHA-512 to be used for prehashing, i.e., `MsgDigest = Sha512`. This - /// function technically works, and is probably safe to use, with any secure hash function with - /// 512-bit digests, but anything outside of SHA-512 is NOT specification-compliant. We expose - /// [`crate::Sha512`] for user convenience. - #[cfg(feature = "digest")] - #[allow(non_snake_case)] - pub fn verify_prehashed( - &self, - prehashed_message: MsgDigest, - context: Option<&[u8]>, - signature: &ed25519::Signature, - ) -> Result<(), SignatureError> - where - MsgDigest: Digest, - { - self.raw_verify_prehashed::(prehashed_message, context, signature) - } - - /// Strictly verify a signature on a message with this keypair's public key. - /// - /// # On The (Multiple) Sources of Malleability in Ed25519 Signatures - /// - /// This version of verification is technically non-RFC8032 compliant. The - /// following explains why. - /// - /// 1. Scalar Malleability - /// - /// The authors of the RFC explicitly stated that verification of an ed25519 - /// signature must fail if the scalar `s` is not properly reduced mod $\ell$: - /// - /// > To verify a signature on a message M using public key A, with F - /// > being 0 for Ed25519ctx, 1 for Ed25519ph, and if Ed25519ctx or - /// > Ed25519ph is being used, C being the context, first split the - /// > signature into two 32-octet halves. Decode the first half as a - /// > point R, and the second half as an integer S, in the range - /// > 0 <= s < L. Decode the public key A as point A'. If any of the - /// > decodings fail (including S being out of range), the signature is - /// > invalid.) - /// - /// All `verify_*()` functions within ed25519-dalek perform this check. - /// - /// 2. Point malleability - /// - /// The authors of the RFC added in a malleability check to step #3 in - /// §5.1.7, for small torsion components in the `R` value of the signature, - /// *which is not strictly required*, as they state: - /// - /// > Check the group equation \[8\]\[S\]B = \[8\]R + \[8\]\[k\]A'. It's - /// > sufficient, but not required, to instead check \[S\]B = R + \[k\]A'. - /// - /// # History of Malleability Checks - /// - /// As originally defined (cf. the "Malleability" section in the README of - /// this repo), ed25519 signatures didn't consider *any* form of - /// malleability to be an issue. Later the scalar malleability was - /// considered important. Still later, particularly with interests in - /// cryptocurrency design and in unique identities (e.g. for Signal users, - /// Tor onion services, etc.), the group element malleability became a - /// concern. - /// - /// However, libraries had already been created to conform to the original - /// definition. One well-used library in particular even implemented the - /// group element malleability check, *but only for batch verification*! - /// Which meant that even using the same library, a single signature could - /// verify fine individually, but suddenly, when verifying it with a bunch - /// of other signatures, the whole batch would fail! - /// - /// # "Strict" Verification - /// - /// This method performs *both* of the above signature malleability checks. - /// - /// It must be done as a separate method because one doesn't simply get to - /// change the definition of a cryptographic primitive ten years - /// after-the-fact with zero consideration for backwards compatibility in - /// hardware and protocols which have it already have the older definition - /// baked in. - /// - /// # Return - /// - /// Returns `Ok(())` if the signature is valid, and `Err` otherwise. - #[allow(non_snake_case)] - pub fn verify_strict( - &self, - message: &[u8], - signature: &ed25519::Signature, - ) -> Result<(), SignatureError> { - let signature = InternalSignature::try_from(signature)?; - - let signature_R = signature - .R - .decompress() - .ok_or_else(|| SignatureError::from(InternalError::Verify))?; - - // Logical OR is fine here as we're not trying to be constant time. - if signature_R.is_small_order() || self.point.is_small_order() { - return Err(InternalError::Verify.into()); - } - - let expected_R = self.recompute_R::(None, &signature, message); - if expected_R == signature.R { - Ok(()) - } else { - Err(InternalError::Verify.into()) - } - } - - /// Verify a `signature` on a `prehashed_message` using the Ed25519ph algorithm, - /// using strict signture checking as defined by [`Self::verify_strict`]. - /// - /// # Inputs - /// - /// * `prehashed_message` is an instantiated hash digest with 512-bits of - /// output which has had the message to be signed previously fed into its - /// state. - /// * `context` is an optional context string, up to 255 bytes inclusive, - /// which may be used to provide additional domain separation. If not - /// set, this will default to an empty string. - /// * `signature` is a purported Ed25519ph signature on the `prehashed_message`. - /// - /// # Returns - /// - /// Returns `true` if the `signature` was a valid signature created by this - /// [`SigningKey`] on the `prehashed_message`. - /// - /// # Note - /// - /// The RFC only permits SHA-512 to be used for prehashing, i.e., `MsgDigest = Sha512`. This - /// function technically works, and is probably safe to use, with any secure hash function with - /// 512-bit digests, but anything outside of SHA-512 is NOT specification-compliant. We expose - /// [`crate::Sha512`] for user convenience. - #[cfg(feature = "digest")] - #[allow(non_snake_case)] - pub fn verify_prehashed_strict( - &self, - prehashed_message: MsgDigest, - context: Option<&[u8]>, - signature: &ed25519::Signature, - ) -> Result<(), SignatureError> - where - MsgDigest: Digest, - { - let signature = InternalSignature::try_from(signature)?; - - let ctx: &[u8] = context.unwrap_or(b""); - debug_assert!( - ctx.len() <= 255, - "The context must not be longer than 255 octets." - ); - - let signature_R = signature - .R - .decompress() - .ok_or_else(|| SignatureError::from(InternalError::Verify))?; - - // Logical OR is fine here as we're not trying to be constant time. - if signature_R.is_small_order() || self.point.is_small_order() { - return Err(InternalError::Verify.into()); - } - - let message = prehashed_message.finalize(); - let expected_R = self.recompute_R::(Some(ctx), &signature, &message); - - if expected_R == signature.R { - Ok(()) - } else { - Err(InternalError::Verify.into()) - } - } - - /// Convert this verifying key into Montgomery form. - /// - /// This can be used for performing X25519 Diffie-Hellman using Ed25519 keys. The output of - /// this function is a valid X25519 public key whose secret key is `sk.to_scalar_bytes()`, - /// where `sk` is a valid signing key for this `VerifyingKey`. - /// - /// # Note - /// - /// We do NOT recommend this usage of a signing/verifying key. Signing keys are usually - /// long-term keys, while keys used for key exchange should rather be ephemeral. If you can - /// help it, use a separate key for encryption. - /// - /// For more information on the security of systems which use the same keys for both signing - /// and Diffie-Hellman, see the paper - /// [On using the same key pair for Ed25519 and an X25519 based KEM](https://eprint.iacr.org/2021/509). - pub fn to_montgomery(&self) -> MontgomeryPoint { - self.point.to_montgomery() - } -} - -impl Verifier for VerifyingKey { - /// Verify a signature on a message with this keypair's public key. - /// - /// # Return - /// - /// Returns `Ok(())` if the signature is valid, and `Err` otherwise. - fn verify(&self, message: &[u8], signature: &ed25519::Signature) -> Result<(), SignatureError> { - self.raw_verify::(message, signature) - } -} - -/// Equivalent to [`VerifyingKey::verify_prehashed`] with `context` set to [`None`]. -#[cfg(feature = "digest")] -impl DigestVerifier for VerifyingKey -where - MsgDigest: Digest, -{ - fn verify_digest( - &self, - msg_digest: MsgDigest, - signature: &ed25519::Signature, - ) -> Result<(), SignatureError> { - self.verify_prehashed(msg_digest, None, signature) - } -} - -/// Equivalent to [`VerifyingKey::verify_prehashed`] with `context` set to [`Some`] -/// containing `self.value()`. -#[cfg(feature = "digest")] -impl DigestVerifier for Context<'_, '_, VerifyingKey> -where - MsgDigest: Digest, -{ - fn verify_digest( - &self, - msg_digest: MsgDigest, - signature: &ed25519::Signature, - ) -> Result<(), SignatureError> { - self.key() - .verify_prehashed(msg_digest, Some(self.value()), signature) - } -} - -impl TryFrom<&[u8]> for VerifyingKey { - type Error = SignatureError; - - #[inline] - fn try_from(bytes: &[u8]) -> Result { - let bytes = bytes.try_into().map_err(|_| InternalError::BytesLength { - name: "VerifyingKey", - length: PUBLIC_KEY_LENGTH, - })?; - Self::from_bytes(bytes) - } -} - -#[cfg(all(feature = "alloc", feature = "pkcs8"))] -impl pkcs8::EncodePublicKey for VerifyingKey { - fn to_public_key_der(&self) -> pkcs8::spki::Result { - pkcs8::PublicKeyBytes::from(self).to_public_key_der() - } -} - -#[cfg(feature = "pkcs8")] -impl TryFrom for VerifyingKey { - type Error = pkcs8::spki::Error; - - fn try_from(pkcs8_key: pkcs8::PublicKeyBytes) -> pkcs8::spki::Result { - VerifyingKey::try_from(&pkcs8_key) - } -} - -#[cfg(feature = "pkcs8")] -impl TryFrom<&pkcs8::PublicKeyBytes> for VerifyingKey { - type Error = pkcs8::spki::Error; - - fn try_from(pkcs8_key: &pkcs8::PublicKeyBytes) -> pkcs8::spki::Result { - VerifyingKey::from_bytes(pkcs8_key.as_ref()).map_err(|_| pkcs8::spki::Error::KeyMalformed) - } -} - -#[cfg(feature = "pkcs8")] -impl From for pkcs8::PublicKeyBytes { - fn from(verifying_key: VerifyingKey) -> pkcs8::PublicKeyBytes { - pkcs8::PublicKeyBytes::from(&verifying_key) - } -} - -#[cfg(feature = "pkcs8")] -impl From<&VerifyingKey> for pkcs8::PublicKeyBytes { - fn from(verifying_key: &VerifyingKey) -> pkcs8::PublicKeyBytes { - pkcs8::PublicKeyBytes(verifying_key.to_bytes()) - } -} - -#[cfg(feature = "pkcs8")] -impl TryFrom> for VerifyingKey { - type Error = pkcs8::spki::Error; - - fn try_from(public_key: pkcs8::spki::SubjectPublicKeyInfoRef<'_>) -> pkcs8::spki::Result { - pkcs8::PublicKeyBytes::try_from(public_key)?.try_into() - } -} - -#[cfg(feature = "serde")] -impl Serialize for VerifyingKey { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_bytes(&self.as_bytes()[..]) - } -} - -#[cfg(feature = "serde")] -impl<'d> Deserialize<'d> for VerifyingKey { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'d>, - { - struct VerifyingKeyVisitor; - - impl<'de> serde::de::Visitor<'de> for VerifyingKeyVisitor { - type Value = VerifyingKey; - - fn expecting(&self, formatter: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(formatter, concat!("An ed25519 verifying (public) key")) - } - - fn visit_bytes(self, bytes: &[u8]) -> Result { - VerifyingKey::try_from(bytes).map_err(E::custom) - } - - fn visit_seq(self, mut seq: A) -> Result - where - A: serde::de::SeqAccess<'de>, - { - let mut bytes = [0u8; 32]; - - #[allow(clippy::needless_range_loop)] - for i in 0..32 { - bytes[i] = seq - .next_element()? - .ok_or_else(|| serde::de::Error::invalid_length(i, &"expected 32 bytes"))?; - } - - let remaining = (0..) - .map(|_| seq.next_element::()) - .take_while(|el| matches!(el, Ok(Some(_)))) - .count(); - - if remaining > 0 { - return Err(serde::de::Error::invalid_length( - 32 + remaining, - &"expected 32 bytes", - )); - } - - VerifyingKey::try_from(&bytes[..]).map_err(serde::de::Error::custom) - } - } - - deserializer.deserialize_bytes(VerifyingKeyVisitor) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/ed25519.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/ed25519.rs deleted file mode 100644 index c05efa3c3306..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/ed25519.rs +++ /dev/null @@ -1,657 +0,0 @@ -// -*- mode: rust; -*- -// -// This file is part of ed25519-dalek. -// Copyright (c) 2017-2019 isis lovecruft -// See LICENSE for licensing information. -// -// Authors: -// - isis agora lovecruft - -//! Integration tests for ed25519-dalek. - -#![allow(clippy::items_after_test_module)] - -use ed25519_dalek::*; - -use hex::FromHex; -#[cfg(feature = "digest")] -use hex_literal::hex; - -#[cfg(test)] -mod vectors { - use super::*; - - use curve25519_dalek::{ - constants::ED25519_BASEPOINT_POINT, - edwards::{CompressedEdwardsY, EdwardsPoint}, - scalar::Scalar, - traits::IsIdentity, - }; - use sha2::{digest::Digest, Sha512}; - - use std::{ - convert::TryFrom, - fs::File, - io::{BufRead, BufReader}, - ops::Neg, - }; - - // TESTVECTORS is taken from sign.input.gz in agl's ed25519 Golang - // package. It is a selection of test cases from - // http://ed25519.cr.yp.to/python/sign.input - #[test] - fn against_reference_implementation() { - // TestGolden - let mut line: String; - let mut lineno: usize = 0; - - let f = File::open("TESTVECTORS"); - if f.is_err() { - println!( - "This test is only available when the code has been cloned \ - from the git repository, since the TESTVECTORS file is large \ - and is therefore not included within the distributed crate." - ); - panic!(); - } - let file = BufReader::new(f.unwrap()); - - for l in file.lines() { - lineno += 1; - line = l.unwrap(); - - let parts: Vec<&str> = line.split(':').collect(); - assert_eq!(parts.len(), 5, "wrong number of fields in line {}", lineno); - - let sec_bytes: Vec = FromHex::from_hex(parts[0]).unwrap(); - let pub_bytes: Vec = FromHex::from_hex(parts[1]).unwrap(); - let msg_bytes: Vec = FromHex::from_hex(parts[2]).unwrap(); - let sig_bytes: Vec = FromHex::from_hex(parts[3]).unwrap(); - - let sec_bytes = &sec_bytes[..SECRET_KEY_LENGTH].try_into().unwrap(); - let pub_bytes = &pub_bytes[..PUBLIC_KEY_LENGTH].try_into().unwrap(); - - let signing_key = SigningKey::from_bytes(sec_bytes); - let expected_verifying_key = VerifyingKey::from_bytes(pub_bytes).unwrap(); - assert_eq!(expected_verifying_key, signing_key.verifying_key()); - - // The signatures in the test vectors also include the message - // at the end, but we just want R and S. - let sig1: Signature = Signature::try_from(&sig_bytes[..64]).unwrap(); - let sig2: Signature = signing_key.sign(&msg_bytes); - - assert!(sig1 == sig2, "Signature bytes not equal on line {}", lineno); - assert!( - signing_key.verify(&msg_bytes, &sig2).is_ok(), - "Signature verification failed on line {}", - lineno - ); - assert!( - expected_verifying_key - .verify_strict(&msg_bytes, &sig2) - .is_ok(), - "Signature strict verification failed on line {}", - lineno - ); - } - } - - // From https://tools.ietf.org/html/rfc8032#section-7.3 - #[cfg(feature = "digest")] - #[test] - fn ed25519ph_rf8032_test_vector_prehash() { - let sec_bytes = hex!("833fe62409237b9d62ec77587520911e9a759cec1d19755b7da901b96dca3d42"); - let pub_bytes = hex!("ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf"); - let msg_bytes = hex!("616263"); - let sig_bytes = hex!("98a70222f0b8121aa9d30f813d683f809e462b469c7ff87639499bb94e6dae4131f85042463c2a355a2003d062adf5aaa10b8c61e636062aaad11c2a26083406"); - - let signing_key = SigningKey::from_bytes(&sec_bytes); - let expected_verifying_key = VerifyingKey::from_bytes(&pub_bytes).unwrap(); - assert_eq!(expected_verifying_key, signing_key.verifying_key()); - let sig1 = Signature::try_from(&sig_bytes[..]).unwrap(); - - let mut prehash_for_signing = Sha512::default(); - let mut prehash_for_verifying = Sha512::default(); - - prehash_for_signing.update(&msg_bytes[..]); - prehash_for_verifying.update(&msg_bytes[..]); - - let sig2: Signature = signing_key - .sign_prehashed(prehash_for_signing, None) - .unwrap(); - - assert!( - sig1 == sig2, - "Original signature from test vectors doesn't equal signature produced:\ - \noriginal:\n{:?}\nproduced:\n{:?}", - sig1, - sig2 - ); - assert!( - signing_key - .verify_prehashed(prehash_for_verifying.clone(), None, &sig2) - .is_ok(), - "Could not verify ed25519ph signature!" - ); - assert!( - expected_verifying_key - .verify_prehashed_strict(prehash_for_verifying, None, &sig2) - .is_ok(), - "Could not strict-verify ed25519ph signature!" - ); - } - - // - // The remaining items in this mod are for the repudiation tests - // - - // Taken from curve25519_dalek::constants::EIGHT_TORSION[4] - const EIGHT_TORSION_4: [u8; 32] = [ - 236, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, - ]; - - // Computes the prehashed or non-prehashed challenge, depending on whether context is given - fn compute_challenge( - message: &[u8], - pub_key: &EdwardsPoint, - signature_r: &EdwardsPoint, - context: Option<&[u8]>, - ) -> Scalar { - let mut h = Sha512::default(); - if let Some(c) = context { - h.update(b"SigEd25519 no Ed25519 collisions"); - h.update([1]); - h.update([c.len() as u8]); - h.update(c); - } - h.update(signature_r.compress().as_bytes()); - h.update(&pub_key.compress().as_bytes()[..]); - h.update(message); - Scalar::from_hash(h) - } - - fn serialize_signature(r: &EdwardsPoint, s: &Scalar) -> Vec { - [&r.compress().as_bytes()[..], &s.as_bytes()[..]].concat() - } - - const WEAK_PUBKEY: CompressedEdwardsY = CompressedEdwardsY(EIGHT_TORSION_4); - - // Pick a random Scalar - fn non_null_scalar() -> Scalar { - let mut rng = rand::rngs::OsRng; - let mut s_candidate = Scalar::random(&mut rng); - while s_candidate == Scalar::ZERO { - s_candidate = Scalar::random(&mut rng); - } - s_candidate - } - - fn pick_r(s: Scalar) -> EdwardsPoint { - let r0 = s * ED25519_BASEPOINT_POINT; - // Pick a torsion point of order 2 - r0 + WEAK_PUBKEY.decompress().unwrap().neg() - } - - // Tests that verify_strict() rejects small-order pubkeys. We test this by explicitly - // constructing a pubkey-signature pair that verifies with respect to two distinct messages. - // This should be accepted by verify(), but rejected by verify_strict(). - #[test] - fn repudiation() { - let message1 = b"Send 100 USD to Alice"; - let message2 = b"Send 100000 USD to Alice"; - - let mut s: Scalar = non_null_scalar(); - let pubkey = WEAK_PUBKEY.decompress().unwrap(); - let mut r = pick_r(s); - - // Find an R such that - // H(R || A || M₁) · A == A == H(R || A || M₂) · A - // This happens with high probability when A is low order. - while !(pubkey.neg() + compute_challenge(message1, &pubkey, &r, None) * pubkey) - .is_identity() - || !(pubkey.neg() + compute_challenge(message2, &pubkey, &r, None) * pubkey) - .is_identity() - { - // We pick an s and let R = sB - A where B is the basepoint - s = non_null_scalar(); - r = pick_r(s); - } - - // At this point, both verification equations hold: - // sB = R + H(R || A || M₁) · A - // = R + H(R || A || M₂) · A - // Check that this is true - let signature = serialize_signature(&r, &s); - let vk = VerifyingKey::from_bytes(pubkey.compress().as_bytes()).unwrap(); - let sig = Signature::try_from(&signature[..]).unwrap(); - assert!(vk.verify(message1, &sig).is_ok()); - assert!(vk.verify(message2, &sig).is_ok()); - - // Check that this public key appears as weak - assert!(vk.is_weak()); - - // Now check that the sigs fail under verify_strict. This is because verify_strict rejects - // small order pubkeys. - assert!(vk.verify_strict(message1, &sig).is_err()); - assert!(vk.verify_strict(message2, &sig).is_err()); - } - - // Identical to repudiation() above, but testing verify_prehashed against - // verify_prehashed_strict. See comments above for a description of what's happening. - #[cfg(feature = "digest")] - #[test] - fn repudiation_prehash() { - let message1 = Sha512::new().chain_update(b"Send 100 USD to Alice"); - let message2 = Sha512::new().chain_update(b"Send 100000 USD to Alice"); - let message1_bytes = message1.clone().finalize(); - let message2_bytes = message2.clone().finalize(); - - let mut s: Scalar = non_null_scalar(); - let pubkey = WEAK_PUBKEY.decompress().unwrap(); - let mut r = pick_r(s); - let context_str = Some(&b"edtest"[..]); - - while !(pubkey.neg() - + compute_challenge(&message1_bytes, &pubkey, &r, context_str) * pubkey) - .is_identity() - || !(pubkey.neg() - + compute_challenge(&message2_bytes, &pubkey, &r, context_str) * pubkey) - .is_identity() - { - s = non_null_scalar(); - r = pick_r(s); - } - - // Check that verify_prehashed succeeds on both sigs - let signature = serialize_signature(&r, &s); - let vk = VerifyingKey::from_bytes(pubkey.compress().as_bytes()).unwrap(); - let sig = Signature::try_from(&signature[..]).unwrap(); - assert!(vk - .verify_prehashed(message1.clone(), context_str, &sig) - .is_ok()); - assert!(vk - .verify_prehashed(message2.clone(), context_str, &sig) - .is_ok()); - - // Check that verify_prehashed_strict fails on both sigs - assert!(vk - .verify_prehashed_strict(message1.clone(), context_str, &sig) - .is_err()); - assert!(vk - .verify_prehashed_strict(message2.clone(), context_str, &sig) - .is_err()); - } -} - -#[cfg(feature = "rand_core")] -mod integrations { - use super::*; - use rand::rngs::OsRng; - #[cfg(feature = "digest")] - use sha2::Sha512; - use std::collections::HashMap; - - #[test] - fn sign_verify() { - // TestSignVerify - - let good: &[u8] = "test message".as_bytes(); - let bad: &[u8] = "wrong message".as_bytes(); - - let mut csprng = OsRng; - - let signing_key: SigningKey = SigningKey::generate(&mut csprng); - let verifying_key = signing_key.verifying_key(); - let good_sig: Signature = signing_key.sign(good); - let bad_sig: Signature = signing_key.sign(bad); - - // Check that an honestly generated public key is not weak - assert!(!verifying_key.is_weak()); - - assert!( - signing_key.verify(good, &good_sig).is_ok(), - "Verification of a valid signature failed!" - ); - assert!( - verifying_key.verify_strict(good, &good_sig).is_ok(), - "Strict verification of a valid signature failed!" - ); - assert!( - signing_key.verify(good, &bad_sig).is_err(), - "Verification of a signature on a different message passed!" - ); - assert!( - verifying_key.verify_strict(good, &bad_sig).is_err(), - "Strict verification of a signature on a different message passed!" - ); - assert!( - signing_key.verify(bad, &good_sig).is_err(), - "Verification of a signature on a different message passed!" - ); - assert!( - verifying_key.verify_strict(bad, &good_sig).is_err(), - "Strict verification of a signature on a different message passed!" - ); - } - - #[cfg(feature = "digest")] - #[test] - fn ed25519ph_sign_verify() { - let good: &[u8] = b"test message"; - let bad: &[u8] = b"wrong message"; - - let mut csprng = OsRng; - - // ugh… there's no `impl Copy for Sha512`… i hope we can all agree these are the same hashes - let mut prehashed_good1: Sha512 = Sha512::default(); - prehashed_good1.update(good); - let mut prehashed_good2: Sha512 = Sha512::default(); - prehashed_good2.update(good); - let mut prehashed_good3: Sha512 = Sha512::default(); - prehashed_good3.update(good); - - let mut prehashed_bad1: Sha512 = Sha512::default(); - prehashed_bad1.update(bad); - let mut prehashed_bad2: Sha512 = Sha512::default(); - prehashed_bad2.update(bad); - - let context: &[u8] = b"testing testing 1 2 3"; - - let signing_key: SigningKey = SigningKey::generate(&mut csprng); - let verifying_key = signing_key.verifying_key(); - let good_sig: Signature = signing_key - .sign_prehashed(prehashed_good1, Some(context)) - .unwrap(); - let bad_sig: Signature = signing_key - .sign_prehashed(prehashed_bad1, Some(context)) - .unwrap(); - - assert!( - signing_key - .verify_prehashed(prehashed_good2.clone(), Some(context), &good_sig) - .is_ok(), - "Verification of a valid signature failed!" - ); - assert!( - verifying_key - .verify_prehashed_strict(prehashed_good2, Some(context), &good_sig) - .is_ok(), - "Strict verification of a valid signature failed!" - ); - assert!( - signing_key - .verify_prehashed(prehashed_good3.clone(), Some(context), &bad_sig) - .is_err(), - "Verification of a signature on a different message passed!" - ); - assert!( - verifying_key - .verify_prehashed_strict(prehashed_good3, Some(context), &bad_sig) - .is_err(), - "Strict verification of a signature on a different message passed!" - ); - assert!( - signing_key - .verify_prehashed(prehashed_bad2.clone(), Some(context), &good_sig) - .is_err(), - "Verification of a signature on a different message passed!" - ); - assert!( - verifying_key - .verify_prehashed_strict(prehashed_bad2, Some(context), &good_sig) - .is_err(), - "Strict verification of a signature on a different message passed!" - ); - } - - #[cfg(feature = "batch")] - #[test] - fn verify_batch_seven_signatures() { - let messages: [&[u8]; 7] = [ - b"Watch closely everyone, I'm going to show you how to kill a god.", - b"I'm not a cryptographer I just encrypt a lot.", - b"Still not a cryptographer.", - b"This is a test of the tsunami alert system. This is only a test.", - b"Fuck dumbin' it down, spit ice, skip jewellery: Molotov cocktails on me like accessories.", - b"Hey, I never cared about your bucks, so if I run up with a mask on, probably got a gas can too.", - b"And I'm not here to fill 'er up. Nope, we came to riot, here to incite, we don't want any of your stuff.", ]; - let mut csprng = OsRng; - let mut signing_keys: Vec = Vec::new(); - let mut signatures: Vec = Vec::new(); - - for msg in messages { - let signing_key: SigningKey = SigningKey::generate(&mut csprng); - signatures.push(signing_key.sign(msg)); - signing_keys.push(signing_key); - } - let verifying_keys: Vec = - signing_keys.iter().map(|key| key.verifying_key()).collect(); - - let result = verify_batch(&messages, &signatures, &verifying_keys); - - assert!(result.is_ok()); - } - - #[test] - fn public_key_hash_trait_check() { - let mut csprng = OsRng {}; - let secret: SigningKey = SigningKey::generate(&mut csprng); - let public_from_secret: VerifyingKey = (&secret).into(); - - let mut m = HashMap::new(); - m.insert(public_from_secret, "Example_Public_Key"); - - m.insert(public_from_secret, "Updated Value"); - - let (k, &v) = m.get_key_value(&public_from_secret).unwrap(); - assert_eq!(k, &public_from_secret); - assert_eq!(v, "Updated Value"); - assert_eq!(m.len(), 1usize); - - let second_secret: SigningKey = SigningKey::generate(&mut csprng); - let public_from_second_secret: VerifyingKey = (&second_secret).into(); - assert_ne!(public_from_secret, public_from_second_secret); - m.insert(public_from_second_secret, "Second public key"); - - let (k, &v) = m.get_key_value(&public_from_second_secret).unwrap(); - assert_eq!(k, &public_from_second_secret); - assert_eq!(v, "Second public key"); - assert_eq!(m.len(), 2usize); - } -} - -#[cfg(all(test, feature = "serde"))] -#[derive(Debug, serde::Serialize, serde::Deserialize)] -#[serde(crate = "serde")] -struct Demo { - signing_key: SigningKey, -} - -#[cfg(all(test, feature = "serde"))] -mod serialisation { - #![allow(clippy::zero_prefixed_literal)] - - use super::*; - - // The size for bincode to serialize the length of a byte array. - static BINCODE_INT_LENGTH: usize = 8; - - static PUBLIC_KEY_BYTES: [u8; PUBLIC_KEY_LENGTH] = [ - 130, 039, 155, 015, 062, 076, 188, 063, 124, 122, 026, 251, 233, 253, 225, 220, 014, 041, - 166, 120, 108, 035, 254, 077, 160, 083, 172, 058, 219, 042, 086, 120, - ]; - - static SECRET_KEY_BYTES: [u8; SECRET_KEY_LENGTH] = [ - 062, 070, 027, 163, 092, 182, 011, 003, 077, 234, 098, 004, 011, 127, 079, 228, 243, 187, - 150, 073, 201, 137, 076, 022, 085, 251, 152, 002, 241, 042, 072, 054, - ]; - - /// Signature with the above signing_key of a blank message. - static SIGNATURE_BYTES: [u8; SIGNATURE_LENGTH] = [ - 010, 126, 151, 143, 157, 064, 047, 001, 196, 140, 179, 058, 226, 152, 018, 102, 160, 123, - 080, 016, 210, 086, 196, 028, 053, 231, 012, 157, 169, 019, 158, 063, 045, 154, 238, 007, - 053, 185, 227, 229, 079, 108, 213, 080, 124, 252, 084, 167, 216, 085, 134, 144, 129, 149, - 041, 081, 063, 120, 126, 100, 092, 059, 050, 011, - ]; - - #[test] - fn serialize_deserialize_signature_bincode() { - let signature: Signature = Signature::from_bytes(&SIGNATURE_BYTES); - let encoded_signature: Vec = bincode::serialize(&signature).unwrap(); - let decoded_signature: Signature = bincode::deserialize(&encoded_signature).unwrap(); - - assert_eq!(signature, decoded_signature); - } - - #[test] - fn serialize_deserialize_signature_json() { - let signature: Signature = Signature::from_bytes(&SIGNATURE_BYTES); - let encoded_signature = serde_json::to_string(&signature).unwrap(); - let decoded_signature: Signature = serde_json::from_str(&encoded_signature).unwrap(); - - assert_eq!(signature, decoded_signature); - } - - #[test] - fn serialize_deserialize_verifying_key_bincode() { - let verifying_key: VerifyingKey = VerifyingKey::from_bytes(&PUBLIC_KEY_BYTES).unwrap(); - let encoded_verifying_key: Vec = bincode::serialize(&verifying_key).unwrap(); - let decoded_verifying_key: VerifyingKey = - bincode::deserialize(&encoded_verifying_key).unwrap(); - - assert_eq!( - &PUBLIC_KEY_BYTES[..], - &encoded_verifying_key[encoded_verifying_key.len() - PUBLIC_KEY_LENGTH..] - ); - assert_eq!(verifying_key, decoded_verifying_key); - } - - #[test] - fn serialize_deserialize_verifying_key_json() { - let verifying_key: VerifyingKey = VerifyingKey::from_bytes(&PUBLIC_KEY_BYTES).unwrap(); - let encoded_verifying_key = serde_json::to_string(&verifying_key).unwrap(); - let decoded_verifying_key: VerifyingKey = - serde_json::from_str(&encoded_verifying_key).unwrap(); - - assert_eq!(verifying_key, decoded_verifying_key); - } - - #[test] - fn serialize_deserialize_verifying_key_json_too_long() { - // derived from `serialize_deserialize_verifying_key_json` test - // trailing zero elements makes key too long (34 bytes) - let encoded_verifying_key_too_long = "[130,39,155,15,62,76,188,63,124,122,26,251,233,253,225,220,14,41,166,120,108,35,254,77,160,83,172,58,219,42,86,120,0,0]"; - let de_err = serde_json::from_str::(encoded_verifying_key_too_long) - .unwrap_err() - .to_string(); - assert!( - de_err.contains("invalid length 34"), - "expected invalid length error, got: {de_err}", - ); - } - - #[test] - fn serialize_deserialize_verifying_key_json_too_short() { - // derived from `serialize_deserialize_verifying_key_json` test - let encoded_verifying_key_too_long = "[130,39,155,15]"; - let de_err = serde_json::from_str::(encoded_verifying_key_too_long) - .unwrap_err() - .to_string(); - assert!( - de_err.contains("invalid length 4"), - "expected invalid length error, got: {de_err}" - ); - } - - #[test] - fn serialize_deserialize_signing_key_bincode() { - let signing_key = SigningKey::from_bytes(&SECRET_KEY_BYTES); - let encoded_signing_key: Vec = bincode::serialize(&signing_key).unwrap(); - let decoded_signing_key: SigningKey = bincode::deserialize(&encoded_signing_key).unwrap(); - - #[allow(clippy::needless_range_loop)] - for i in 0..SECRET_KEY_LENGTH { - assert_eq!(SECRET_KEY_BYTES[i], decoded_signing_key.to_bytes()[i]); - } - } - - #[test] - fn serialize_deserialize_signing_key_json() { - let signing_key = SigningKey::from_bytes(&SECRET_KEY_BYTES); - let encoded_signing_key = serde_json::to_string(&signing_key).unwrap(); - let decoded_signing_key: SigningKey = serde_json::from_str(&encoded_signing_key).unwrap(); - - #[allow(clippy::needless_range_loop)] - for i in 0..SECRET_KEY_LENGTH { - assert_eq!(SECRET_KEY_BYTES[i], decoded_signing_key.to_bytes()[i]); - } - } - - #[test] - fn serialize_deserialize_signing_key_json_too_long() { - // derived from `serialize_deserialize_signing_key_json` test - // trailing zero elements makes key too long (34 bytes) - let encoded_signing_key_too_long = "[62,70,27,163,92,182,11,3,77,234,98,4,11,127,79,228,243,187,150,73,201,137,76,22,85,251,152,2,241,42,72,54,0,0]"; - let de_err = serde_json::from_str::(encoded_signing_key_too_long) - .unwrap_err() - .to_string(); - assert!( - de_err.contains("invalid length 34"), - "expected invalid length error, got: {de_err}", - ); - } - - #[test] - fn serialize_deserialize_signing_key_json_too_short() { - // derived from `serialize_deserialize_signing_key_json` test - let encoded_signing_key_too_long = "[62,70,27,163]"; - let de_err = serde_json::from_str::(encoded_signing_key_too_long) - .unwrap_err() - .to_string(); - assert!( - de_err.contains("invalid length 4"), - "expected invalid length error, got: {de_err}" - ); - } - - #[test] - fn serialize_deserialize_signing_key_toml() { - let demo = Demo { - signing_key: SigningKey::from_bytes(&SECRET_KEY_BYTES), - }; - - println!("\n\nWrite to toml"); - let demo_toml = toml::to_string(&demo).unwrap(); - println!("{}", demo_toml); - let demo_toml_rebuild: Result = toml::from_str(&demo_toml); - println!("{:?}", demo_toml_rebuild); - } - - #[test] - fn serialize_verifying_key_size() { - let verifying_key: VerifyingKey = VerifyingKey::from_bytes(&PUBLIC_KEY_BYTES).unwrap(); - assert_eq!( - bincode::serialized_size(&verifying_key).unwrap() as usize, - BINCODE_INT_LENGTH + PUBLIC_KEY_LENGTH - ); - } - - #[test] - fn serialize_signature_size() { - let signature: Signature = Signature::from_bytes(&SIGNATURE_BYTES); - assert_eq!( - bincode::serialized_size(&signature).unwrap() as usize, - SIGNATURE_LENGTH - ); - } - - #[test] - fn serialize_signing_key_size() { - let signing_key = SigningKey::from_bytes(&SECRET_KEY_BYTES); - assert_eq!( - bincode::serialized_size(&signing_key).unwrap() as usize, - BINCODE_INT_LENGTH + SECRET_KEY_LENGTH - ); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pkcs8-v1.der b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pkcs8-v1.der deleted file mode 100644 index cb780b362c9dbb7e62b9159ac40c45b1242bec2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 48 zcmV-00MGw0E&>4nFa-t!D`jv5A_O4R?sD7t6Ie>sw%GCaY51)={(LCQ@znd^m#B|K Gbyz~LI~HgF diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pkcs8-v2.der b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pkcs8-v2.der deleted file mode 100644 index 3358e8a730ac3daf865b6eab869bb9a921ab9ef4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 116 zcmV-)0E_=HasmMXFa-t!D`jv5A_O4R?sD7t6Ie>sw%GCaY51)={(LCQ@znd^m#B|K zbyz~6A21yT3Mz(3hW8Bt2?-Q24-5@Mb#i2EWgtUnVQF%6fgu1HzeEXXgw6hiLAt?b W+&h-YP==~7wzkU*TsW<8F=pYUFECsH diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pubkey.der b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/examples/pubkey.der deleted file mode 100644 index d1002c4a4e624c322cc71015e6685a25808df374..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44 zcmXreGGJw6)=n*8R%DRe@4}hca`s=V, - #[serde(deserialize_with = "bytes_from_hex")] - sig: Vec, - msg: String, - flags: Option>, -} - -/// The test vector struct from [CCTV][]. `sig` may or may not be a valid signature of `msg` with -/// respect to `pubkey`, depending on the verification function's validation criteria. `flags` -/// describes all the edge cases which this test vector falls into. -/// -/// [CCTV]: https://github.com/C2SP/CCTV/tree/5ea85644bd035c555900a2f707f7e4c31ea65ced/ed25519vectors -struct TestVector { - number: usize, - pubkey: VerifyingKey, - sig: Signature, - msg: Vec, - flags: Set, -} - -impl From for TestVector { - fn from(tv: IntermediateTestVector) -> Self { - let number = tv.number; - let pubkey = { - let mut buf = [0u8; 32]; - buf.copy_from_slice(&tv.pubkey); - VerifyingKey::from_bytes(&buf).unwrap() - }; - let sig = { - let mut buf = [0u8; 64]; - buf.copy_from_slice(&tv.sig); - Signature::from_bytes(&buf) - }; - let msg = tv.msg.as_bytes().to_vec(); - - // Unwrap the Option> - let flags = tv.flags.unwrap_or_default(); - - Self { - number, - pubkey, - sig, - msg, - flags, - } - } -} - -// Tells serde how to deserialize bytes from hex -fn bytes_from_hex<'de, D>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - let mut hex_str = String::deserialize(deserializer)?; - // Prepend a 0 if it's not even length - if hex_str.len() % 2 == 1 { - hex_str.insert(0, '0'); - } - hex::decode(hex_str).map_err(|e| SError::custom(format!("{:?}", e))) -} - -fn get_test_vectors() -> impl Iterator { - let f = File::open("VALIDATIONVECTORS").expect( - "This test is only available when the code has been cloned from the git repository, since - the VALIDATIONVECTORS file is large and is therefore not included within the distributed \ - crate.", - ); - - serde_json::from_reader::<_, Vec>(f) - .unwrap() - .into_iter() - .map(TestVector::from) -} - -/// Tests that the verify() and verify_strict() functions succeed only on test cases whose flags -/// (i.e., edge cases it falls into) are a subset of VERIFY_ALLOWED_EDGECASES and -/// VERIFY_STRICT_ALLOWED_EDGECASES, respectively -#[test] -fn check_validation_criteria() { - let verify_allowed_edgecases = Set::from_iter(VERIFY_ALLOWED_EDGECASES.to_vec()); - let verify_strict_allowed_edgecases = Set::from_iter(VERIFY_STRICT_ALLOWED_EDGECASES.to_vec()); - - for TestVector { - number, - pubkey, - msg, - sig, - flags, - } in get_test_vectors() - { - // If all the verify-permitted flags here are ones we permit, then verify() should succeed. - // Otherwise, it should not. - let success = pubkey.verify(&msg, &sig).is_ok(); - if flags.is_subset(&verify_allowed_edgecases) { - assert!(success, "verify() expected success in testcase #{number}",); - } else { - assert!(!success, "verify() expected failure in testcase #{number}",); - } - - // If all the verify_strict-permitted flags here are ones we permit, then verify_strict() - // should succeed. Otherwise, it should not. - let success = pubkey.verify_strict(&msg, &sig).is_ok(); - if flags.is_subset(&verify_strict_allowed_edgecases) { - assert!( - success, - "verify_strict() expected success in testcase #{number}", - ); - } else { - assert!( - !success, - "verify_strict() expected failure in testcase #{number}", - ); - } - } -} - -/// Prints the flags that are consistently permitted by verify() and verify_strict() -#[test] -fn find_validation_criteria() { - let mut verify_allowed_edgecases = Set::new(); - let mut verify_strict_allowed_edgecases = Set::new(); - - // Counts the number of times a signature with a re-encoded k and a low-order A verified. This - // happens with 1/8 probability, assuming the usual verification equation(s). - let mut num_lucky_reencoded_k = 0; - let mut num_reencoded_k = 0; - - for TestVector { - number: _, - pubkey, - msg, - sig, - flags, - } in get_test_vectors() - { - // If verify() was a success, add all the associated flags to verify-permitted set - let success = pubkey.verify(&msg, &sig).is_ok(); - - // If this is ReencodedK && LowOrderA, log some statistics - if flags.contains(&Flag::ReencodedK) && flags.contains(&Flag::LowOrderA) { - num_reencoded_k += 1; - num_lucky_reencoded_k += success as u8; - } - - if success { - for flag in &flags { - // Don't count re-encoded k when A is low-order. This is because the - // re-encoded k might be a multiple of 8 by accident - if *flag == Flag::ReencodedK && flags.contains(&Flag::LowOrderA) { - continue; - } else { - verify_allowed_edgecases.insert(*flag); - } - } - } - - // If verify_strict() was a success, add all the associated flags to - // verify_strict-permitted set - let success = pubkey.verify_strict(&msg, &sig).is_ok(); - if success { - for flag in &flags { - verify_strict_allowed_edgecases.insert(*flag); - } - } - } - - println!("VERIFY_ALLOWED_EDGECASES: {:?}", verify_allowed_edgecases); - println!( - "VERIFY_STRICT_ALLOWED_EDGECASES: {:?}", - verify_strict_allowed_edgecases - ); - println!( - "re-encoded k && low-order A yielded a valid signature {}/{} of the time", - num_lucky_reencoded_k, num_reencoded_k - ); -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/x25519.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/x25519.rs deleted file mode 100644 index 11e72a80485f..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/tests/x25519.rs +++ /dev/null @@ -1,80 +0,0 @@ -//! Tests for converting Ed25519 keys into X25519 (Montgomery form) keys. - -use curve25519_dalek::scalar::{clamp_integer, Scalar}; -use ed25519_dalek::SigningKey; -use hex_literal::hex; -use sha2::{Digest, Sha512}; -use x25519_dalek::{PublicKey as XPublicKey, StaticSecret as XStaticSecret}; - -/// Tests that X25519 Diffie-Hellman works when using keys converted from Ed25519. -// TODO: generate test vectors using another implementation of Ed25519->X25519 -#[test] -fn ed25519_to_x25519_dh() { - // Keys from RFC8032 test vectors (from section 7.1) - let ed_secret_key_a = hex!("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60"); - let ed_secret_key_b = hex!("4ccd089b28ff96da9db6c346ec114e0f5b8a319f35aba624da8cf6ed4fb8a6fb"); - - let ed_signing_key_a = SigningKey::from_bytes(&ed_secret_key_a); - let ed_signing_key_b = SigningKey::from_bytes(&ed_secret_key_b); - - // Create an x25519 static secret from the ed25519 signing key - let scalar_bytes_a = ed_signing_key_a.to_scalar_bytes(); - let scalar_bytes_b = ed_signing_key_b.to_scalar_bytes(); - let x_static_secret_a = XStaticSecret::from(scalar_bytes_a); - let x_static_secret_b = XStaticSecret::from(scalar_bytes_b); - - // Compute the secret scalars too - let scalar_a = ed_signing_key_a.to_scalar(); - let scalar_b = ed_signing_key_b.to_scalar(); - - // Compare the scalar bytes to the first 32 bytes of SHA-512(secret_key). We have to clamp and - // reduce the SHA-512 output because that's what the spec does before using the scalars for - // anything. - assert_eq!(scalar_bytes_a, &Sha512::digest(ed_secret_key_a)[..32]); - assert_eq!(scalar_bytes_b, &Sha512::digest(ed_secret_key_b)[..32]); - - // Compare the scalar with the clamped and reduced scalar bytes - assert_eq!( - scalar_a, - Scalar::from_bytes_mod_order(clamp_integer(scalar_bytes_a)) - ); - assert_eq!( - scalar_b, - Scalar::from_bytes_mod_order(clamp_integer(scalar_bytes_b)) - ); - - let x_public_key_a = XPublicKey::from(&x_static_secret_a); - let x_public_key_b = XPublicKey::from(&x_static_secret_b); - assert_eq!( - x_public_key_a.to_bytes(), - hex!("d85e07ec22b0ad881537c2f44d662d1a143cf830c57aca4305d85c7a90f6b62e") - ); - assert_eq!( - x_public_key_b.to_bytes(), - hex!("25c704c594b88afc00a76b69d1ed2b984d7e22550f3ed0802d04fbcd07d38d47") - ); - - // Test the claim made in the comments of SigningKey::to_scalar_bytes, i.e., that the resulting - // scalar is a valid private key for the x25519 pubkey represented by - // `sk.verifying_key().to_montgomery()` - assert_eq!( - ed_signing_key_a.verifying_key().to_montgomery().as_bytes(), - x_public_key_a.as_bytes() - ); - assert_eq!( - ed_signing_key_b.verifying_key().to_montgomery().as_bytes(), - x_public_key_b.as_bytes() - ); - - // Check that Diffie-Hellman works - let expected_shared_secret = - hex!("5166f24a6918368e2af831a4affadd97af0ac326bdf143596c045967cc00230e"); - assert_eq!( - x_static_secret_a.diffie_hellman(&x_public_key_b).to_bytes(), - expected_shared_secret, - ); - assert_eq!( - x_static_secret_b.diffie_hellman(&x_public_key_a).to_bytes(), - expected_shared_secret, - ); -} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.cargo_vcs_info.json deleted file mode 100644 index 19f6bb7e5257..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "cfa4df6c621d99429d4357b6823fb48f8e4fe8ad" - }, - "path_in_vcs": "" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.github/workflows/audit.yml b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.github/workflows/audit.yml deleted file mode 100644 index abcbbff5ea5a..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.github/workflows/audit.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Security audit -on: - push: - paths: - - '**/Cargo.toml' - - '**/Cargo.lock' - schedule: - - cron: '0 0 * * *' -jobs: - security_audit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.github/workflows/ci.yml b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.github/workflows/ci.yml deleted file mode 100644 index ced88fec08ab..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.github/workflows/ci.yml +++ /dev/null @@ -1,82 +0,0 @@ -on: [push, pull_request] - -name: Continuous integration - -jobs: - test: - name: Test Suite - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: test - - fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add clippy - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings - - no-std-check: - name: no_std Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-no-std-check - - run: cargo-no-std-check --no-default-features - env: - RUSTFLAGS: -D warnings - - doc: - name: Doc generation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: doc diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.gitignore b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.gitignore deleted file mode 100644 index 96ef6c0b944e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -Cargo.lock diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/Cargo.toml deleted file mode 100644 index c1f100da538b..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/Cargo.toml +++ /dev/null @@ -1,61 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -name = "ed25519-dalek-bip32" -version = "0.3.0" -authors = ["Julian Popescu "] -description = "Simplified ed25519 BIP32 derivations" -homepage = "https://github.com/jpopesculian/ed25519-dalek-bip32" -documentation = "https://docs.rs/ed25519-dalek-bip32/" -readme = "README.md" -keywords = [ - "derivation", - "BIP32", - "ed25519", - "trezor", - "blockchain", -] -categories = [ - "cryptography", - "no-std", -] -license = "MIT OR Apache-2.0" -repository = "https://github.com/jpopesculian/ed25519-dalek-bip32" - -[dependencies.derivation-path] -version = "0.2.0" -default-features = false - -[dependencies.ed25519-dalek] -version = "2.0.0" -features = ["rand_core"] -default-features = false - -[dependencies.hmac] -version = "0.12.0" -default-features = false - -[dependencies.sha2] -version = "0.10.1" -default-features = false - -[dev-dependencies.hex] -version = "0.4.2" - -[features] -default = ["std"] -std = [ - "derivation-path/std", - "sha2/std", - "ed25519-dalek/std", -] diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/Cargo.toml.orig deleted file mode 100644 index 2ed39e33db71..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/Cargo.toml.orig +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "ed25519-dalek-bip32" -version = "0.3.0" -authors = ["Julian Popescu "] -edition = "2021" -license = "MIT OR Apache-2.0" -readme = "README.md" -homepage = "https://github.com/jpopesculian/ed25519-dalek-bip32" -documentation = "https://docs.rs/ed25519-dalek-bip32/" -repository = "https://github.com/jpopesculian/ed25519-dalek-bip32" -description = "Simplified ed25519 BIP32 derivations" -keywords = ["derivation", "BIP32", "ed25519", "trezor", "blockchain"] -categories = ["cryptography", "no-std"] - -[features] -default = ["std"] -std = ["derivation-path/std", "sha2/std", "ed25519-dalek/std"] - -[dependencies] -derivation-path = { version = "0.2.0", default-features = false } -sha2 = { version = "0.10.1", default-features = false } -hmac = { version = "0.12.0", default-features = false } -ed25519-dalek = { version = "2.0.0", default-features = false, features = ["rand_core"] } - -[dev-dependencies] -hex = "0.4.2" diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/README.md b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/README.md deleted file mode 100644 index 411d2271b23f..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# ed25519-dalek-bip32 - -A simple BIP32 implementation for ed25519 public keys. Although there exists [another very good -library that does this](https://docs.rs/ed25519-bip32), this library preserves 32 byte secret -keys and doesn't allow for extended public keys or "normal" child indexes, so that it can be as -close to the BIP32 specifications as possible, allowing for compatibility with libraries like -`trezor-crypto` - -License: MIT OR Apache-2.0 diff --git a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/src/lib.rs deleted file mode 100644 index f7bb005140db..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/src/lib.rs +++ /dev/null @@ -1,452 +0,0 @@ -//! A simple BIP32 implementation for ed25519 public keys. Although there exists [another very good -//! library that does this](https://docs.rs/ed25519-bip32), this library preserves 32 byte secret -//! keys and doesn't allow for extended public keys or "normal" child indexes, so that it can be as -//! close to the BIP32 specifications as possible, allowing for compatibility with libraries like -//! `trezor-crypto` - -#![cfg_attr(not(feature = "std"), no_std)] - -pub extern crate derivation_path; -pub extern crate ed25519_dalek; - -pub use derivation_path::{ChildIndex, DerivationPath}; -pub use ed25519_dalek::{SigningKey, VerifyingKey}; - -use core::fmt; -use hmac::{Hmac, Mac}; -use sha2::Sha512; - -const ED25519_BIP32_NAME: &str = "ed25519 seed"; - -/// Errors thrown while deriving secret keys -#[derive(Debug)] -pub enum Error { - Ed25519, - ExpectedHardenedIndex(ChildIndex), -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Ed25519 => f.write_str("ed25519 error"), - Self::ExpectedHardenedIndex(index) => { - f.write_fmt(format_args!("expected hardened child index: {}", index)) - } - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} - -/// An expanded secret key with chain code and meta data -#[derive(Debug)] -pub struct ExtendedSigningKey { - /// How many derivations this key is from the root (0 for root) - pub depth: u8, - /// Child index of the key used to derive from parent (`Normal(0)` for root) - pub child_index: ChildIndex, - /// Signing Key - pub signing_key: SigningKey, - /// Chain code - pub chain_code: [u8; 32], -} - -type HmacSha512 = Hmac; - -/// A convenience wrapper for a [`core::result::Result`] with an [`Error`] -pub type Result = core::result::Result; - -impl ExtendedSigningKey { - /// Create a new extended secret key from a seed - pub fn from_seed(seed: &[u8]) -> Result { - let mut mac = HmacSha512::new_from_slice(ED25519_BIP32_NAME.as_ref()).unwrap(); - mac.update(seed); - let bytes = mac.finalize().into_bytes(); - - let secret_key_bytes: [u8; 32] = bytes[0..32].try_into().unwrap(); - let signing_key = SigningKey::from_bytes(&secret_key_bytes); - - let mut chain_code = [0; 32]; - chain_code.copy_from_slice(&bytes[32..]); - - Ok(Self { - depth: 0, - child_index: ChildIndex::Normal(0), - signing_key, - chain_code, - }) - } - - /// Derive an extended secret key fom the current using a derivation path - pub fn derive>(&self, path: &P) -> Result { - let mut path = path.as_ref().iter(); - let mut next = match path.next() { - Some(index) => self.derive_child(*index)?, - None => self.clone(), - }; - for index in path { - next = next.derive_child(*index)?; - } - Ok(next) - } - - /// Derive a child extended secret key with an index - pub fn derive_child(&self, index: ChildIndex) -> Result { - if index.is_normal() { - return Err(Error::ExpectedHardenedIndex(index)); - } - - let mut mac = HmacSha512::new_from_slice(&self.chain_code).unwrap(); - mac.update(&[0u8]); - mac.update(self.signing_key.to_bytes().as_ref()); - mac.update(index.to_bits().to_be_bytes().as_ref()); - let bytes = mac.finalize().into_bytes(); - - let secret_key_bytes: [u8; 32] = bytes[0..32].try_into().unwrap(); - let signing_key = SigningKey::from_bytes(&secret_key_bytes); - - let mut chain_code = [0; 32]; - chain_code.copy_from_slice(&bytes[32..]); - - Ok(Self { - depth: self.depth + 1, - child_index: index, - signing_key, - chain_code, - }) - } - - /// Get the associated verifying key - #[inline] - pub fn verifying_key(&self) -> VerifyingKey { - self.signing_key.verifying_key() - } - - #[inline] - fn clone(&self) -> Self { - Self { - depth: self.depth, - child_index: self.child_index, - signing_key: SigningKey::from_bytes(&self.signing_key.to_bytes()), - chain_code: self.chain_code, - } - } -} - -impl From for Error { - fn from(_: ed25519_dalek::SignatureError) -> Self { - Self::Ed25519 - } -} - -#[cfg(test)] -mod tests { - use super::*; - - extern crate alloc; - use alloc::vec::Vec; - use hex::FromHex; - - fn hex_str(string: &str) -> Vec { - hex::decode(string).unwrap() - } - - fn key_hex_str(input_str: &str) -> [u8; 32] { - <[u8; 32]>::from_hex(input_str).expect("Failed to convert Hex Str into Key") - } - - fn root(seed: &str) -> ExtendedSigningKey { - ExtendedSigningKey::from_seed(&hex_str(seed)).unwrap() - } - - #[test] - fn derivation_path() { - let vector1_path: DerivationPath = "m/0'/1'/2'/2'/1000000000'".parse().unwrap(); - let vector2_path: DerivationPath = "m/0'/2147483647'/1'/2147483646'/2'".parse().unwrap(); - - let node = root("000102030405060708090a0b0c0d0e0f") - .derive(&vector1_path) - .unwrap(); - assert_eq!(node.depth, 5); - assert_eq!(node.child_index, ChildIndex::Hardened(1000000000)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("68789923a0cac2cd5a29172a475fe9e0fb14cd6adb5ad98a3fa70333e7afa230") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "8f94d394a8e8fd6b1bc2f3f49f5c47e385281d5c17e65324b0f62483e37e8793", - )); - - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "3c24da049451555d51a7014a37337aa4e12d41e485abccfa46b47dfb2af54b7a", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - let node = root("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542").derive(&vector2_path).unwrap(); - assert_eq!(node.depth, 5); - assert_eq!(node.child_index, ChildIndex::Hardened(2)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("5d70af781f3a37b829f0d060924d5e960bdc02e85423494afc0b1a41bbe196d4") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "551d333177df541ad876a60ea71f00447931c0a9da16f227c11ea080d7391b8d", - )); - - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "47150c75db263559a70d5778bf36abbab30fb061ad69f69ece61a72b0cfa4fc0", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - } - - #[test] - fn normal_errs() { - let node = root("000102030405060708090a0b0c0d0e0f"); - - let res = node.derive_child(ChildIndex::Normal(0)); - assert!(matches!( - res, - Err(Error::ExpectedHardenedIndex(ChildIndex::Normal(0))) - )); - - let res = node.derive_child(ChildIndex::Normal(100000)); - assert!(matches!( - res, - Err(Error::ExpectedHardenedIndex(ChildIndex::Normal(100000))) - )); - - let soft_path: DerivationPath = "m/0'/1'/2'/3/4'".parse().unwrap(); - let res = node.derive(&soft_path); - assert!(matches!( - res, - Err(Error::ExpectedHardenedIndex(ChildIndex::Normal(3))) - )); - } - - #[test] - fn vector1() { - // Chain m - let node = root("000102030405060708090a0b0c0d0e0f"); - assert_eq!(node.depth, 0); - assert_eq!(node.child_index, ChildIndex::Normal(0)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("90046a93de5380a72b5e45010748567d5ea02bbf6522f979e05c0d8d8ca9fffb") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "a4b2856bfec510abab89753fac1ac0e1112364e7d250545963f135f2a33188ed", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0' - let node = node.derive_child(ChildIndex::Hardened(0)).unwrap(); - assert_eq!(node.depth, 1); - assert_eq!(node.child_index, ChildIndex::Hardened(0)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("8b59aa11380b624e81507a27fedda59fea6d0b779a778918a2fd3590e16e9c69") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "68e0fe46dfb67e368c75379acec591dad19df3cde26e63b93a8e704f1dade7a3", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "8c8a13df77a28f3445213a0f432fde644acaa215fc72dcdf300d5efaa85d350c", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0'/1' - let node = node.derive_child(ChildIndex::Hardened(1)).unwrap(); - assert_eq!(node.depth, 2); - assert_eq!(node.child_index, ChildIndex::Hardened(1)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("a320425f77d1b5c2505a6b1b27382b37368ee640e3557c315416801243552f14") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "b1d0bad404bf35da785a64ca1ac54b2617211d2777696fbffaf208f746ae84f2", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "1932a5270f335bed617d5b935c80aedb1a35bd9fc1e31acafd5372c30f5c1187", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0'/1'/2' - let node = node.derive_child(ChildIndex::Hardened(2)).unwrap(); - assert_eq!(node.depth, 3); - assert_eq!(node.child_index, ChildIndex::Hardened(2)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("2e69929e00b5ab250f49c3fb1c12f252de4fed2c1db88387094a0f8c4c9ccd6c") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "92a5b23c0b8a99e37d07df3fb9966917f5d06e02ddbd909c7e184371463e9fc9", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "ae98736566d30ed0e9d2f4486a64bc95740d89c7db33f52121f8ea8f76ff0fc1", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0'/1'/2'/2' - let node = node.derive_child(ChildIndex::Hardened(2)).unwrap(); - assert_eq!(node.depth, 4); - assert_eq!(node.child_index, ChildIndex::Hardened(2)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("8f6d87f93d750e0efccda017d662a1b31a266e4a6f5993b15f5c1f07f74dd5cc") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "30d1dc7e5fc04c31219ab25a27ae00b50f6fd66622f6e9c913253d6511d1e662", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "8abae2d66361c879b900d204ad2cc4984fa2aa344dd7ddc46007329ac76c429c", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0'/1'/2'/2'/1000000000' - let node = node.derive_child(ChildIndex::Hardened(1000000000)).unwrap(); - assert_eq!(node.depth, 5); - assert_eq!(node.child_index, ChildIndex::Hardened(1000000000)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("68789923a0cac2cd5a29172a475fe9e0fb14cd6adb5ad98a3fa70333e7afa230") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "8f94d394a8e8fd6b1bc2f3f49f5c47e385281d5c17e65324b0f62483e37e8793", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "3c24da049451555d51a7014a37337aa4e12d41e485abccfa46b47dfb2af54b7a", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - } - - #[test] - fn vector2() { - // Chain m - let node = root("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"); - assert_eq!(node.depth, 0); - assert_eq!(node.child_index, ChildIndex::Normal(0)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("ef70a74db9c3a5af931b5fe73ed8e1a53464133654fd55e7a66f8570b8e33c3b") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "171cb88b1b3c1db25add599712e36245d75bc65a1a5c9e18d76f9f2b1eab4012", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "8fe9693f8fa62a4305a140b9764c5ee01e455963744fe18204b4fb948249308a", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0' - let node = node.derive_child(ChildIndex::Hardened(0)).unwrap(); - assert_eq!(node.depth, 1); - assert_eq!(node.child_index, ChildIndex::Hardened(0)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("0b78a3226f915c082bf118f83618a618ab6dec793752624cbeb622acb562862d") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "1559eb2bbec5790b0c65d8693e4d0875b1747f4970ae8b650486ed7470845635", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "86fab68dcb57aa196c77c5f264f215a112c22a912c10d123b0d03c3c28ef1037", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0'/2147483647' - let node = node.derive_child(ChildIndex::Hardened(2147483647)).unwrap(); - assert_eq!(node.depth, 2); - assert_eq!(node.child_index, ChildIndex::Hardened(2147483647)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("138f0b2551bcafeca6ff2aa88ba8ed0ed8de070841f0c4ef0165df8181eaad7f") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "ea4f5bfe8694d8bb74b7b59404632fd5968b774ed545e810de9c32a4fb4192f4", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "5ba3b9ac6e90e83effcd25ac4e58a1365a9e35a3d3ae5eb07b9e4d90bcf7506d", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0'/2147483647'/1' - let node = node.derive_child(ChildIndex::Hardened(1)).unwrap(); - assert_eq!(node.depth, 3); - assert_eq!(node.child_index, ChildIndex::Hardened(1)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("73bd9fff1cfbde33a1b846c27085f711c0fe2d66fd32e139d3ebc28e5a4a6b90") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "3757c7577170179c7868353ada796c839135b3d30554bbb74a4b1e4a5a58505c", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "2e66aa57069c86cc18249aecf5cb5a9cebbfd6fadeab056254763874a9352b45", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0'/2147483647'/1'/2147483646' - let node = node.derive_child(ChildIndex::Hardened(2147483646)).unwrap(); - assert_eq!(node.depth, 4); - assert_eq!(node.child_index, ChildIndex::Hardened(2147483646)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("0902fe8a29f9140480a00ef244bd183e8a13288e4412d8389d140aac1794825a") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "5837736c89570de861ebc173b1086da4f505d4adb387c6a1b1342d5e4ac9ec72", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "e33c0f7d81d843c572275f287498e8d408654fdf0d1e065b84e2e6f157aab09b", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - - // Chain m/0'/2147483647'/1'/2147483646'/2' - let node = node.derive_child(ChildIndex::Hardened(2)).unwrap(); - assert_eq!(node.depth, 5); - assert_eq!(node.child_index, ChildIndex::Hardened(2)); - assert_eq!( - node.chain_code.as_ref(), - hex_str("5d70af781f3a37b829f0d060924d5e960bdc02e85423494afc0b1a41bbe196d4") - ); - let secret = SigningKey::from_bytes(&key_hex_str( - "551d333177df541ad876a60ea71f00447931c0a9da16f227c11ea080d7391b8d", - )); - assert_eq!(node.signing_key.to_bytes(), secret.to_bytes()); - let public = VerifyingKey::from_bytes(&key_hex_str( - "47150c75db263559a70d5778bf36abbab30fb061ad69f69ece61a72b0cfa4fc0", - )) - .unwrap(); - assert_eq!(node.verifying_key().to_bytes(), public.to_bytes()); - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/.cargo_vcs_info.json deleted file mode 100644 index d4454240fe4b..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "7736dd21389b8820dfeb396e8c4c932de93d3ddf" - }, - "path_in_vcs": "pkcs8" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/CHANGELOG.md b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/CHANGELOG.md deleted file mode 100644 index 1f754d527beb..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/CHANGELOG.md +++ /dev/null @@ -1,234 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## 0.10.2 (2023-04-04) -### Changed -- Bump `spki` to v0.7.1 ([#981]) - -[#981]: https://github.com/RustCrypto/formats/pull/981 - -## 0.10.1 (2023-03-05) -### Added -- `sha1-insecure` feature ([#913]) - -[#913]: https://github.com/RustCrypto/formats/pull/913 - -## 0.10.0 (2023-02-26) [YANKED] -### Changed -- Use blanket impls for `Decode*` traits ([#785]) -- Bump `der` dependency to v0.7 ([#899]) -- Bump `spki` dependency to v0.7 ([#900]) -- Bump `pkcs5` dependency to v0.7 ([#901]) - -[#785]: https://github.com/RustCrypto/formats/pull/785 -[#899]: https://github.com/RustCrypto/formats/pull/899 -[#900]: https://github.com/RustCrypto/formats/pull/900 -[#901]: https://github.com/RustCrypto/formats/pull/901 - -## 0.9.0 (2022-05-08) -### Added -- Error conversion support to `pkcs8::spki::Error` ([#335]) -- Re-export `AssociatedOid` ([#645]) - -### Changed -- Use `finish_non_exhaustive` in `Debug` impls ([#245]) -- Replace `PrivateKeyDocument` with `der::SecretDocument` ([#571]) -- Bump `der` to v0.6 ([#653]) -- Bump `spki` to v0.6 ([#654]) -- Bump `pkcs5` to v0.5 ([#655]) - -### Removed -- `PrivateKeyDocument` ([#571]) - -[#245]: https://github.com/RustCrypto/formats/pull/245 -[#335]: https://github.com/RustCrypto/formats/pull/335 -[#571]: https://github.com/RustCrypto/formats/pull/571 -[#645]: https://github.com/RustCrypto/formats/pull/645 -[#653]: https://github.com/RustCrypto/formats/pull/653 -[#654]: https://github.com/RustCrypto/formats/pull/654 -[#655]: https://github.com/RustCrypto/formats/pull/655 - -## 0.8.0 (2021-11-16) -### Added -- Re-export `spki` crate ([#210]) - -### Changed -- Replace usages of `expect` with fallible methods ([#108]) -- Impl `From*Key`/`To*Key` traits on `Document` types ([#110]) -- Rename `From/ToPrivateKey` => `DecodePrivateKey`/`EncodePrivateKey` ([#121]) -- Rust 2021 edition upgrade; MSRV 1.56 ([#136]) -- Use `der::Document` to impl `*PrivateKeyDocument` ([#140]) -- Rename `Error::Crypto` => `Error::EncryptedPrivateKey` ([#213], [#214]) -- Bump `der` dependency to v0.5 ([#222]) -- Bump `spki` dependency to v0.5 ([#223]) -- Bump `pkcs5` dependency to v0.4 ([#224]) -- Replace `from_pkcs8_private_key_info` with `TryFrom` ([#230]) - -### Removed -- `*_with_le` PEM encoding methods ([#109]) -- PKCS#1 support; moved to `pkcs1` crate ([#124]) -- I/O related errors from key format crates ([#158]) -- `der::pem` export ([#211]) - -[#108]: https://github.com/RustCrypto/formats/pull/108 -[#109]: https://github.com/RustCrypto/formats/pull/109 -[#110]: https://github.com/RustCrypto/formats/pull/110 -[#121]: https://github.com/RustCrypto/formats/pull/121 -[#124]: https://github.com/RustCrypto/formats/pull/124 -[#136]: https://github.com/RustCrypto/formats/pull/136 -[#140]: https://github.com/RustCrypto/formats/pull/140 -[#158]: https://github.com/RustCrypto/formats/pull/158 -[#210]: https://github.com/RustCrypto/formats/pull/210 -[#211]: https://github.com/RustCrypto/formats/pull/211 -[#213]: https://github.com/RustCrypto/formats/pull/213 -[#214]: https://github.com/RustCrypto/formats/pull/214 -[#222]: https://github.com/RustCrypto/formats/pull/222 -[#223]: https://github.com/RustCrypto/formats/pull/223 -[#224]: https://github.com/RustCrypto/formats/pull/224 -[#230]: https://github.com/RustCrypto/formats/pull/230 - -## 0.7.6 (2021-09-14) -### Added -- `3des` and `des-insecure` features -- `sha1` feature -- Support for AES-192-CBC - -### Changed -- Moved to `formats` repo ([#2]) - -[#2]: https://github.com/RustCrypto/formats/pull/2 - -## 0.7.5 (2021-07-26) -### Added -- Support for customizing PEM `LineEnding` - -### Changed -- Bump `pem-rfc7468` dependency to v0.2 - -## 0.7.4 (2021-07-25) -### Added -- PKCS#1 support - -## 0.7.3 (2021-07-24) -### Changed -- Use `pem-rfc7468` crate - -## 0.7.2 (2021-07-20) -### Added -- `Error::ParametersMalformed` variant - -## 0.7.1 (2021-07-20) -### Added -- `Error::KeyMalformed` variant - -## 0.7.0 (2021-06-07) -### Added -- ASN.1 error improvements - -### Changed -- Merge `OneAsymmetricKey` into `PrivateKeyInfo` -- Use scrypt as the default PBES2 KDF -- Return `Result`(s) when encoding -- Bump `der` to v0.4 -- Bump `spki` to v0.4 -- Bump `pkcs5` to v0.3 - -## 0.6.1 (2021-05-24) -### Added -- Support for RFC5958's `OneAsymmetricKey` - -### Changed -- Bump `der` to v0.3.5 - -## 0.6.0 (2021-03-22) -### Changed -- Bump `der` dependency to v0.3 -- Bump `spki` dependency to v0.3 -- Bump `pkcs5` dependency to v0.2 - -## 0.5.5 (2021-03-17) -### Changed -- Bump `base64ct` dependency to v1.0 - -## 0.5.4 (2021-02-24) -### Added -- Encryption helper methods for `FromPrivateKey`/`ToPrivateKey` - -## 0.5.3 (2021-02-23) -### Added -- Support for decrypting/encrypting `EncryptedPrivateKeyInfo` -- PEM support for `EncryptedPrivateKeyInfo` -- `Error::Crypto` variant - -## 0.5.2 (2021-02-20) -### Changed -- Use `pkcs5` crate - -## 0.5.1 (2021-02-18) [YANKED] -### Added -- `pkcs5` feature - -### Changed -- Bump `spki` dependency to v0.2.0 - -## 0.5.0 (2021-02-16) [YANKED] -### Added -- Initial `EncryptedPrivateKeyInfo` support - -### Changed -- Extract SPKI-related types into the `spki` crate - -## 0.4.1 (2021-02-01) -### Changed -- Bump `basec4ct` dependency to v0.2 - -## 0.4.0 (2021-01-26) -### Changed -- Bump `der` crate dependency to v0.2 -- Use `base64ct` v0.1 for PEM encoding - -## 0.3.3 (2020-12-21) -### Changed -- Use `der` crate for decoding/encoding ASN.1 DER - -## 0.3.2 (2020-12-16) -### Added -- `AlgorithmIdentifier::parameters_oid` method - -## 0.3.1 (2020-12-16) -### Changed -- Bump `const-oid` dependency to v0.4 - -## 0.3.0 (2020-12-16) [YANKED] -### Added -- `AlgorithmParameters` enum - -## 0.2.2 (2020-12-14) -### Fixed -- Decoding/encoding support for Ed25519 keys - -## 0.2.1 (2020-12-14) -### Added -- rustdoc improvements - -## 0.2.0 (2020-12-14) -### Added -- File writing methods for public/private keys -- Methods for loading `*Document` types from files -- DER encoding support -- PEM encoding support -- `ToPrivateKey`/`ToPublicKey` traits - -### Changed -- `Error` enum -- Rename `load_*_file` methods to `read_*_file` - -## 0.1.1 (2020-12-06) -### Added -- Helper methods to load keys from the local filesystem - -## 0.1.0 (2020-12-05) -- Initial release diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/Cargo.toml deleted file mode 100644 index d8365512d546..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/Cargo.toml +++ /dev/null @@ -1,108 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -rust-version = "1.65" -name = "pkcs8" -version = "0.10.2" -authors = ["RustCrypto Developers"] -description = """ -Pure Rust implementation of Public-Key Cryptography Standards (PKCS) #8: -Private-Key Information Syntax Specification (RFC 5208), with additional -support for PKCS#8v2 asymmetric key packages (RFC 5958) -""" -readme = "README.md" -keywords = [ - "crypto", - "key", - "pkcs", - "private", -] -categories = [ - "cryptography", - "data-structures", - "encoding", - "no-std", - "parser-implementations", -] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/formats/tree/master/pkcs8" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = [ - "--cfg", - "docsrs", -] - -[dependencies.der] -version = "0.7" -features = ["oid"] - -[dependencies.pkcs5] -version = "0.7" -optional = true - -[dependencies.rand_core] -version = "0.6" -optional = true -default-features = false - -[dependencies.spki] -version = "0.7.1" - -[dependencies.subtle] -version = "2" -optional = true -default-features = false - -[dev-dependencies.hex-literal] -version = "0.3" - -[dev-dependencies.tempfile] -version = "3" - -[features] -3des = [ - "encryption", - "pkcs5/3des", -] -alloc = [ - "der/alloc", - "der/zeroize", - "spki/alloc", -] -des-insecure = [ - "encryption", - "pkcs5/des-insecure", -] -encryption = [ - "alloc", - "pkcs5/alloc", - "pkcs5/pbes2", - "rand_core", -] -getrandom = ["rand_core/getrandom"] -pem = [ - "alloc", - "der/pem", - "spki/pem", -] -sha1-insecure = [ - "encryption", - "pkcs5/sha1-insecure", -] -std = [ - "alloc", - "der/std", - "spki/std", -] diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/Cargo.toml.orig deleted file mode 100644 index 9ffae2b45a46..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/Cargo.toml.orig +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "pkcs8" -version = "0.10.2" -description = """ -Pure Rust implementation of Public-Key Cryptography Standards (PKCS) #8: -Private-Key Information Syntax Specification (RFC 5208), with additional -support for PKCS#8v2 asymmetric key packages (RFC 5958) -""" -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/formats/tree/master/pkcs8" -categories = ["cryptography", "data-structures", "encoding", "no-std", "parser-implementations"] -keywords = ["crypto", "key", "pkcs", "private"] -readme = "README.md" -edition = "2021" -rust-version = "1.65" - -[dependencies] -der = { version = "0.7", features = ["oid"], path = "../der" } -spki = { version = "0.7.1", path = "../spki" } - -# optional dependencies -rand_core = { version = "0.6", optional = true, default-features = false } -pkcs5 = { version = "0.7", optional = true, path = "../pkcs5" } -subtle = { version = "2", optional = true, default-features = false } - -[dev-dependencies] -hex-literal = "0.3" -tempfile = "3" - -[features] -alloc = ["der/alloc", "der/zeroize", "spki/alloc"] -std = ["alloc", "der/std", "spki/std"] - -3des = ["encryption", "pkcs5/3des"] -des-insecure = ["encryption", "pkcs5/des-insecure"] -encryption = ["alloc", "pkcs5/alloc", "pkcs5/pbes2", "rand_core"] -getrandom = ["rand_core/getrandom"] -pem = ["alloc", "der/pem", "spki/pem"] -sha1-insecure = ["encryption", "pkcs5/sha1-insecure"] - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-APACHE b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-APACHE deleted file mode 100644 index 78173fa2e753..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - 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. diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-MIT b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-MIT deleted file mode 100644 index e0d082780149..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2020-2023 The RustCrypto Project Developers - -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. diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/README.md b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/README.md deleted file mode 100644 index c1585439a440..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/README.md +++ /dev/null @@ -1,94 +0,0 @@ -# [RustCrypto]: PKCS#8 (Private Keys) - -[![crate][crate-image]][crate-link] -[![Docs][docs-image]][docs-link] -[![Build Status][build-image]][build-link] -![Apache2/MIT licensed][license-image] -![Rust Version][rustc-image] -[![Project Chat][chat-image]][chat-link] - -Pure Rust implementation of Public-Key Cryptography Standards (PKCS) #8: -Private-Key Information Syntax Specification ([RFC 5208]). - -[Documentation][docs-link] - -## About PKCS#8 - -PKCS#8 is a format for cryptographic private keys, often containing pairs -of private and public keys. - -You can identify a PKCS#8 private key encoded as PEM (i.e. text) by the -following: - -```text ------BEGIN PRIVATE KEY----- -``` - -PKCS#8 private keys can optionally be encrypted under a password using -key derivation algorithms like PBKDF2 and [scrypt], and encrypted with -ciphers like AES-CBC. When a PKCS#8 private key has been encrypted, -it starts with the following: - -```text ------BEGIN ENCRYPTED PRIVATE KEY----- -``` - -PKCS#8 private keys can also be serialized in an ASN.1-based binary format. -The PEM text encoding is a Base64 representation of this format. - -## Supported Algorithms - -This crate is implemented in an algorithm-agnostic manner with the goal of -enabling PKCS#8 support for any algorithm. - -That said, it has been tested for interoperability against keys generated by -OpenSSL for the following algorithms: - -- ECC (`id-ecPublicKey`) -- Ed25519 (`id-Ed25519`) -- RSA (`id-rsaEncryption`) -- X25519 (`id-X25519`) - -Please open an issue if you encounter trouble using it with a particular -algorithm, including the ones listed above or other algorithms. - -## Minimum Supported Rust Version - -This crate requires **Rust 1.65** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - -## License - -Licensed under either of: - - * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) - * [MIT license](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. - -[//]: # (badges) - -[crate-image]: https://buildstats.info/crate/pkcs8 -[crate-link]: https://crates.io/crates/pkcs8 -[docs-image]: https://docs.rs/pkcs8/badge.svg -[docs-link]: https://docs.rs/pkcs8/ -[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.65+-blue.svg -[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg -[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/300570-formats -[build-image]: https://github.com/RustCrypto/formats/workflows/pkcs8/badge.svg?branch=master&event=push -[build-link]: https://github.com/RustCrypto/formats/actions - -[//]: # (links) - -[RustCrypto]: https://github.com/rustcrypto -[RFC 5208]: https://tools.ietf.org/html/rfc5208 -[scrypt]: https://en.wikipedia.org/wiki/Scrypt diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/encrypted_private_key_info.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/encrypted_private_key_info.rs deleted file mode 100644 index d55949cad6c0..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/encrypted_private_key_info.rs +++ /dev/null @@ -1,165 +0,0 @@ -//! PKCS#8 `EncryptedPrivateKeyInfo` - -use crate::{Error, Result}; -use core::fmt; -use der::{ - asn1::OctetStringRef, Decode, DecodeValue, Encode, EncodeValue, Header, Length, Reader, - Sequence, Writer, -}; -use pkcs5::EncryptionScheme; - -#[cfg(feature = "alloc")] -use der::SecretDocument; - -#[cfg(feature = "encryption")] -use { - pkcs5::pbes2, - rand_core::{CryptoRng, RngCore}, -}; - -#[cfg(feature = "pem")] -use der::pem::PemLabel; - -/// PKCS#8 `EncryptedPrivateKeyInfo`. -/// -/// ASN.1 structure containing a PKCS#5 [`EncryptionScheme`] identifier for a -/// password-based symmetric encryption scheme and encrypted private key data. -/// -/// ## Schema -/// Structure described in [RFC 5208 Section 6]: -/// -/// ```text -/// EncryptedPrivateKeyInfo ::= SEQUENCE { -/// encryptionAlgorithm EncryptionAlgorithmIdentifier, -/// encryptedData EncryptedData } -/// -/// EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier -/// -/// EncryptedData ::= OCTET STRING -/// ``` -/// -/// [RFC 5208 Section 6]: https://tools.ietf.org/html/rfc5208#section-6 -#[derive(Clone, Eq, PartialEq)] -pub struct EncryptedPrivateKeyInfo<'a> { - /// Algorithm identifier describing a password-based symmetric encryption - /// scheme used to encrypt the `encrypted_data` field. - pub encryption_algorithm: EncryptionScheme<'a>, - - /// Private key data - pub encrypted_data: &'a [u8], -} - -impl<'a> EncryptedPrivateKeyInfo<'a> { - /// Attempt to decrypt this encrypted private key using the provided - /// password to derive an encryption key. - #[cfg(feature = "encryption")] - pub fn decrypt(&self, password: impl AsRef<[u8]>) -> Result { - Ok(self - .encryption_algorithm - .decrypt(password, self.encrypted_data)? - .try_into()?) - } - - /// Encrypt the given ASN.1 DER document using a symmetric encryption key - /// derived from the provided password. - #[cfg(feature = "encryption")] - pub(crate) fn encrypt( - mut rng: impl CryptoRng + RngCore, - password: impl AsRef<[u8]>, - doc: &[u8], - ) -> Result { - let mut salt = [0u8; 16]; - rng.fill_bytes(&mut salt); - - let mut iv = [0u8; 16]; - rng.fill_bytes(&mut iv); - - let pbes2_params = pbes2::Parameters::scrypt_aes256cbc(Default::default(), &salt, &iv)?; - EncryptedPrivateKeyInfo::encrypt_with(pbes2_params, password, doc) - } - - /// Encrypt this private key using a symmetric encryption key derived - /// from the provided password and [`pbes2::Parameters`]. - #[cfg(feature = "encryption")] - pub(crate) fn encrypt_with( - pbes2_params: pbes2::Parameters<'a>, - password: impl AsRef<[u8]>, - doc: &[u8], - ) -> Result { - let encrypted_data = pbes2_params.encrypt(password, doc)?; - - EncryptedPrivateKeyInfo { - encryption_algorithm: pbes2_params.into(), - encrypted_data: &encrypted_data, - } - .try_into() - } -} - -impl<'a> DecodeValue<'a> for EncryptedPrivateKeyInfo<'a> { - fn decode_value>( - reader: &mut R, - header: Header, - ) -> der::Result> { - reader.read_nested(header.length, |reader| { - Ok(Self { - encryption_algorithm: reader.decode()?, - encrypted_data: OctetStringRef::decode(reader)?.as_bytes(), - }) - }) - } -} - -impl EncodeValue for EncryptedPrivateKeyInfo<'_> { - fn value_len(&self) -> der::Result { - self.encryption_algorithm.encoded_len()? - + OctetStringRef::new(self.encrypted_data)?.encoded_len()? - } - - fn encode_value(&self, writer: &mut impl Writer) -> der::Result<()> { - self.encryption_algorithm.encode(writer)?; - OctetStringRef::new(self.encrypted_data)?.encode(writer)?; - Ok(()) - } -} - -impl<'a> Sequence<'a> for EncryptedPrivateKeyInfo<'a> {} - -impl<'a> TryFrom<&'a [u8]> for EncryptedPrivateKeyInfo<'a> { - type Error = Error; - - fn try_from(bytes: &'a [u8]) -> Result { - Ok(Self::from_der(bytes)?) - } -} - -impl<'a> fmt::Debug for EncryptedPrivateKeyInfo<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("EncryptedPrivateKeyInfo") - .field("encryption_algorithm", &self.encryption_algorithm) - .finish_non_exhaustive() - } -} - -#[cfg(feature = "alloc")] -impl TryFrom> for SecretDocument { - type Error = Error; - - fn try_from(encrypted_private_key: EncryptedPrivateKeyInfo<'_>) -> Result { - SecretDocument::try_from(&encrypted_private_key) - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<&EncryptedPrivateKeyInfo<'_>> for SecretDocument { - type Error = Error; - - fn try_from(encrypted_private_key: &EncryptedPrivateKeyInfo<'_>) -> Result { - Ok(Self::encode_msg(encrypted_private_key)?) - } -} - -#[cfg(feature = "pem")] -impl PemLabel for EncryptedPrivateKeyInfo<'_> { - const PEM_LABEL: &'static str = "ENCRYPTED PRIVATE KEY"; -} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/error.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/error.rs deleted file mode 100644 index 70c60aedb407..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/error.rs +++ /dev/null @@ -1,93 +0,0 @@ -//! Error types - -use core::fmt; - -#[cfg(feature = "pem")] -use der::pem; - -/// Result type -pub type Result = core::result::Result; - -/// Error type -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[non_exhaustive] -pub enum Error { - /// ASN.1 DER-related errors. - Asn1(der::Error), - - /// Errors relating to PKCS#5-encrypted keys. - #[cfg(feature = "pkcs5")] - EncryptedPrivateKey(pkcs5::Error), - - /// Malformed cryptographic key contained in a PKCS#8 document. - /// - /// This is intended for relaying errors related to the raw data contained - /// within [`PrivateKeyInfo::private_key`][`crate::PrivateKeyInfo::private_key`] - /// or [`SubjectPublicKeyInfo::subject_public_key`][`crate::SubjectPublicKeyInfo::subject_public_key`]. - KeyMalformed, - - /// [`AlgorithmIdentifier::parameters`][`crate::AlgorithmIdentifierRef::parameters`] - /// is malformed or otherwise encoded in an unexpected manner. - ParametersMalformed, - - /// Public key errors propagated from the [`spki::Error`] type. - PublicKey(spki::Error), -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Error::Asn1(err) => write!(f, "PKCS#8 ASN.1 error: {}", err), - #[cfg(feature = "pkcs5")] - Error::EncryptedPrivateKey(err) => write!(f, "{}", err), - Error::KeyMalformed => f.write_str("PKCS#8 cryptographic key data malformed"), - Error::ParametersMalformed => f.write_str("PKCS#8 algorithm parameters malformed"), - Error::PublicKey(err) => write!(f, "public key error: {}", err), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} - -impl From for Error { - fn from(err: der::Error) -> Error { - Error::Asn1(err) - } -} - -impl From for Error { - fn from(err: der::ErrorKind) -> Error { - Error::Asn1(err.into()) - } -} - -#[cfg(feature = "pem")] -impl From for Error { - fn from(err: pem::Error) -> Error { - der::Error::from(err).into() - } -} - -#[cfg(feature = "pkcs5")] -impl From for Error { - fn from(err: pkcs5::Error) -> Error { - Error::EncryptedPrivateKey(err) - } -} - -impl From for Error { - fn from(err: spki::Error) -> Error { - Error::PublicKey(err) - } -} - -impl From for spki::Error { - fn from(err: Error) -> spki::Error { - match err { - Error::Asn1(e) => spki::Error::Asn1(e), - Error::PublicKey(e) => e, - _ => spki::Error::KeyMalformed, - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/lib.rs deleted file mode 100644 index 33ceef8e26c5..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/lib.rs +++ /dev/null @@ -1,111 +0,0 @@ -#![no_std] -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![doc = include_str!("../README.md")] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" -)] -#![forbid(unsafe_code)] -#![warn( - clippy::mod_module_files, - clippy::unwrap_used, - missing_docs, - rust_2018_idioms, - unused_lifetimes, - unused_qualifications -)] - -//! ## About this crate -//! This library provides generalized PKCS#8 support designed to work with a -//! number of different algorithms. It supports `no_std` platforms including -//! ones without a heap (albeit with reduced functionality). -//! -//! It supports decoding/encoding the following types: -//! -//! - [`EncryptedPrivateKeyInfo`]: (with `pkcs5` feature) encrypted key. -//! - [`PrivateKeyInfo`]: algorithm identifier and data representing a private key. -//! Optionally also includes public key data for asymmetric keys. -//! - [`SubjectPublicKeyInfo`]: algorithm identifier and data representing a public key -//! (re-exported from the [`spki`] crate) -//! -//! When the `pem` feature is enabled, it also supports decoding/encoding -//! documents from "PEM encoding" format as defined in RFC 7468. -//! -//! ## Encrypted Private Key Support -//! [`EncryptedPrivateKeyInfo`] supports decoding/encoding encrypted PKCS#8 -//! private keys and is gated under the `pkcs5` feature. -//! -//! When the `encryption` feature of this crate is enabled, it provides -//! [`EncryptedPrivateKeyInfo::decrypt`] and [`PrivateKeyInfo::encrypt`] -//! functions which are able to decrypt/encrypt keys using the following -//! algorithms: -//! -//! - [PKCS#5v2 Password Based Encryption Scheme 2 (RFC 8018)] -//! - Key derivation functions: -//! - [scrypt] ([RFC 7914]) -//! - PBKDF2 ([RFC 8018](https://datatracker.ietf.org/doc/html/rfc8018#section-5.2)) -//! - SHA-2 based PRF with HMAC-SHA224, HMAC-SHA256, HMAC-SHA384, or HMAC-SHA512 -//! - SHA-1 based PRF with HMAC-SHA1, when the `sha1` feature of this crate is enabled. -//! - Symmetric encryption: AES-128-CBC, AES-192-CBC, or AES-256-CBC -//! (best available options for PKCS#5v2) -//! -//! ## Legacy DES-CBC and DES-EDE3-CBC (3DES) support (optional) -//! When the `des-insecure` and/or `3des` features are enabled this crate provides support for -//! private keys encrypted with with DES-CBC and DES-EDE3-CBC (3DES or Triple DES) symmetric -//! encryption, respectively. -//! -//! ⚠️ WARNING ⚠️ -//! -//! DES support (gated behind the `des-insecure` feature) is implemented to -//! allow for decryption of legacy PKCS#8 files only. -//! -//! Such PKCS#8 documents should be considered *INSECURE* due to the short -//! 56-bit key size of DES. -//! -//! New keys should use AES instead. -//! -//! [RFC 5208]: https://tools.ietf.org/html/rfc5208 -//! [RFC 5958]: https://tools.ietf.org/html/rfc5958 -//! [RFC 7914]: https://datatracker.ietf.org/doc/html/rfc7914 -//! [PKCS#5v2 Password Based Encryption Scheme 2 (RFC 8018)]: https://tools.ietf.org/html/rfc8018#section-6.2 -//! [scrypt]: https://en.wikipedia.org/wiki/Scrypt - -#[cfg(feature = "pem")] -extern crate alloc; -#[cfg(feature = "std")] -extern crate std; - -mod error; -mod private_key_info; -mod traits; -mod version; - -#[cfg(feature = "pkcs5")] -pub(crate) mod encrypted_private_key_info; - -pub use crate::{ - error::{Error, Result}, - private_key_info::PrivateKeyInfo, - traits::DecodePrivateKey, - version::Version, -}; -pub use der::{self, asn1::ObjectIdentifier, oid::AssociatedOid}; -pub use spki::{ - self, AlgorithmIdentifierRef, DecodePublicKey, SubjectPublicKeyInfo, SubjectPublicKeyInfoRef, -}; - -#[cfg(feature = "alloc")] -pub use { - crate::traits::EncodePrivateKey, - der::{Document, SecretDocument}, - spki::EncodePublicKey, -}; - -#[cfg(feature = "pem")] -pub use der::pem::LineEnding; - -#[cfg(feature = "pkcs5")] -pub use {encrypted_private_key_info::EncryptedPrivateKeyInfo, pkcs5}; - -#[cfg(feature = "rand_core")] -pub use rand_core; diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/private_key_info.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/private_key_info.rs deleted file mode 100644 index ecae624df5b6..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/private_key_info.rs +++ /dev/null @@ -1,295 +0,0 @@ -//! PKCS#8 `PrivateKeyInfo`. - -use crate::{AlgorithmIdentifierRef, Error, Result, Version}; -use core::fmt; -use der::{ - asn1::{AnyRef, BitStringRef, ContextSpecific, OctetStringRef}, - Decode, DecodeValue, Encode, EncodeValue, Header, Length, Reader, Sequence, TagMode, TagNumber, - Writer, -}; - -#[cfg(feature = "alloc")] -use der::SecretDocument; - -#[cfg(feature = "encryption")] -use { - crate::EncryptedPrivateKeyInfo, - der::zeroize::Zeroizing, - pkcs5::pbes2, - rand_core::{CryptoRng, RngCore}, -}; - -#[cfg(feature = "pem")] -use der::pem::PemLabel; - -#[cfg(feature = "subtle")] -use subtle::{Choice, ConstantTimeEq}; - -/// Context-specific tag number for the public key. -const PUBLIC_KEY_TAG: TagNumber = TagNumber::N1; - -/// PKCS#8 `PrivateKeyInfo`. -/// -/// ASN.1 structure containing an `AlgorithmIdentifier`, private key -/// data in an algorithm specific format, and optional attributes -/// (ignored by this implementation). -/// -/// Supports PKCS#8 v1 as described in [RFC 5208] and PKCS#8 v2 as described -/// in [RFC 5958]. PKCS#8 v2 keys include an additional public key field. -/// -/// # PKCS#8 v1 `PrivateKeyInfo` -/// -/// Described in [RFC 5208 Section 5]: -/// -/// ```text -/// PrivateKeyInfo ::= SEQUENCE { -/// version Version, -/// privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, -/// privateKey PrivateKey, -/// attributes [0] IMPLICIT Attributes OPTIONAL } -/// -/// Version ::= INTEGER -/// -/// PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier -/// -/// PrivateKey ::= OCTET STRING -/// -/// Attributes ::= SET OF Attribute -/// ``` -/// -/// # PKCS#8 v2 `OneAsymmetricKey` -/// -/// PKCS#8 `OneAsymmetricKey` as described in [RFC 5958 Section 2]: -/// -/// ```text -/// PrivateKeyInfo ::= OneAsymmetricKey -/// -/// OneAsymmetricKey ::= SEQUENCE { -/// version Version, -/// privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, -/// privateKey PrivateKey, -/// attributes [0] Attributes OPTIONAL, -/// ..., -/// [[2: publicKey [1] PublicKey OPTIONAL ]], -/// ... -/// } -/// -/// Version ::= INTEGER { v1(0), v2(1) } (v1, ..., v2) -/// -/// PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier -/// -/// PrivateKey ::= OCTET STRING -/// -/// Attributes ::= SET OF Attribute -/// -/// PublicKey ::= BIT STRING -/// ``` -/// -/// [RFC 5208]: https://tools.ietf.org/html/rfc5208 -/// [RFC 5958]: https://datatracker.ietf.org/doc/html/rfc5958 -/// [RFC 5208 Section 5]: https://tools.ietf.org/html/rfc5208#section-5 -/// [RFC 5958 Section 2]: https://datatracker.ietf.org/doc/html/rfc5958#section-2 -#[derive(Clone)] -pub struct PrivateKeyInfo<'a> { - /// X.509 `AlgorithmIdentifier` for the private key type. - pub algorithm: AlgorithmIdentifierRef<'a>, - - /// Private key data. - pub private_key: &'a [u8], - - /// Public key data, optionally available if version is V2. - pub public_key: Option<&'a [u8]>, -} - -impl<'a> PrivateKeyInfo<'a> { - /// Create a new PKCS#8 [`PrivateKeyInfo`] message. - /// - /// This is a helper method which initializes `attributes` and `public_key` - /// to `None`, helpful if you aren't using those. - pub fn new(algorithm: AlgorithmIdentifierRef<'a>, private_key: &'a [u8]) -> Self { - Self { - algorithm, - private_key, - public_key: None, - } - } - - /// Get the PKCS#8 [`Version`] for this structure. - /// - /// [`Version::V1`] if `public_key` is `None`, [`Version::V2`] if `Some`. - pub fn version(&self) -> Version { - if self.public_key.is_some() { - Version::V2 - } else { - Version::V1 - } - } - - /// Encrypt this private key using a symmetric encryption key derived - /// from the provided password. - /// - /// Uses the following algorithms for encryption: - /// - PBKDF: scrypt with default parameters: - /// - log₂(N): 15 - /// - r: 8 - /// - p: 1 - /// - Cipher: AES-256-CBC (best available option for PKCS#5 encryption) - #[cfg(feature = "encryption")] - pub fn encrypt( - &self, - rng: impl CryptoRng + RngCore, - password: impl AsRef<[u8]>, - ) -> Result { - let der = Zeroizing::new(self.to_der()?); - EncryptedPrivateKeyInfo::encrypt(rng, password, der.as_ref()) - } - - /// Encrypt this private key using a symmetric encryption key derived - /// from the provided password and [`pbes2::Parameters`]. - #[cfg(feature = "encryption")] - pub fn encrypt_with_params( - &self, - pbes2_params: pbes2::Parameters<'_>, - password: impl AsRef<[u8]>, - ) -> Result { - let der = Zeroizing::new(self.to_der()?); - EncryptedPrivateKeyInfo::encrypt_with(pbes2_params, password, der.as_ref()) - } - - /// Get a `BIT STRING` representation of the public key, if present. - fn public_key_bit_string(&self) -> der::Result>>> { - self.public_key - .map(|pk| { - BitStringRef::from_bytes(pk).map(|value| ContextSpecific { - tag_number: PUBLIC_KEY_TAG, - tag_mode: TagMode::Implicit, - value, - }) - }) - .transpose() - } -} - -impl<'a> DecodeValue<'a> for PrivateKeyInfo<'a> { - fn decode_value>( - reader: &mut R, - header: Header, - ) -> der::Result> { - reader.read_nested(header.length, |reader| { - // Parse and validate `version` INTEGER. - let version = Version::decode(reader)?; - let algorithm = reader.decode()?; - let private_key = OctetStringRef::decode(reader)?.into(); - let public_key = reader - .context_specific::>(PUBLIC_KEY_TAG, TagMode::Implicit)? - .map(|bs| { - bs.as_bytes() - .ok_or_else(|| der::Tag::BitString.value_error()) - }) - .transpose()?; - - if version.has_public_key() != public_key.is_some() { - return Err(reader.error( - der::Tag::ContextSpecific { - constructed: true, - number: PUBLIC_KEY_TAG, - } - .value_error() - .kind(), - )); - } - - // Ignore any remaining extension fields - while !reader.is_finished() { - reader.decode::>>()?; - } - - Ok(Self { - algorithm, - private_key, - public_key, - }) - }) - } -} - -impl EncodeValue for PrivateKeyInfo<'_> { - fn value_len(&self) -> der::Result { - self.version().encoded_len()? - + self.algorithm.encoded_len()? - + OctetStringRef::new(self.private_key)?.encoded_len()? - + self.public_key_bit_string()?.encoded_len()? - } - - fn encode_value(&self, writer: &mut impl Writer) -> der::Result<()> { - self.version().encode(writer)?; - self.algorithm.encode(writer)?; - OctetStringRef::new(self.private_key)?.encode(writer)?; - self.public_key_bit_string()?.encode(writer)?; - Ok(()) - } -} - -impl<'a> Sequence<'a> for PrivateKeyInfo<'a> {} - -impl<'a> TryFrom<&'a [u8]> for PrivateKeyInfo<'a> { - type Error = Error; - - fn try_from(bytes: &'a [u8]) -> Result { - Ok(Self::from_der(bytes)?) - } -} - -impl<'a> fmt::Debug for PrivateKeyInfo<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("PrivateKeyInfo") - .field("version", &self.version()) - .field("algorithm", &self.algorithm) - .field("public_key", &self.public_key) - .finish_non_exhaustive() - } -} - -#[cfg(feature = "alloc")] -impl TryFrom> for SecretDocument { - type Error = Error; - - fn try_from(private_key: PrivateKeyInfo<'_>) -> Result { - SecretDocument::try_from(&private_key) - } -} - -#[cfg(feature = "alloc")] -impl TryFrom<&PrivateKeyInfo<'_>> for SecretDocument { - type Error = Error; - - fn try_from(private_key: &PrivateKeyInfo<'_>) -> Result { - Ok(Self::encode_msg(private_key)?) - } -} - -#[cfg(feature = "pem")] -impl PemLabel for PrivateKeyInfo<'_> { - const PEM_LABEL: &'static str = "PRIVATE KEY"; -} - -#[cfg(feature = "subtle")] -impl<'a> ConstantTimeEq for PrivateKeyInfo<'a> { - fn ct_eq(&self, other: &Self) -> Choice { - // NOTE: public fields are not compared in constant time - let public_fields_eq = - self.algorithm == other.algorithm && self.public_key == other.public_key; - - self.private_key.ct_eq(other.private_key) & Choice::from(public_fields_eq as u8) - } -} - -#[cfg(feature = "subtle")] -impl<'a> Eq for PrivateKeyInfo<'a> {} - -#[cfg(feature = "subtle")] -impl<'a> PartialEq for PrivateKeyInfo<'a> { - fn eq(&self, other: &Self) -> bool { - self.ct_eq(other).into() - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/traits.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/traits.rs deleted file mode 100644 index b4f80b2e76ea..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/traits.rs +++ /dev/null @@ -1,140 +0,0 @@ -//! Traits for parsing objects from PKCS#8 encoded documents - -use crate::{Error, PrivateKeyInfo, Result}; - -#[cfg(feature = "alloc")] -use der::SecretDocument; - -#[cfg(feature = "encryption")] -use { - crate::EncryptedPrivateKeyInfo, - rand_core::{CryptoRng, RngCore}, -}; - -#[cfg(feature = "pem")] -use {crate::LineEnding, alloc::string::String, der::zeroize::Zeroizing}; - -#[cfg(feature = "pem")] -use der::pem::PemLabel; - -#[cfg(feature = "std")] -use std::path::Path; - -/// Parse a private key object from a PKCS#8 encoded document. -pub trait DecodePrivateKey: Sized { - /// Deserialize PKCS#8 private key from ASN.1 DER-encoded data - /// (binary format). - fn from_pkcs8_der(bytes: &[u8]) -> Result; - - /// Deserialize encrypted PKCS#8 private key from ASN.1 DER-encoded data - /// (binary format) and attempt to decrypt it using the provided password. - #[cfg(feature = "encryption")] - fn from_pkcs8_encrypted_der(bytes: &[u8], password: impl AsRef<[u8]>) -> Result { - let doc = EncryptedPrivateKeyInfo::try_from(bytes)?.decrypt(password)?; - Self::from_pkcs8_der(doc.as_bytes()) - } - - /// Deserialize PKCS#8-encoded private key from PEM. - /// - /// Keys in this format begin with the following delimiter: - /// - /// ```text - /// -----BEGIN PRIVATE KEY----- - /// ``` - #[cfg(feature = "pem")] - fn from_pkcs8_pem(s: &str) -> Result { - let (label, doc) = SecretDocument::from_pem(s)?; - PrivateKeyInfo::validate_pem_label(label)?; - Self::from_pkcs8_der(doc.as_bytes()) - } - - /// Deserialize encrypted PKCS#8-encoded private key from PEM and attempt - /// to decrypt it using the provided password. - /// - /// Keys in this format begin with the following delimiter: - /// - /// ```text - /// -----BEGIN ENCRYPTED PRIVATE KEY----- - /// ``` - #[cfg(all(feature = "encryption", feature = "pem"))] - fn from_pkcs8_encrypted_pem(s: &str, password: impl AsRef<[u8]>) -> Result { - let (label, doc) = SecretDocument::from_pem(s)?; - EncryptedPrivateKeyInfo::validate_pem_label(label)?; - Self::from_pkcs8_encrypted_der(doc.as_bytes(), password) - } - - /// Load PKCS#8 private key from an ASN.1 DER-encoded file on the local - /// filesystem (binary format). - #[cfg(feature = "std")] - fn read_pkcs8_der_file(path: impl AsRef) -> Result { - Self::from_pkcs8_der(SecretDocument::read_der_file(path)?.as_bytes()) - } - - /// Load PKCS#8 private key from a PEM-encoded file on the local filesystem. - #[cfg(all(feature = "pem", feature = "std"))] - fn read_pkcs8_pem_file(path: impl AsRef) -> Result { - let (label, doc) = SecretDocument::read_pem_file(path)?; - PrivateKeyInfo::validate_pem_label(&label)?; - Self::from_pkcs8_der(doc.as_bytes()) - } -} - -impl DecodePrivateKey for T -where - T: for<'a> TryFrom, Error = Error>, -{ - fn from_pkcs8_der(bytes: &[u8]) -> Result { - Self::try_from(PrivateKeyInfo::try_from(bytes)?) - } -} - -/// Serialize a private key object to a PKCS#8 encoded document. -#[cfg(feature = "alloc")] -pub trait EncodePrivateKey { - /// Serialize a [`SecretDocument`] containing a PKCS#8-encoded private key. - fn to_pkcs8_der(&self) -> Result; - - /// Create an [`SecretDocument`] containing the ciphertext of - /// a PKCS#8 encoded private key encrypted under the given `password`. - #[cfg(feature = "encryption")] - fn to_pkcs8_encrypted_der( - &self, - rng: impl CryptoRng + RngCore, - password: impl AsRef<[u8]>, - ) -> Result { - EncryptedPrivateKeyInfo::encrypt(rng, password, self.to_pkcs8_der()?.as_bytes()) - } - - /// Serialize this private key as PEM-encoded PKCS#8 with the given [`LineEnding`]. - #[cfg(feature = "pem")] - fn to_pkcs8_pem(&self, line_ending: LineEnding) -> Result> { - let doc = self.to_pkcs8_der()?; - Ok(doc.to_pem(PrivateKeyInfo::PEM_LABEL, line_ending)?) - } - - /// Serialize this private key as an encrypted PEM-encoded PKCS#8 private - /// key using the `provided` to derive an encryption key. - #[cfg(all(feature = "encryption", feature = "pem"))] - fn to_pkcs8_encrypted_pem( - &self, - rng: impl CryptoRng + RngCore, - password: impl AsRef<[u8]>, - line_ending: LineEnding, - ) -> Result> { - let doc = self.to_pkcs8_encrypted_der(rng, password)?; - Ok(doc.to_pem(EncryptedPrivateKeyInfo::PEM_LABEL, line_ending)?) - } - - /// Write ASN.1 DER-encoded PKCS#8 private key to the given path - #[cfg(feature = "std")] - fn write_pkcs8_der_file(&self, path: impl AsRef) -> Result<()> { - Ok(self.to_pkcs8_der()?.write_der_file(path)?) - } - - /// Write ASN.1 DER-encoded PKCS#8 private key to the given path - #[cfg(all(feature = "pem", feature = "std"))] - fn write_pkcs8_pem_file(&self, path: impl AsRef, line_ending: LineEnding) -> Result<()> { - let doc = self.to_pkcs8_der()?; - Ok(doc.write_pem_file(path, PrivateKeyInfo::PEM_LABEL, line_ending)?) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/version.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/version.rs deleted file mode 100644 index 0ca80bc482bd..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/version.rs +++ /dev/null @@ -1,63 +0,0 @@ -//! PKCS#8 version identifier. - -use crate::Error; -use der::{Decode, Encode, FixedTag, Reader, Tag, Writer}; - -/// Version identifier for PKCS#8 documents. -/// -/// (RFC 5958 designates `0` and `1` as the only valid versions for PKCS#8 documents) -#[derive(Clone, Debug, Copy, PartialEq, Eq)] -pub enum Version { - /// Denotes PKCS#8 v1: no public key field. - V1 = 0, - - /// Denotes PKCS#8 v2: `OneAsymmetricKey` with public key field. - V2 = 1, -} - -impl Version { - /// Is this version expected to have a public key? - pub fn has_public_key(self) -> bool { - match self { - Version::V1 => false, - Version::V2 => true, - } - } -} - -impl<'a> Decode<'a> for Version { - fn decode>(decoder: &mut R) -> der::Result { - Version::try_from(u8::decode(decoder)?).map_err(|_| Self::TAG.value_error()) - } -} - -impl Encode for Version { - fn encoded_len(&self) -> der::Result { - der::Length::from(1u8).for_tlv() - } - - fn encode(&self, writer: &mut impl Writer) -> der::Result<()> { - u8::from(*self).encode(writer) - } -} - -impl From for u8 { - fn from(version: Version) -> Self { - version as u8 - } -} - -impl TryFrom for Version { - type Error = Error; - fn try_from(byte: u8) -> Result { - match byte { - 0 => Ok(Version::V1), - 1 => Ok(Version::V2), - _ => Err(Self::TAG.value_error().into()), - } - } -} - -impl FixedTag for Version { - const TAG: Tag = Tag::Integer; -} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/encrypted_private_key.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/encrypted_private_key.rs deleted file mode 100644 index dbe0a18e7f41..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/encrypted_private_key.rs +++ /dev/null @@ -1,234 +0,0 @@ -//! Encrypted PKCS#8 private key tests. - -#![cfg(feature = "pkcs5")] - -use hex_literal::hex; -use pkcs8::{pkcs5::pbes2, EncryptedPrivateKeyInfo, PrivateKeyInfo}; - -#[cfg(feature = "alloc")] -use der::Encode; - -#[cfg(feature = "pem")] -use der::EncodePem; - -/// Ed25519 PKCS#8 private key plaintext encoded as ASN.1 DER -#[cfg(feature = "encryption")] -const ED25519_DER_PLAINTEXT_EXAMPLE: &[u8] = include_bytes!("examples/ed25519-priv-pkcs8v1.der"); - -/// Ed25519 PKCS#8 encrypted private key (PBES2 + AES-128-CBC + PBKDF2-SHA1) encoded as ASN.1 DER. -/// -/// Generated using: -/// -/// ``` -/// $ openssl pkcs8 -v2 aes256-cbc -v2prf hmacWithSHA1 -topk8 -inform der -in ed25519-priv.der -outform der -out ed25519-encpriv-aes128-pbkdf2-sha1.der -/// ``` -const ED25519_DER_AES128_PBKDF2_SHA1_EXAMPLE: &[u8] = - include_bytes!("examples/ed25519-encpriv-aes128-pbkdf2-sha1.der"); - -/// Ed25519 PKCS#8 encrypted private key (PBES2 + AES-256-CBC + PBKDF2-SHA256) encoded as ASN.1 DER. -/// -/// Generated using: -/// -/// ``` -/// $ openssl pkcs8 -v2 aes256-cbc -v2prf hmacWithSHA256 -topk8 -inform der -in ed25519-priv.der -outform der -out ed25519-encpriv-aes256-pbkdf2-sha256.der -/// ``` -const ED25519_DER_AES256_PBKDF2_SHA256_EXAMPLE: &[u8] = - include_bytes!("examples/ed25519-encpriv-aes256-pbkdf2-sha256.der"); - -/// Ed25519 PKCS#8 encrypted private key (PBES2 + AES-256-CBC + scrypt) encoded as ASN.1 DER. -/// -/// Generated using: -/// -/// ``` -/// $ openssl pkcs8 -v2 aes256-cbc -scrypt -topk8 -inform der -in ed25519-priv.der -outform der -out ed25519-encpriv-aes256-scrypt.der -/// ``` -#[cfg(feature = "encryption")] -const ED25519_DER_AES256_SCRYPT_EXAMPLE: &[u8] = - include_bytes!("examples/ed25519-encpriv-aes256-scrypt.der"); - -/// Ed25519 PKCS#8 encrypted private key encoded as PEM -#[cfg(feature = "pem")] -const ED25519_PEM_AES256_PBKDF2_SHA256_EXAMPLE: &str = - include_str!("examples/ed25519-encpriv-aes256-pbkdf2-sha256.pem"); - -/// Ed25519 PKCS#8 encrypted private key (PBES2 + 3DES + PBKDF2-SHA256) encoded as ASN.1 DER -/// -/// Generated using: -/// -/// ``` -/// $ openssl pkcs8 -v2 des3 -topk8 -inform der -in ed25519-priv-pkcs8v1.der -outform der -out ed25519-encpriv-des3-pbkdf2-sha256.der -/// ``` -#[cfg(feature = "3des")] -const ED25519_DER_DES3_PBKDF2_SHA256_EXAMPLE: &[u8] = - include_bytes!("examples/ed25519-encpriv-des3-pbkdf2-sha256.der"); - -/// Ed25519 PKCS#8 encrypted private key (PBES2 + DES + PBKDF2-SHA256) encoded as ASN.1 DER -/// -/// Generated using: -/// -/// ``` -/// $ openssl pkcs8 -v2 des -topk8 -inform der -in ed25519-priv-pkcs8v1.der -outform der -out ed25519-encpriv-des3-pbkdf2-sha256.der -/// ``` -#[cfg(feature = "des-insecure")] -const ED25519_DER_DES_PBKDF2_SHA256_EXAMPLE: &[u8] = - include_bytes!("examples/ed25519-encpriv-des-pbkdf2-sha256.der"); - -/// Password used to encrypt the keys. -#[cfg(feature = "encryption")] -const PASSWORD: &[u8] = b"hunter42"; // Bad password; don't actually use outside tests! - -#[test] -fn decode_ed25519_encpriv_aes128_pbkdf2_sha1_der() { - let pk = EncryptedPrivateKeyInfo::try_from(ED25519_DER_AES128_PBKDF2_SHA1_EXAMPLE).unwrap(); - - assert_eq!( - pk.encryption_algorithm.oid(), - "1.2.840.113549.1.5.13".parse().unwrap() - ); // PBES2 - - let pbes2_params = pk.encryption_algorithm.pbes2().unwrap(); - let pbkdf2_params = pbes2_params.kdf.pbkdf2().unwrap(); - - assert_eq!(pbkdf2_params.salt, hex!("e8765e01e43b6bad")); - assert_eq!(pbkdf2_params.iteration_count, 2048); - assert_eq!(pbkdf2_params.key_length, None); - assert_eq!(pbkdf2_params.prf, pbes2::Pbkdf2Prf::HmacWithSha1); - - match pbes2_params.encryption { - pbes2::EncryptionScheme::Aes128Cbc { iv } => { - assert_eq!(iv, &hex!("223080a71bcd2b9a256d876c924979d2")); - } - other => panic!("unexpected encryption scheme: {:?}", other), - } - - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/ed25519-encpriv-aes128-sha1.der - assert_eq!( - pk.encrypted_data, - &hex!("4B4D091548EAC381EE7663B21234CD4FF3C9DF664D713394CACCEA7C9B982BD8F29910FABCA4BF7BE0431FAC5C4D657BE997C1F5BF40E2DA465AC1FCC2E30470") - ); -} - -#[test] -fn decode_ed25519_encpriv_aes256_pbkdf2_sha256_der() { - let pk = EncryptedPrivateKeyInfo::try_from(ED25519_DER_AES256_PBKDF2_SHA256_EXAMPLE).unwrap(); - - assert_eq!( - pk.encryption_algorithm.oid(), - "1.2.840.113549.1.5.13".parse().unwrap() - ); // PBES2 - - let pbes2_params = pk.encryption_algorithm.pbes2().unwrap(); - let pbkdf2_params = pbes2_params.kdf.pbkdf2().unwrap(); - - assert_eq!(pbkdf2_params.salt, hex!("79d982e70df91a88")); - assert_eq!(pbkdf2_params.iteration_count, 2048); - assert_eq!(pbkdf2_params.key_length, None); - assert_eq!(pbkdf2_params.prf, pbes2::Pbkdf2Prf::HmacWithSha256); - - match pbes2_params.encryption { - pbes2::EncryptionScheme::Aes256Cbc { iv } => { - assert_eq!(iv, &hex!("b2d02d78b2efd9dff694cf8e0af40925")); - } - other => panic!("unexpected encryption scheme: {:?}", other), - } - - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/ed25519-encpriv-aes256-sha256.der - assert_eq!( - pk.encrypted_data, - &hex!("D0CD6C770F4BB87176422305C17401809E226674CE74185D221BFDAA95069890C8882FCE02B05D41BCBF54B035595BCD4154B32593708469B86AACF8815A7B2B") - ); -} - -#[cfg(feature = "encryption")] -#[test] -fn decrypt_ed25519_der_encpriv_aes256_pbkdf2_sha256() { - let enc_pk = - EncryptedPrivateKeyInfo::try_from(ED25519_DER_AES256_PBKDF2_SHA256_EXAMPLE).unwrap(); - let pk = enc_pk.decrypt(PASSWORD).unwrap(); - assert_eq!(pk.as_bytes(), ED25519_DER_PLAINTEXT_EXAMPLE); -} - -#[cfg(feature = "encryption")] -#[test] -fn decrypt_ed25519_der_encpriv_aes256_scrypt() { - let enc_pk = EncryptedPrivateKeyInfo::try_from(ED25519_DER_AES256_SCRYPT_EXAMPLE).unwrap(); - let pk = enc_pk.decrypt(PASSWORD).unwrap(); - assert_eq!(pk.as_bytes(), ED25519_DER_PLAINTEXT_EXAMPLE); -} - -#[cfg(feature = "encryption")] -#[test] -fn encrypt_ed25519_der_encpriv_aes256_pbkdf2_sha256() { - let pbes2_params = pkcs5::pbes2::Parameters::pbkdf2_sha256_aes256cbc( - 2048, - &hex!("79d982e70df91a88"), - &hex!("b2d02d78b2efd9dff694cf8e0af40925"), - ) - .unwrap(); - - let pk_plaintext = PrivateKeyInfo::try_from(ED25519_DER_PLAINTEXT_EXAMPLE).unwrap(); - let pk_encrypted = pk_plaintext - .encrypt_with_params(pbes2_params, PASSWORD) - .unwrap(); - - assert_eq!( - pk_encrypted.as_bytes(), - ED25519_DER_AES256_PBKDF2_SHA256_EXAMPLE - ); -} - -#[cfg(feature = "encryption")] -#[test] -fn encrypt_ed25519_der_encpriv_aes256_scrypt() { - let scrypt_params = pkcs5::pbes2::Parameters::scrypt_aes256cbc( - pkcs5::scrypt::Params::new(15, 8, 1, 32).unwrap(), - &hex!("E6211E2348AD69E0"), - &hex!("9BD0A6251F2254F9FD5963887C27CF01"), - ) - .unwrap(); - - let pk_plaintext = PrivateKeyInfo::try_from(ED25519_DER_PLAINTEXT_EXAMPLE).unwrap(); - let pk_encrypted = pk_plaintext - .encrypt_with_params(scrypt_params, PASSWORD) - .unwrap(); - - assert_eq!(pk_encrypted.as_bytes(), ED25519_DER_AES256_SCRYPT_EXAMPLE); -} - -#[test] -#[cfg(feature = "alloc")] -fn encode_ed25519_encpriv_aes256_pbkdf2_sha256_der() { - let pk = EncryptedPrivateKeyInfo::try_from(ED25519_DER_AES256_PBKDF2_SHA256_EXAMPLE).unwrap(); - assert_eq!( - ED25519_DER_AES256_PBKDF2_SHA256_EXAMPLE, - &pk.to_der().unwrap() - ); -} - -#[test] -#[cfg(feature = "pem")] -fn encode_ed25519_encpriv_aes256_pbkdf2_sha256_pem() { - let pk = EncryptedPrivateKeyInfo::try_from(ED25519_DER_AES256_PBKDF2_SHA256_EXAMPLE).unwrap(); - assert_eq!( - ED25519_PEM_AES256_PBKDF2_SHA256_EXAMPLE, - pk.to_pem(Default::default()).unwrap() - ); -} - -#[test] -#[cfg(feature = "3des")] -fn decrypt_ed25519_der_encpriv_des3_pbkdf2_sha256() { - let enc_pk = EncryptedPrivateKeyInfo::try_from(ED25519_DER_DES3_PBKDF2_SHA256_EXAMPLE).unwrap(); - let pk = enc_pk.decrypt(PASSWORD).unwrap(); - assert_eq!(pk.as_bytes(), ED25519_DER_PLAINTEXT_EXAMPLE); -} - -#[test] -#[cfg(feature = "des-insecure")] -fn decrypt_ed25519_der_encpriv_des_pbkdf2_sha256() { - let enc_pk = EncryptedPrivateKeyInfo::try_from(ED25519_DER_DES_PBKDF2_SHA256_EXAMPLE).unwrap(); - let pk = enc_pk.decrypt(PASSWORD).unwrap(); - assert_eq!(pk.as_bytes(), ED25519_DER_PLAINTEXT_EXAMPLE); -} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes128-pbkdf2-sha1.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes128-pbkdf2-sha1.der deleted file mode 100644 index c8d6edf7ce079f1e82bcef2e677a1fc48e76cddd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmXqL>^1OY3aJ(psV|-$ry_SiIgTX+SjWeOmgE5tv zg^`IxK*^wCx%64>S*p41Ig>mqFR?gy`*MnUygJaId$e$ s&FmT4H$Kf2__b%r{^|$L@@ryzQ>$N2KlpXO!=qbnQ3wAVddyM)0LL6S?*IS* diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-pbkdf2-sha256.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-pbkdf2-sha256.der deleted file mode 100644 index 5170c06e4bfebdf9d5d7f9e2fc36d98c989b3ae4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 zcmXqLoNW-!#;Mij(e|B}k(JlL%Rm#s5iX+x~zp8X*kOe3SuI)-dkom|k8xg%@MkH)BKZ2%&< BIHdpp diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-pbkdf2-sha256.pem b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-pbkdf2-sha256.pem deleted file mode 100644 index e5d3207a6b4c..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-pbkdf2-sha256.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAh52YLnDfkaiAICCAAw -DAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEELLQLXiy79nf9pTPjgr0CSUEQNDN -bHcPS7hxdkIjBcF0AYCeImZ0znQYXSIb/aqVBpiQyIgvzgKwXUG8v1SwNVlbzUFU -syWTcIRpuGqs+IFaeys= ------END ENCRYPTED PRIVATE KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-scrypt.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-scrypt.der deleted file mode 100644 index a045982f76a53b7c03a154949d48f657b6b097e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 151 zcmV;I0BHX(fs`;%1_>&LNQU>g$4HsBT(Ii$u1#+=Kr*i@kp1i FcMLz1GgJTo diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-scrypt.pem b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-scrypt.pem deleted file mode 100644 index 1f0562d80e3d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-aes256-scrypt.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIGTME8GCSqGSIb3DQEFDTBCMCEGCSsGAQQB2kcECzAUBAjmIR4jSK1p4AICQAAC -AQgCAQEwHQYJYIZIAWUDBAEqBBCb0KYlHyJU+f1ZY4h8J88BBEDMYrp3PA9JX6s2 -aOT8782wjnig7hXgoVAT9iq+CNqnQgZe6zZtbmyYzDsOfmm9yGHIiv648D26Hixt -mdBtFzYM ------END ENCRYPTED PRIVATE KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-des-pbkdf2-sha256.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-des-pbkdf2-sha256.der deleted file mode 100644 index 85d3b83b27d5011ced28b78254bbccf67572a8e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 138 zcmXqLY&Y;`+=W+J06o hXXaPh`B_YEVQl<;%(hgs+A)iJ+UfdPTVh`A0summFkt`y diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-des3-pbkdf2-sha256.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-encpriv-des3-pbkdf2-sha256.der deleted file mode 100644 index aed05ab638571edc1ec2649f98f656ba7d720b58..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 141 zcmXqL>@x6U4nFa-t!D`jv5A_O28?VNMz+hm@>iKY^R9ACw7BZ3FPs-64N#Xdjv Gsw%GCaY51)={(LCQ@znd^m#B|K zbyz~6A21yT3Mz(3hW8Bt2?-Q24-5@Mb#i2EWgtUnVQF%6fgu1HzeEXXgw6hiLAt?b W+&h-YP==~7wzkU*TsW<8F=pYUFECsH diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-priv-pkcs8v2.pem b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-priv-pkcs8v2.pem deleted file mode 100644 index 84961082a4a9..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-priv-pkcs8v2.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PRIVATE KEY----- -MHICAQEwBQYDK2VwBCIEINTuctv5E1hK1bbY8fdp+K06/nwoy/HU++CXqI9EdVhC -oB8wHQYKKoZIhvcNAQkJFDEPDA1DdXJkbGUgQ2hhaXJzgSEAGb9ECWmEzf6FQbrB -Z9w7lshQhqowtrbLDFw4rXAxZuE= ------END PRIVATE KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-pub.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-pub.der deleted file mode 100644 index 1b602ee1f2754f327636c7e58cbbf340dd7ca82b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44 zcmXreGGJw6)=n*8R%Gzi6sxzF6k7Iu?JrF$Rw>Z~amT9r#nq~1LIdu+2;R#J00n>! ARR910 diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-pub.pem b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-pub.pem deleted file mode 100644 index 6891701f7888..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/ed25519-pub.pem +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEATSkWfz8ZEqb3rfopOgUaFcBexnuPFyZ7HFVQ3OhTvQ0= ------END PUBLIC KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/p256-priv.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/p256-priv.der deleted file mode 100644 index c0de45ef22f512ba6a199fa9d57e08e5f95ef7e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 138 zcmXqLY-eI*Fc4;A*J|@PXUoLM#sOw9GqSVf8e}suGO{RSCOH;{NhO=`K6rj3^V5Qm zNuhmGEN$Ic^IN^z(mN!27rHPzF|f$2`M)(@U+4Xext*`gz112;Re~CH-z}Ia#@1+l q!}5Ink;Wx1lMH<8zGWR0-}kS1#f5&+c&LNQUrr!ay9qXGc{0)hbn0Jg*|QC|?I zs`7%yKHK6#L!of<`X)2INHb%9N6JrcHsCs4DeuD>8psbh4TnoP;}1bk&cXbk?SbV- z?ZVACEOz!BkQkRex%yLia;L`u_P2fsg5SYkz!@j*UVPb0Pg$Sva1*D!4*+`O9C z%Da3+5y^t}j@xn*twmU~GA3d2d=c!W}oRnM@4C!y%bpH2Wg@`#R; zGC|qamAt#G+>o?RJ_%o=a9HXku|HlZT)wPr=s2s4P_JR)n3r3JF9HJr009Dm0RVo? zgJQt#uyhe*AzmW)O1aq^plJYb4E8pVN(f%mGIgsN!P%FiEN=hKee%(hUv6L??crge zD_p{Sq91|M$(%hNppKB^1v;>s@24c*@X*7f!Rd4i4WD)rY80Nps(pZXAXJ1UO_d$6 zd`$Ttwna<{Wr+P*B-^X&HJqXXQfSZw`POc;*7vQ!6Pv9-@onB?o)KhocEJLHfdJgV zVI(b1lCQ4kD#a7ZWx4loHu=4N4sKya8h-a>LM7}KJbqj;rWJZ_S`+_n7mkNm!OJt* z*1O{up7Dv8f1fxb%!GN!4 z>0k(Lll|sgvOfKt2{%V#^_U(u7)h^a&DT?u|7uPK>uItHHke#W@)dOit;609O&&ad}@7$k=iv)659fSfF<_jltLgVYfbyVLN&ndSVPhofRTw& zAlAxzAPa(RKF)KFE&xf7tO_b@scFaX!^#@4yg(^&GQM><*S_COu18N_=uKZDZln|G>8!b*l*S>r`Z*1)ZjfFo`J~5_-6!F8(ZH~#9Jm)I+*b!PL diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-priv.pem b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-priv.pem deleted file mode 100644 index e2a218c86a3d..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-priv.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC2xCxRXxCmqvKC -xj7b4kJDoXDz+iYzvUgzY39Hyk9vNuA6XSnvwxkayA85DYdLOeMPQU/Owfyg7YHl -R+3CzTgsdvYckBiXPbn6U3lyp8cB9rd+CYLfwV/AGSfuXnzZS09Zn/BwE6fIKBvf -Ity8mtfKu3xDEcmC9Y7bchOtRVizMiZtdDrtgZLRiEytuLFHOaja2mbclwgG2ces -RQyxPQ18V1+xmFNPxhvEG8DwV04OATDHu7+9/cn2puLj4q/xy+rIm6V4hFKNVc+w -gyeh6MifTgA88oiOkzJB2daVvLus3JC0Tj4JX6NwWOolsT9eKVy+rG3oOKuMUK9h -4piXW4cvAgMBAAECggEAfsyDYsDtsHQRZCFeIvdKudkboGkAcAz2NpDlEU2O5r3P -uy4/lhRpKmd6CD8Wil5S5ZaOZAe52XxuDkBk+C2gt1ihTxe5t9QfX0jijWVRcE9W -5p56qfpjD8dkKMBtJeRV3PxVt6wrT3ZkP97T/hX/eKuyfmWsxKrQvfbbJ+9gppEM -XEoIXtQydasZwdmXoyxu/8598tGTX25gHu3hYaErXMJ8oh+B0smcPR6gjpDjBTqw -m++nJN7w0MOjwel0DA2fdhJqFJ7Aqn2AeCBUhCVNlR2wfEz5H7ZFTAlliP1ZJNur -6zWcogJSaNAE+dZus9b3rcETm61A8W3eY54RZHN2wQKBgQDcwGEkLU6Sr67nKsUT -ymW593A2+b1+Dm5hRhp+92VCJewVPH5cMaYVem5aE/9uF46HWMHLM9nWu+MXnvGJ -mOQi7Ny+149Oz9vl9PzYrsLJ0NyGRzypvRbZ0jjSH7Xd776xQ8ph0L1qqNkfM6CX -eQ6WQNvJEIXcXyY0O6MTj2stZwKBgQDT8xR1fkDpVINvkr4kI2ry8NoEo0ZTwYCv -Z+lgCG2T/eZcsj79nQk3R2L1mB42GEmvaM3XU5T/ak4G62myCeQijbLfpw5A9/l1 -ClKBdmR7eI0OV3eiy4si480mf/cLTzsC06r7DhjFkKVksDGIsKpfxIFWsHYiIUJD -vRIn76fy+QKBgQDOaLesGw0QDWNuVUiHU8XAmEP9s5DicF33aJRXyb2Nl2XjCXhh -fi78gEj0wyQgbbhgh7ZU6Xuz1GTn7j+M2D/hBDb33xjpqWPE5kkR1n7eNAQvLibj -06GtNGra1rm39ncIywlOYt7p/01dZmmvmIryJV0c6O0xfGp9hpHaNU0S2wKBgCX2 -5ZRCIChrTfu/QjXA7lhD0hmAkYlRINbKeyALgm0+znOOLgBJj6wKKmypacfww8oa -sLxAKXEyvnU4177fTLDvxrmO99ulT1aqmaq85TTEnCeUfUZ4xRxjx4x84WhyMbTI -61h65u8EgMuvT8AXPP1Yen5nr1FfubnedREYOXIpAoGAMZlUBtQGIHyt6uo1s40E -DF+Kmhrggn6e0GsVPYO2ghk1tLNqgr6dVseRtYwnJxpXk9U6HWV8CJl5YLFDPlFx -mH9FLxRKfHIwbWPh0//Atxt1qwjy5FpILpiEUcvkeOEusijQdFbJJLZvbO0EjYU/ -Uz4xpoYU8cPObY7JmDznKvc= ------END PRIVATE KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-pub.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-pub.der deleted file mode 100644 index 4148aaaaaffcd235fca03d18d0605a7d28fdd4e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 294 zcmV+>0ondAf&n5h4F(A+hDe6@4FLfG1potr0S^E$f&mHwf&l>lw!|z^Ul69M@`A=b z+u}k)p>Xs1CNsTAGh=^8%1>`L;5uC?@531y$PYOUhf6u*4?$1P!Tg}@f#pZ-!p%4= zcJ>^Q7?(Y{`crvwr^f;Iw|)tN-@#wN87J;ueA!D+S)cH56Q{^18{Z<_yqed_yL>|t z$%6Hc+j0}FMOd>kCT(;&?SYcfh)k`xu}3+m+S+E^mk0*g$E-yRu{{lZS6{K1Q%}Yl z#2diyS56KAFvq*Uz5U7drsCt`ukp+3$eX2jgi?)F&#;3hq3Fn;P5?aeh>nvoLD|-o syt}O2khD%d316ddSn4IQKVB(ZzN~HNIIE0MuVLbtms^J~0s{d60e+T>_W%F@ diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-pub.pem b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-pub.pem deleted file mode 100644 index 5ecd892394ee..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/rsa2048-pub.pem +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtsQsUV8QpqrygsY+2+JC -Q6Fw8/omM71IM2N/R8pPbzbgOl0p78MZGsgPOQ2HSznjD0FPzsH8oO2B5Uftws04 -LHb2HJAYlz25+lN5cqfHAfa3fgmC38FfwBkn7l582UtPWZ/wcBOnyCgb3yLcvJrX -yrt8QxHJgvWO23ITrUVYszImbXQ67YGS0YhMrbixRzmo2tpm3JcIBtnHrEUMsT0N -fFdfsZhTT8YbxBvA8FdODgEwx7u/vf3J9qbi4+Kv8cvqyJuleIRSjVXPsIMnoejI -n04APPKIjpMyQdnWlby7rNyQtE4+CV+jcFjqJbE/Xilcvqxt6DirjFCvYeKYl1uH -LwIDAQAB ------END PUBLIC KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/x25519-priv.der b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/x25519-priv.der deleted file mode 100644 index 79355d27c7f0cd046b03a640b0bdd0ae8aff2b26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 48 zcmXreV`5}5U}a<0PR(OcVo@kaP}MYElUL<6n{QLHP817QyK2?#wpn&(4qwbJ@>g>Q E01|i(!2kdN diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/x25519-priv.pem b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/x25519-priv.pem deleted file mode 100644 index 501f95da6720..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/examples/x25519-priv.pem +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VuBCIEIHBgJSkzrG56SpsOsmMsWgQKhyV624aaPszD0WtyTyZH ------END PRIVATE KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/private_key.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/private_key.rs deleted file mode 100644 index 1ef0f7361755..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/private_key.rs +++ /dev/null @@ -1,187 +0,0 @@ -//! PKCS#8 private key tests - -use der::asn1::ObjectIdentifier; -use hex_literal::hex; -use pkcs8::{PrivateKeyInfo, Version}; - -#[cfg(feature = "alloc")] -use der::Encode; - -#[cfg(feature = "pem")] -use der::{pem::LineEnding, EncodePem}; - -/// Elliptic Curve (P-256) PKCS#8 private key encoded as ASN.1 DER -const EC_P256_DER_EXAMPLE: &[u8] = include_bytes!("examples/p256-priv.der"); - -/// Ed25519 PKCS#8 v1 private key encoded as ASN.1 DER -const ED25519_DER_V1_EXAMPLE: &[u8] = include_bytes!("examples/ed25519-priv-pkcs8v1.der"); - -/// Ed25519 PKCS#8 v2 private key + public key encoded as ASN.1 DER -const ED25519_DER_V2_EXAMPLE: &[u8] = include_bytes!("examples/ed25519-priv-pkcs8v2.der"); - -/// RSA-2048 PKCS#8 private key encoded as ASN.1 DER -const RSA_2048_DER_EXAMPLE: &[u8] = include_bytes!("examples/rsa2048-priv.der"); - -/// X25519 PKCS#8 private key encoded as ASN.1 DER -const X25519_DER_EXAMPLE: &[u8] = include_bytes!("examples/x25519-priv.der"); - -/// Elliptic Curve (P-256) PKCS#8 private key encoded as PEM -#[cfg(feature = "pem")] -const EC_P256_PEM_EXAMPLE: &str = include_str!("examples/p256-priv.pem"); - -/// Ed25519 PKCS#8 private key encoded as PEM -#[cfg(feature = "pem")] -const ED25519_PEM_V1_EXAMPLE: &str = include_str!("examples/ed25519-priv-pkcs8v1.pem"); - -/// RSA-2048 PKCS#8 private key encoded as PEM -#[cfg(feature = "pem")] -const RSA_2048_PEM_EXAMPLE: &str = include_str!("examples/rsa2048-priv.pem"); - -/// X25519 PKCS#8 private key encoded as PEM -#[cfg(feature = "pem")] -const X25519_PEM_EXAMPLE: &str = include_str!("examples/x25519-priv.pem"); - -#[test] -fn decode_ec_p256_der() { - let pk = PrivateKeyInfo::try_from(EC_P256_DER_EXAMPLE).unwrap(); - - assert_eq!(pk.version(), Version::V1); - assert_eq!(pk.algorithm.oid, "1.2.840.10045.2.1".parse().unwrap()); - - assert_eq!( - pk.algorithm - .parameters - .unwrap() - .decode_as::() - .unwrap(), - "1.2.840.10045.3.1.7".parse().unwrap() - ); - - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/p256-priv.der - assert_eq!(pk.private_key, &hex!("306B020101042069624171561A63340DE0E7D869F2A05492558E1A04868B6A9F854A866788188DA144034200041CACFFB55F2F2CEFD89D89EB374B2681152452802DEEA09916068137D839CF7FC481A44492304D7EF66AC117BEFE83A8D08F155F2B52F9F618DD447029048E0F")[..]); -} - -// Test vector from RFC8410 Section 10.3: -// https://datatracker.ietf.org/doc/html/rfc8410#section-10.3 -#[test] -fn decode_ed25519_der_v1() { - let pk = PrivateKeyInfo::try_from(ED25519_DER_V1_EXAMPLE).unwrap(); - assert_eq!(pk.version(), Version::V1); - assert_eq!(pk.algorithm.oid, "1.3.101.112".parse().unwrap()); - assert_eq!(pk.algorithm.parameters, None); - - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/ed25519-priv.der - assert_eq!( - pk.private_key, - &hex!("042017ED9C73E9DB649EC189A612831C5FC570238207C1AA9DFBD2C53E3FF5E5EA85")[..] - ); -} - -// Test vector from RFC8410 Section 10.3: -// https://datatracker.ietf.org/doc/html/rfc8410#section-10.3 -#[test] -fn decode_ed25519_der_v2() { - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/ed25519-priv-pkcs8v2.der - const PRIV_KEY: [u8; 34] = - hex!("0420D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F44755842"); - const PUB_KEY: [u8; 32] = - hex!("19BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1"); - - let pk = PrivateKeyInfo::try_from(ED25519_DER_V2_EXAMPLE).unwrap(); - assert_eq!(pk.version(), Version::V2); - assert_eq!(pk.algorithm.oid, "1.3.101.112".parse().unwrap()); - assert_eq!(pk.algorithm.parameters, None); - assert_eq!(pk.private_key, PRIV_KEY); - assert_eq!(pk.public_key, Some(&PUB_KEY[..])); -} - -#[test] -fn decode_rsa_2048_der() { - let pk = PrivateKeyInfo::try_from(RSA_2048_DER_EXAMPLE).unwrap(); - assert_eq!(pk.version(), Version::V1); - assert_eq!(pk.algorithm.oid, "1.2.840.113549.1.1.1".parse().unwrap()); - assert!(pk.algorithm.parameters.unwrap().is_null()); - - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/rsa2048-priv.der - assert_eq!(pk.private_key, &hex!("308204A30201000282010100B6C42C515F10A6AAF282C63EDBE24243A170F3FA2633BD4833637F47CA4F6F36E03A5D29EFC3191AC80F390D874B39E30F414FCEC1FCA0ED81E547EDC2CD382C76F61C9018973DB9FA537972A7C701F6B77E0982DFC15FC01927EE5E7CD94B4F599FF07013A7C8281BDF22DCBC9AD7CABB7C4311C982F58EDB7213AD4558B332266D743AED8192D1884CADB8B14739A8DADA66DC970806D9C7AC450CB13D0D7C575FB198534FC61BC41BC0F0574E0E0130C7BBBFBDFDC9F6A6E2E3E2AFF1CBEAC89BA57884528D55CFB08327A1E8C89F4E003CF2888E933241D9D695BCBBACDC90B44E3E095FA37058EA25B13F5E295CBEAC6DE838AB8C50AF61E298975B872F0203010001028201007ECC8362C0EDB0741164215E22F74AB9D91BA06900700CF63690E5114D8EE6BDCFBB2E3F9614692A677A083F168A5E52E5968E6407B9D97C6E0E4064F82DA0B758A14F17B9B7D41F5F48E28D6551704F56E69E7AA9FA630FC76428C06D25E455DCFC55B7AC2B4F76643FDED3FE15FF78ABB27E65ACC4AAD0BDF6DB27EF60A6910C5C4A085ED43275AB19C1D997A32C6EFFCE7DF2D1935F6E601EEDE161A12B5CC27CA21F81D2C99C3D1EA08E90E3053AB09BEFA724DEF0D0C3A3C1E9740C0D9F76126A149EC0AA7D8078205484254D951DB07C4CF91FB6454C096588FD5924DBABEB359CA2025268D004F9D66EB3D6F7ADC1139BAD40F16DDE639E11647376C102818100DCC061242D4E92AFAEE72AC513CA65B9F77036F9BD7E0E6E61461A7EF7654225EC153C7E5C31A6157A6E5A13FF6E178E8758C1CB33D9D6BBE3179EF18998E422ECDCBED78F4ECFDBE5F4FCD8AEC2C9D0DC86473CA9BD16D9D238D21FB5DDEFBEB143CA61D0BD6AA8D91F33A097790E9640DBC91085DC5F26343BA3138F6B2D6702818100D3F314757E40E954836F92BE24236AF2F0DA04A34653C180AF67E960086D93FDE65CB23EFD9D09374762F5981E361849AF68CDD75394FF6A4E06EB69B209E4228DB2DFA70E40F7F9750A528176647B788D0E5777A2CB8B22E3CD267FF70B4F3B02D3AAFB0E18C590A564B03188B0AA5FC48156B07622214243BD1227EFA7F2F902818100CE68B7AC1B0D100D636E55488753C5C09843FDB390E2705DF7689457C9BD8D9765E30978617E2EFC8048F4C324206DB86087B654E97BB3D464E7EE3F8CD83FE10436F7DF18E9A963C4E64911D67EDE34042F2E26E3D3A1AD346ADAD6B9B7F67708CB094E62DEE9FF4D5D6669AF988AF2255D1CE8ED317C6A7D8691DA354D12DB02818025F6E5944220286B4DFBBF4235C0EE5843D2198091895120D6CA7B200B826D3ECE738E2E00498FAC0A2A6CA969C7F0C3CA1AB0BC40297132BE7538D7BEDF4CB0EFC6B98EF7DBA54F56AA99AABCE534C49C27947D4678C51C63C78C7CE1687231B4C8EB587AE6EF0480CBAF4FC0173CFD587A7E67AF515FB9B9DE75111839722902818031995406D406207CADEAEA35B38D040C5F8A9A1AE0827E9ED06B153D83B6821935B4B36A82BE9D56C791B58C27271A5793D53A1D657C08997960B1433E5171987F452F144A7C72306D63E1D3FFC0B71B75AB08F2E45A482E988451CBE478E12EB228D07456C924B66F6CED048D853F533E31A68614F1C3CE6D8EC9983CE72AF7")[..]); -} - -#[test] -fn decode_x25519_der() { - let pk = PrivateKeyInfo::try_from(X25519_DER_EXAMPLE).unwrap(); - assert_eq!(pk.version(), Version::V1); - assert_eq!(pk.algorithm.oid, "1.3.101.110".parse().unwrap()); - assert_eq!(pk.algorithm.parameters, None); - - // Extracted with: - // $ openssl asn1parse -inform der -in tests/examples/x25519-priv.der - assert_eq!( - pk.private_key, - &hex!("04207060252933AC6E7A4A9B0EB2632C5A040A87257ADB869A3ECCC3D16B724F2647")[..] - ); -} - -#[test] -#[cfg(feature = "alloc")] -fn encode_ec_p256_der() { - let pk = PrivateKeyInfo::try_from(EC_P256_DER_EXAMPLE).unwrap(); - let pk_encoded = pk.to_der().unwrap(); - assert_eq!(EC_P256_DER_EXAMPLE, pk_encoded); -} - -#[test] -#[cfg(feature = "alloc")] -fn encode_ed25519_der_v1() { - let pk = PrivateKeyInfo::try_from(ED25519_DER_V1_EXAMPLE).unwrap(); - assert_eq!(ED25519_DER_V1_EXAMPLE, pk.to_der().unwrap()); -} - -#[test] -#[cfg(all(feature = "alloc", feature = "subtle"))] -fn encode_ed25519_der_v2() { - let private_key = PrivateKeyInfo::try_from(ED25519_DER_V2_EXAMPLE).unwrap(); - let private_der = private_key.to_der().unwrap(); - assert_eq!( - private_key, - PrivateKeyInfo::try_from(private_der.as_ref()).unwrap() - ); -} - -#[test] -#[cfg(feature = "alloc")] -fn encode_rsa_2048_der() { - let pk = PrivateKeyInfo::try_from(RSA_2048_DER_EXAMPLE).unwrap(); - assert_eq!(RSA_2048_DER_EXAMPLE, &pk.to_der().unwrap()); -} - -#[test] -#[cfg(feature = "pem")] -fn encode_ec_p256_pem() { - let pk = PrivateKeyInfo::try_from(EC_P256_DER_EXAMPLE).unwrap(); - assert_eq!(EC_P256_PEM_EXAMPLE, pk.to_pem(LineEnding::LF).unwrap()); -} - -#[test] -#[cfg(feature = "pem")] -fn encode_ed25519_pem() { - let pk = PrivateKeyInfo::try_from(ED25519_DER_V1_EXAMPLE).unwrap(); - assert_eq!(ED25519_PEM_V1_EXAMPLE, pk.to_pem(LineEnding::LF).unwrap()); -} - -#[test] -#[cfg(feature = "pem")] -fn encode_rsa_2048_pem() { - let pk = PrivateKeyInfo::try_from(RSA_2048_DER_EXAMPLE).unwrap(); - assert_eq!(RSA_2048_PEM_EXAMPLE, pk.to_pem(LineEnding::LF).unwrap()); -} - -#[test] -#[cfg(feature = "pem")] -fn encode_x25519_pem() { - let pk = PrivateKeyInfo::try_from(X25519_DER_EXAMPLE).unwrap(); - assert_eq!(X25519_PEM_EXAMPLE, pk.to_pem(LineEnding::LF).unwrap()); -} diff --git a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/traits.rs b/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/traits.rs deleted file mode 100644 index 4a603bb94e33..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/tests/traits.rs +++ /dev/null @@ -1,102 +0,0 @@ -//! Tests for PKCS#8 encoding/decoding traits. - -#![cfg(any(feature = "pem", feature = "std"))] - -use der::Encode; -use pkcs8::{DecodePrivateKey, EncodePrivateKey, Error, PrivateKeyInfo, Result, SecretDocument}; - -#[cfg(feature = "pem")] -use pkcs8::der::pem::LineEnding; - -#[cfg(feature = "std")] -use tempfile::tempdir; - -#[cfg(all(feature = "pem", feature = "std"))] -use std::fs; - -/// Ed25519 `PrivateKeyInfo` encoded as ASN.1 DER -const ED25519_DER_EXAMPLE: &[u8] = include_bytes!("examples/ed25519-priv-pkcs8v1.der"); - -/// Ed25519 private key encoded as PEM -#[cfg(feature = "pem")] -const ED25519_PEM_EXAMPLE: &str = include_str!("examples/ed25519-priv-pkcs8v1.pem"); - -/// Mock key type for testing trait impls against. -pub struct MockKey(Vec); - -impl AsRef<[u8]> for MockKey { - fn as_ref(&self) -> &[u8] { - self.0.as_ref() - } -} - -impl EncodePrivateKey for MockKey { - fn to_pkcs8_der(&self) -> Result { - Ok(SecretDocument::try_from(self.as_ref())?) - } -} - -impl TryFrom> for MockKey { - type Error = Error; - - fn try_from(pkcs8: PrivateKeyInfo<'_>) -> Result { - Ok(MockKey(pkcs8.to_der()?)) - } -} - -#[cfg(feature = "pem")] -#[test] -fn from_pkcs8_pem() { - let key = MockKey::from_pkcs8_pem(ED25519_PEM_EXAMPLE).unwrap(); - assert_eq!(key.as_ref(), ED25519_DER_EXAMPLE); -} - -#[cfg(feature = "std")] -#[test] -fn read_pkcs8_der_file() { - let key = MockKey::read_pkcs8_der_file("tests/examples/ed25519-priv-pkcs8v1.der").unwrap(); - assert_eq!(key.as_ref(), ED25519_DER_EXAMPLE); -} - -#[cfg(all(feature = "pem", feature = "std"))] -#[test] -fn read_pkcs8_pem_file() { - let key = MockKey::read_pkcs8_pem_file("tests/examples/ed25519-priv-pkcs8v1.pem").unwrap(); - assert_eq!(key.as_ref(), ED25519_DER_EXAMPLE); -} - -#[cfg(feature = "pem")] -#[test] -fn to_pkcs8_pem() { - let pem = MockKey(ED25519_DER_EXAMPLE.to_vec()) - .to_pkcs8_pem(LineEnding::LF) - .unwrap(); - - assert_eq!(&*pem, ED25519_PEM_EXAMPLE); -} - -#[cfg(feature = "std")] -#[test] -fn write_pkcs8_der_file() { - let dir = tempdir().unwrap(); - let path = dir.path().join("example.der"); - MockKey(ED25519_DER_EXAMPLE.to_vec()) - .write_pkcs8_der_file(&path) - .unwrap(); - - let key = MockKey::read_pkcs8_der_file(&path).unwrap(); - assert_eq!(key.as_ref(), ED25519_DER_EXAMPLE); -} - -#[cfg(all(feature = "pem", feature = "std"))] -#[test] -fn write_pkcs8_pem_file() { - let dir = tempdir().unwrap(); - let path = dir.path().join("example.pem"); - MockKey(ED25519_DER_EXAMPLE.to_vec()) - .write_pkcs8_pem_file(&path, LineEnding::LF) - .unwrap(); - - let pem = fs::read_to_string(path).unwrap(); - assert_eq!(&pem, ED25519_PEM_EXAMPLE); -} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/.cargo_vcs_info.json deleted file mode 100644 index 2230f6e7beeb..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "5adcd4819b380b4aaec2b57c6bf3f2239a109060" - }, - "path_in_vcs": "signature" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/CHANGELOG.md b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/CHANGELOG.md deleted file mode 100644 index 3f9d8cd08440..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/CHANGELOG.md +++ /dev/null @@ -1,247 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## 2.2.0 (2023-11-12) -### Changed -- MSRV 1.60 ([#1387]) - -### Fixed -- No longer vendoring async/derive crates unintentionally ([#1391]) - -[#1387]: https://github.com/RustCrypto/traits/pull/1387 -[#1391]: https://github.com/RustCrypto/traits/pull/1391 - -## 2.1.0 (2023-04-01) -### Added -- `SignatureEncoding::encoded_len` ([#1283]) - -[#1283]: https://github.com/RustCrypto/traits/pull/1283 - -## 2.0.0 (2023-01-15) -### Added -- `SignatureEncoding` trait as a replacement for `Signature` trait and the - now removed `AsRef<[u8]>` bound on signatures ([#1141]) -- New `Keypair` trait which returns owned keys instead of borrowed ([#1141]) - -### Changed -- `derive-preview` has been renamed to `derive` and stabilized ([#1141]) -- `digest-preview` renamed to `digest`, still unstable ([#1210]) -- `hazmat-preview` feature stabilized and removed, always on ([#1141]) -- `rand-preview` renamed to `rand_core`, still unstable ([#1210]) -- `std` feature is no longer enabled by default ([#1141]) -- Old `Keypair` trait renamed to `KeypairRef` ([#1141]) -- Signature generic parameter removed from `Keypair`/`KeypairRef` ([#1141]) -- Use `&mut impl CryptoRngCore` RNG arguments ([#1147]) - -### Removed -- `Signature` trait - replaced by `SignatureEncoding` ([#1141]) -- `hazmat-preview` feature, now always on ([#1141]) - -[#1141]: https://github.com/RustCrypto/traits/pull/1141 -[#1147]: https://github.com/RustCrypto/traits/pull/1147 -[#1210]: https://github.com/RustCrypto/traits/pull/1141 - -## 1.6.4 (2022-10-06) -### Added -- `RandomizedPrehashSigner` trait in `hazmat` module ([#1130]) - -[#1130]: https://github.com/RustCrypto/traits/pull/1130 - -## 1.6.3 (2022-09-16) -### Changed -- Bump `signature_derive` to v1.0.0-pre.7 ([#1119]) - -[#1119]: https://github.com/RustCrypto/traits/pull/1119 - -## 1.6.2 (2022-09-15) -### Changed -- Relax `Keypair` type bounds ([#1107]) - -[#1107]: https://github.com/RustCrypto/traits/pull/1107 - -## 1.6.1 (2022-09-12) [YANKED] -### Added -- `hazmat-preview` feature with `PrehashSigner`/`PrehashVerifier` traits ([#1099]) - -### Changed -- Bump `signature_derive` to v1.0.0-pre.6 ([#1104]) - -[#1099]: https://github.com/RustCrypto/traits/pull/1099 -[#1104]: https://github.com/RustCrypto/traits/pull/1104 - -## 1.6.0 (2022-08-14) [YANKED] -### Added -- `Keypair` trait ([#1080]) - -### Changed -- Rust 2021 edition upgrade; MSRV 1.56 ([#1081]) -- Bump `signature_derive` dependency to v1.0.0-pre.5 ([#1082]) -- Bump `hex-literal` dependency to v0.3 ([#1083]) - -[#1080]: https://github.com/RustCrypto/traits/pull/1080 -[#1081]: https://github.com/RustCrypto/traits/pull/1081 -[#1082]: https://github.com/RustCrypto/traits/pull/1082 -[#1083]: https://github.com/RustCrypto/traits/pull/1083 - -## 1.5.0 (2022-01-04) -### Changed -- Bump `digest` dependency to v0.10 ([#850]) -- Bump `signature-derive` dependency to v1.0.0-pre.4 ([#866]) - -[#850]: https://github.com/RustCrypto/traits/pull/850 -[#866]: https://github.com/RustCrypto/traits/pull/866 - -## 1.4.0 (2021-10-20) -### Added -- Re-export `rand_core` when the `rand-preview` feature is enabled ([#683]) -- `SignerMut` trait ([#734]) - -### Fixed -- Show error source in `Display` impl ([#791]) - -[#683]: https://github.com/RustCrypto/traits/pull/683 -[#734]: https://github.com/RustCrypto/traits/pull/734 -[#791]: https://github.com/RustCrypto/traits/pull/791 - -## 1.3.2 (2021-10-21) -### Fixed -- Backport changes from [#791] to the 1.3.x series. - -## 1.3.1 (2021-06-29) -### Added -- `Result` alias ([#676]) - -[#676]: https://github.com/RustCrypto/traits/pull/676 - -## 1.3.0 (2021-01-06) -### Changed -- Bump `rand_core` to v0.6 ([#457]) -- Bump `signature-derive` v1.0.0-pre.3 ([#459]) - -[#457]: https://github.com/RustCrypto/traits/pull/457 -[#459]: https://github.com/RustCrypto/traits/pull/459 - -## 1.2.2 (2020-07-29) -### Added -- `RandomizedDigestSigner` ([#235]) - -[#235]: https://github.com/RustCrypto/traits/pull/235 - -## 1.2.1 (2020-07-29) -### Removed -- RNG generic parameter `R` from `RandomizedSigner` ([#231]) - -[#231]: https://github.com/RustCrypto/traits/pull/231 - -## 1.2.0 (2020-07-29) [YANKED] -- Note: this release was published without the intended changes - -## 1.1.0 (2020-06-09) -### Changed -- Upgrade `digest` to v0.9; MSRV 1.41+ ([#186]) - -[#186]: https://github.com/RustCrypto/traits/pull/186 - -## 1.0.1 (2020-04-19) -### Changed -- Upgrade `signature_derive` to v1.0.0-pre.2 ([#98]) - -[#98]: https://github.com/RustCrypto/traits/pull/98 - -## 1.0.0 (2020-04-18) - -Initial 1.0 release! 🎉 - -### Changed -- Rename `DigestSignature` => `PrehashSignature` ([#96]) - -[#96]: https://github.com/RustCrypto/traits/pull/96 - -## 1.0.0-pre.5 (2020-03-16) -### Changed -- Improve `Debug` impl on `Error` ([#89]) -- Rename `Signature::as_slice` -> `as_bytes` ([#87]) - -[#89]: https://github.com/RustCrypto/traits/pull/89 -[#87]: https://github.com/RustCrypto/traits/pull/87 - -## 1.0.0-pre.4 (2020-03-15) -### Added -- Mark preview features as unstable in `Cargo.toml` ([#82]) - -### Changed -- Have `Signature::from_bytes` take a byte slice ([#84]) -- Ensure `Error::new()` is mandatory ([#83]) - -### Removed -- `BoxError` type alias ([#81]) - -[#84]: https://github.com/RustCrypto/traits/pull/84 -[#83]: https://github.com/RustCrypto/traits/pull/83 -[#82]: https://github.com/RustCrypto/traits/pull/82 -[#81]: https://github.com/RustCrypto/traits/pull/81 - -## 1.0.0-pre.3 (2020-03-08) -### Fixed -- docs.rs rendering ([#76]) - -[#76]: https://github.com/RustCrypto/traits/pull/76 - -## 1.0.0-pre.2 (2020-03-08) -### Added -- `RandomizedSigner` trait ([#73]) -- Design documentation ([#72]) - -### Changed -- Error cleanups ([#74]) -- Crate moved to `RustCrypto/traits` ([#71]) - -[#74]: https://github.com/RustCrypto/traits/pull/74 -[#73]: https://github.com/RustCrypto/traits/pull/73 -[#72]: https://github.com/RustCrypto/traits/pull/72 -[#71]: https://github.com/RustCrypto/traits/pull/71 - -## 1.0.0-pre.1 (2019-10-27) -### Changed -- Use `Error::source` instead of `::cause` ([RustCrypto/signatures#37]) - -### Removed -- Remove `alloc` feature; MSRV 1.34+ ([RustCrypto/signatures#38]) - -[RustCrypto/signatures#38]: https://github.com/RustCrypto/signatures/pull/38 -[RustCrypto/signatures#37]: https://github.com/RustCrypto/signatures/pull/37 - -## 1.0.0-pre.0 (2019-10-11) -### Changed -- Revert removal of `DigestSignature` ([RustCrypto/signatures#33]) -- 1.0 stabilization proposal ([RustCrypto/signatures#32]) - -[RustCrypto/signatures#33]: https://github.com/RustCrypto/signatures/pull/33 -[RustCrypto/signatures#32]: https://github.com/RustCrypto/signatures/pull/32 - -## 0.3.0 (2019-10-10) -### Changed -- Simplify alloc gating; MSRV 1.36+ ([RustCrypto/signatures#28]) -- Replace `DigestSignature` trait with `#[digest(...)]` attribute ([RustCrypto/signatures#27]) -- signature_derive: Upgrade to 1.x proc macro crates ([RustCrypto/signatures#26]) - -[RustCrypto/signatures#28]: https://github.com/RustCrypto/signatures/pull/28 -[RustCrypto/signatures#27]: https://github.com/RustCrypto/signatures/pull/27 -[RustCrypto/signatures#26]: https://github.com/RustCrypto/signatures/pull/27 - -## 0.2.0 (2019-06-06) -### Added -- `signature_derive`: Custom derive support for `Signer`/`Verifier` ([RustCrypto/signatures#18]) - -### Changed -- Have `DigestSigner`/`DigestVerifier` take `Digest` instance ([RustCrypto/signatures#17]) - -[RustCrypto/signatures#18]: https://github.com/RustCrypto/signatures/pull/18 -[RustCrypto/signatures#17]: https://github.com/RustCrypto/signatures/pull/17 - -## 0.1.0 (2019-05-25) - -- Initial release diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/Cargo.toml deleted file mode 100644 index 871099e1cf86..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/Cargo.toml +++ /dev/null @@ -1,69 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -rust-version = "1.60" -name = "signature" -version = "2.2.0" -authors = ["RustCrypto Developers"] -description = "Traits for cryptographic signature algorithms (e.g. ECDSA, Ed25519)" -documentation = "https://docs.rs/signature" -readme = "README.md" -keywords = [ - "crypto", - "ecdsa", - "ed25519", - "signature", - "signing", -] -categories = [ - "cryptography", - "no-std", -] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/traits/tree/master/signature" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = [ - "--cfg", - "docsrs", -] - -[dependencies.derive] -version = "2" -optional = true -package = "signature_derive" - -[dependencies.digest] -version = "0.10.6" -optional = true -default-features = false - -[dependencies.rand_core] -version = "0.6.4" -optional = true -default-features = false - -[dev-dependencies.hex-literal] -version = "0.4" - -[dev-dependencies.sha2] -version = "0.10" -default-features = false - -[features] -alloc = [] -std = [ - "alloc", - "rand_core?/std", -] diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/Cargo.toml.orig deleted file mode 100644 index 29353f6c4d37..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/Cargo.toml.orig +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "signature" -description = "Traits for cryptographic signature algorithms (e.g. ECDSA, Ed25519)" -version = "2.2.0" -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" -documentation = "https://docs.rs/signature" -repository = "https://github.com/RustCrypto/traits/tree/master/signature" -readme = "README.md" -keywords = ["crypto", "ecdsa", "ed25519", "signature", "signing"] -categories = ["cryptography", "no-std"] -edition = "2021" -rust-version = "1.60" - -[dependencies] -derive = { package = "signature_derive", version = "2", optional = true, path = "../signature_derive" } -digest = { version = "0.10.6", optional = true, default-features = false } -rand_core = { version = "0.6.4", optional = true, default-features = false } - -[dev-dependencies] -hex-literal = "0.4" -sha2 = { version = "0.10", default-features = false } - -[features] -alloc = [] -std = ["alloc", "rand_core?/std"] - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-APACHE b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-APACHE deleted file mode 100644 index 78173fa2e753..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - 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. diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-MIT b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-MIT deleted file mode 100644 index d8d87fe2997c..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2018-2023 RustCrypto Developers - -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. diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/README.md b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/README.md deleted file mode 100644 index 5e1100301de8..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# [RustCrypto]: Digital Signature Algorithms - -[![crate][crate-image]][crate-link] -[![Docs][docs-image]][docs-link] -[![Build Status][build-image]][build-link] -![Apache2/MIT licensed][license-image] -![Rust Version][rustc-image] -[![Project Chat][chat-image]][chat-link] - -This crate contains traits which provide generic, object-safe APIs for -generating and verifying [digital signatures]. - -Used by the [`dsa`], [`ecdsa`], [`ed25519`], and [`rsa`] crates maintained by -the [RustCrypto] organization, as well as [`ed25519-dalek`]. - -[Documentation][docs-link] - -## Minimum Supported Rust Version - -Rust **1.60** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above -- The `derive` feature is stable and covered by SemVer -- The off-by-default features `digest` and `rand_core` are unstable features - which are also considered exempt from SemVer as they correspond to pre-1.0 - crates which are still subject to changes. Breaking changes to these features - will, like MSRV, be done with a minor version bump. - -## License - -Licensed under either of - - * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) - * [MIT license](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. - -[//]: # (badges) - -[crate-image]: https://buildstats.info/crate/signature -[crate-link]: https://crates.io/crates/signature -[docs-image]: https://docs.rs/signature/badge.svg -[docs-link]: https://docs.rs/signature/ -[build-image]: https://github.com/RustCrypto/traits/actions/workflows/signature.yml/badge.svg -[build-link]: https://github.com/RustCrypto/traits/actions/workflows/signature.yml -[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.60+-blue.svg -[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg -[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures - -[//]: # (links) - -[RustCrypto]: https://github.com/RustCrypto/ -[digital signatures]: https://en.wikipedia.org/wiki/Digital_signature -[`dsa`]: https://github.com/RustCrypto/signatures/tree/master/dsa -[`ecdsa`]: https://github.com/RustCrypto/signatures/tree/master/ecdsa -[`ed25519`]: https://github.com/RustCrypto/signatures/tree/master/ed25519 -[`ed25519-dalek`]: https://github.com/dalek-cryptography/ed25519-dalek -[`rsa`]: https://github.com/RustCrypto/RSA diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/encoding.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/encoding.rs deleted file mode 100644 index 8bc475b01886..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/encoding.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! Encoding support. - -#[cfg(feature = "alloc")] -use alloc::vec::Vec; - -/// Support for decoding/encoding signatures as bytes. -pub trait SignatureEncoding: - Clone + Sized + for<'a> TryFrom<&'a [u8]> + TryInto -{ - /// Byte representation of a signature. - type Repr: 'static + AsRef<[u8]> + Clone + Send + Sync; - - /// Encode signature as its byte representation. - fn to_bytes(&self) -> Self::Repr { - self.clone() - .try_into() - .ok() - .expect("signature encoding error") - } - - /// Encode signature as a byte vector. - #[cfg(feature = "alloc")] - fn to_vec(&self) -> Vec { - self.to_bytes().as_ref().to_vec() - } - - /// Get the length of this signature when encoded. - fn encoded_len(&self) -> usize { - self.to_bytes().as_ref().len() - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/error.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/error.rs deleted file mode 100644 index 6518f17b85a5..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/error.rs +++ /dev/null @@ -1,116 +0,0 @@ -//! Signature error types - -use core::fmt::{self, Debug, Display}; - -#[cfg(feature = "std")] -use std::boxed::Box; - -/// Result type. -/// -/// A result with the `signature` crate's [`Error`] type. -pub type Result = core::result::Result; - -/// Signature errors. -/// -/// This type is deliberately opaque as to avoid sidechannel leakage which -/// could potentially be used recover signing private keys or forge signatures -/// (e.g. [BB'06]). -/// -/// When the `std` feature is enabled, it impls [`std::error::Error`] and -/// supports an optional [`std::error::Error::source`], which can be used by -/// things like remote signers (e.g. HSM, KMS) to report I/O or auth errors. -/// -/// [BB'06]: https://en.wikipedia.org/wiki/Daniel_Bleichenbacher -#[derive(Default)] -#[non_exhaustive] -pub struct Error { - /// Source of the error (if applicable). - #[cfg(feature = "std")] - source: Option>, -} - -impl Error { - /// Create a new error with no associated source - pub fn new() -> Self { - Self::default() - } - - /// Create a new error with an associated source. - /// - /// **NOTE:** The "source" should **NOT** be used to propagate cryptographic - /// errors e.g. signature parsing or verification errors. The intended use - /// cases are for propagating errors related to external signers, e.g. - /// communication/authentication errors with HSMs, KMS, etc. - #[cfg(feature = "std")] - pub fn from_source( - source: impl Into>, - ) -> Self { - Self { - source: Some(source.into()), - } - } -} - -impl Debug for Error { - #[cfg(not(feature = "std"))] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("signature::Error {}") - } - - #[cfg(feature = "std")] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("signature::Error { source: ")?; - - if let Some(source) = &self.source { - write!(f, "Some({})", source)?; - } else { - f.write_str("None")?; - } - - f.write_str(" }") - } -} - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("signature error")?; - - #[cfg(feature = "std")] - { - if let Some(source) = &self.source { - write!(f, ": {}", source)?; - } - } - - Ok(()) - } -} - -#[cfg(feature = "std")] -impl From> for Error { - fn from(source: Box) -> Error { - Self::from_source(source) - } -} - -#[cfg(feature = "rand_core")] -impl From for Error { - #[cfg(not(feature = "std"))] - fn from(_source: rand_core::Error) -> Error { - Error::new() - } - - #[cfg(feature = "std")] - fn from(source: rand_core::Error) -> Error { - Error::from_source(source) - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - self.source - .as_ref() - .map(|source| source.as_ref() as &(dyn std::error::Error + 'static)) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/hazmat.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/hazmat.rs deleted file mode 100644 index d2f3e9523554..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/hazmat.rs +++ /dev/null @@ -1,70 +0,0 @@ -//! Hazardous Materials: low-level APIs which can be insecure if misused. -//! -//! The traits in this module are not generally recommended, and should only be -//! used in special cases where they are specifically needed. -//! -//! Using them incorrectly can introduce security vulnerabilities. Please -//! carefully read the documentation before attempting to use them. - -use crate::Error; - -#[cfg(feature = "rand_core")] -use crate::rand_core::CryptoRngCore; - -/// Sign the provided message prehash, returning a digital signature. -pub trait PrehashSigner { - /// Attempt to sign the given message digest, returning a digital signature - /// on success, or an error if something went wrong. - /// - /// The `prehash` parameter should be the output of a secure cryptographic - /// hash function. - /// - /// This API takes a `prehash` byte slice as there can potentially be many - /// compatible lengths for the message digest for a given concrete signature - /// algorithm. - /// - /// Allowed lengths are algorithm-dependent and up to a particular - /// implementation to decide. - fn sign_prehash(&self, prehash: &[u8]) -> Result; -} - -/// Sign the provided message prehash using the provided external randomness source, returning a digital signature. -#[cfg(feature = "rand_core")] -pub trait RandomizedPrehashSigner { - /// Attempt to sign the given message digest, returning a digital signature - /// on success, or an error if something went wrong. - /// - /// The `prehash` parameter should be the output of a secure cryptographic - /// hash function. - /// - /// This API takes a `prehash` byte slice as there can potentially be many - /// compatible lengths for the message digest for a given concrete signature - /// algorithm. - /// - /// Allowed lengths are algorithm-dependent and up to a particular - /// implementation to decide. - fn sign_prehash_with_rng( - &self, - rng: &mut impl CryptoRngCore, - prehash: &[u8], - ) -> Result; -} - -/// Verify the provided message prehash using `Self` (e.g. a public key) -pub trait PrehashVerifier { - /// Use `Self` to verify that the provided signature for a given message - /// `prehash` is authentic. - /// - /// The `prehash` parameter should be the output of a secure cryptographic - /// hash function. - /// - /// Returns `Error` if it is inauthentic or some other error occurred, or - /// otherwise returns `Ok(())`. - /// - /// # ⚠️ Security Warning - /// - /// If `prehash` is something other than the output of a cryptographically - /// secure hash function, an attacker can potentially forge signatures by - /// solving a system of linear equations. - fn verify_prehash(&self, prehash: &[u8], signature: &S) -> Result<(), Error>; -} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/keypair.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/keypair.rs deleted file mode 100644 index d4795f2f9b3c..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/keypair.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Signing keypairs. - -/// Signing keypair with an associated verifying key. -/// -/// This represents a type which holds both a signing key and a verifying key. -pub trait Keypair { - /// Verifying key type for this keypair. - type VerifyingKey: Clone; - - /// Get the verifying key which can verify signatures produced by the - /// signing key portion of this keypair. - fn verifying_key(&self) -> Self::VerifyingKey; -} - -/// Signing keypair with an associated verifying key. -/// -/// This represents a type which holds both a signing key and a verifying key. -pub trait KeypairRef: AsRef { - /// Verifying key type for this keypair. - type VerifyingKey: Clone; -} - -impl Keypair for K { - type VerifyingKey = ::VerifyingKey; - - fn verifying_key(&self) -> Self::VerifyingKey { - self.as_ref().clone() - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/lib.rs deleted file mode 100644 index c90f5cc8a684..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/lib.rs +++ /dev/null @@ -1,158 +0,0 @@ -#![no_std] -#![doc = include_str!("../README.md")] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg" -)] -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![forbid(unsafe_code)] -#![warn( - clippy::mod_module_files, - clippy::unwrap_used, - missing_docs, - rust_2018_idioms, - unused_lifetimes, - unused_qualifications -)] - -//! # Design -//! -//! This crate provides a common set of traits for signing and verifying -//! digital signatures intended to be implemented by libraries which produce -//! or contain implementations of digital signature algorithms, and used by -//! libraries which want to produce or verify digital signatures while -//! generically supporting any compatible backend. -//! -//! ## Goals -//! -//! The traits provided by this crate were designed with the following goals -//! in mind: -//! -//! - Provide an easy-to-use, misuse resistant API optimized for consumers -//! (as opposed to implementers) of its traits. -//! - Support common type-safe wrappers around "bag-of-bytes" representations -//! which can be directly parsed from or written to the "wire". -//! - Expose a trait/object-safe API where signers/verifiers spanning multiple -//! homogeneous provider implementations can be seamlessly leveraged together -//! in the same logical "keyring" so long as they operate on the same -//! underlying signature type. -//! - Allow one provider type to potentially implement support (including -//! being generic over) several signature types. -//! - Keep signature algorithm customizations / "knobs" out-of-band from the -//! signing/verification APIs, ideally pushing such concerns into the type -//! system so that algorithm mismatches are caught as type errors. -//! - Opaque error type which minimizes information leaked from cryptographic -//! failures, as "rich" error types in these scenarios are often a source -//! of sidechannel information for attackers (e.g. [BB'06]) -//! -//! [BB'06]: https://en.wikipedia.org/wiki/Daniel_Bleichenbacher -//! -//! ## Implementation -//! -//! To accomplish the above goals, the [`Signer`] and [`Verifier`] traits -//! provided by this are generic over a signature value, and use generic -//! parameters rather than associated types. Notably, they use such a parameter -//! for the return value, allowing it to be inferred by the type checker based -//! on the desired signature type. -//! -//! ## Alternatives considered -//! -//! This crate is based on many years of exploration of how to encapsulate -//! digital signature systems in the most flexible, developer-friendly way. -//! During that time many design alternatives were explored, tradeoffs -//! compared, and ultimately the provided API was selected. -//! -//! The tradeoffs made in this API have all been to improve simplicity, -//! ergonomics, type safety, and flexibility for *consumers* of the traits. -//! At times, this has come at a cost to implementers. Below are some concerns -//! we are cognizant of which were considered in the design of the API: -//! -//! - "Bag-of-bytes" serialization precludes signature providers from using -//! their own internal representation of a signature, which can be helpful -//! for many reasons (e.g. advanced signature system features like batch -//! verification). -//! - Associated types, rather than generic parameters of traits, could allow -//! more customization of the types used by a particular signature system, -//! e.g. using custom error types. -//! -//! It may still make sense to continue to explore the above tradeoffs, but -//! with a *new* set of traits which are intended to be implementor-friendly, -//! rather than consumer friendly. The existing [`Signer`] and [`Verifier`] -//! traits could have blanket impls for the "provider-friendly" traits. -//! However, as noted above this is a design space easily explored after -//! stabilizing the consumer-oriented traits, and thus we consider these -//! more important. -//! -//! That said, below are some caveats of trying to design such traits, and -//! why we haven't actively pursued them: -//! -//! - Generics in the return position are already used to select which trait -//! impl to use, i.e. for a particular signature algorithm/system. Avoiding -//! a unified, concrete signature type adds another dimension to complexity -//! and compiler errors, and in our experience makes them unsuitable for this -//! sort of API. We believe such an API is the natural one for signature -//! systems, reflecting the natural way they are written absent a trait. -//! - Associated types preclude multiple implementations of the same trait. -//! These parameters are common in signature systems, notably ones which -//! support different serializations of a signature (e.g. raw vs ASN.1). -//! - Digital signatures are almost always larger than the present 32-entry -//! trait impl limitation on array types, which complicates bounds -//! for these types (particularly things like `From` or `Borrow` bounds). -//! -//! ## Unstable features -//! -//! Despite being post-1.0, this crate includes off-by-default unstable -//! optional features, each of which depends on a pre-1.0 -//! crate. -//! -//! These features are considered exempt from SemVer. See the -//! [SemVer policy](#semver-policy) above for more information. -//! -//! The following unstable features are presently supported: -//! -//! - `digest`: enables the [`DigestSigner`] and [`DigestVerifier`] -//! traits which are based on the [`Digest`] trait from the [`digest`] crate. -//! These traits are used for representing signature systems based on the -//! [Fiat-Shamir heuristic] which compute a random challenge value to sign -//! by computing a cryptographically secure digest of the input message. -//! - `rand_core`: enables the [`RandomizedSigner`] trait for signature -//! systems which rely on a cryptographically secure random number generator -//! for security. -//! -//! NOTE: the [`async-signature`] crate contains experimental `async` support -//! for [`Signer`] and [`DigestSigner`]. -//! -//! [`async-signature`]: https://docs.rs/async-signature -//! [`digest`]: https://docs.rs/digest/ -//! [`Digest`]: https://docs.rs/digest/latest/digest/trait.Digest.html -//! [Fiat-Shamir heuristic]: https://en.wikipedia.org/wiki/Fiat%E2%80%93Shamir_heuristic - -#[cfg(feature = "alloc")] -extern crate alloc; -#[cfg(feature = "std")] -extern crate std; - -pub mod hazmat; - -mod encoding; -mod error; -mod keypair; -mod signer; -mod verifier; - -#[cfg(feature = "digest")] -mod prehash_signature; - -pub use crate::{encoding::*, error::*, keypair::*, signer::*, verifier::*}; - -#[cfg(feature = "derive")] -pub use derive::{Signer, Verifier}; - -#[cfg(all(feature = "derive", feature = "digest"))] -pub use derive::{DigestSigner, DigestVerifier}; - -#[cfg(feature = "digest")] -pub use {crate::prehash_signature::*, digest}; - -#[cfg(feature = "rand_core")] -pub use rand_core; diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/prehash_signature.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/prehash_signature.rs deleted file mode 100644 index d9a86456def3..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/prehash_signature.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! `PrehashSignature` trait. - -/// For intra-doc link resolution. -#[allow(unused_imports)] -use crate::{ - signer::{DigestSigner, Signer}, - verifier::{DigestVerifier, Verifier}, -}; - -/// Marker trait for `Signature` types computable as `𝐒(𝐇(𝒎))` -/// i.e. ones which prehash a message to be signed as `𝐇(𝒎)` -/// -/// Where: -/// -/// - `𝐒`: signature algorithm -/// - `𝐇`: hash (a.k.a. digest) function -/// - `𝒎`: message -/// -/// This approach is relatively common in signature schemes based on the -/// [Fiat-Shamir heuristic]. -/// -/// For signature types that implement this trait, when the `derive` crate -/// feature is enabled a custom derive for [`Signer`] is available for any -/// types that impl [`DigestSigner`], and likewise for deriving [`Verifier`] for -/// types which impl [`DigestVerifier`]. -/// -/// [Fiat-Shamir heuristic]: https://en.wikipedia.org/wiki/Fiat%E2%80%93Shamir_heuristic -pub trait PrehashSignature { - /// Preferred `Digest` algorithm to use when computing this signature type. - type Digest: digest::Digest; -} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/signer.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/signer.rs deleted file mode 100644 index b339ddf595cc..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/signer.rs +++ /dev/null @@ -1,118 +0,0 @@ -//! Traits for generating digital signatures - -use crate::error::Error; - -#[cfg(feature = "digest")] -use crate::digest::Digest; - -#[cfg(feature = "rand_core")] -use crate::rand_core::CryptoRngCore; - -/// Sign the provided message bytestring using `Self` (e.g. a cryptographic key -/// or connection to an HSM), returning a digital signature. -pub trait Signer { - /// Sign the given message and return a digital signature - fn sign(&self, msg: &[u8]) -> S { - self.try_sign(msg).expect("signature operation failed") - } - - /// Attempt to sign the given message, returning a digital signature on - /// success, or an error if something went wrong. - /// - /// The main intended use case for signing errors is when communicating - /// with external signers, e.g. cloud KMS, HSMs, or other hardware tokens. - fn try_sign(&self, msg: &[u8]) -> Result; -} - -/// Sign the provided message bytestring using `&mut Self` (e.g. an evolving -/// cryptographic key such as a stateful hash-based signature), returning a -/// digital signature. -pub trait SignerMut { - /// Sign the given message, update the state, and return a digital signature. - fn sign(&mut self, msg: &[u8]) -> S { - self.try_sign(msg).expect("signature operation failed") - } - - /// Attempt to sign the given message, updating the state, and returning a - /// digital signature on success, or an error if something went wrong. - /// - /// Signing can fail, e.g., if the number of time periods allowed by the - /// current key is exceeded. - fn try_sign(&mut self, msg: &[u8]) -> Result; -} - -/// Blanket impl of [`SignerMut`] for all [`Signer`] types. -impl> SignerMut for T { - fn try_sign(&mut self, msg: &[u8]) -> Result { - T::try_sign(self, msg) - } -} - -/// Sign the given prehashed message [`Digest`] using `Self`. -/// -/// ## Notes -/// -/// This trait is primarily intended for signature algorithms based on the -/// [Fiat-Shamir heuristic], a method for converting an interactive -/// challenge/response-based proof-of-knowledge protocol into an offline -/// digital signature through the use of a random oracle, i.e. a digest -/// function. -/// -/// The security of such protocols critically rests upon the inability of -/// an attacker to solve for the output of the random oracle, as generally -/// otherwise such signature algorithms are a system of linear equations and -/// therefore doing so would allow the attacker to trivially forge signatures. -/// -/// To prevent misuse which would potentially allow this to be possible, this -/// API accepts a [`Digest`] instance, rather than a raw digest value. -/// -/// [Fiat-Shamir heuristic]: https://en.wikipedia.org/wiki/Fiat%E2%80%93Shamir_heuristic -#[cfg(feature = "digest")] -pub trait DigestSigner { - /// Sign the given prehashed message [`Digest`], returning a signature. - /// - /// Panics in the event of a signing error. - fn sign_digest(&self, digest: D) -> S { - self.try_sign_digest(digest) - .expect("signature operation failed") - } - - /// Attempt to sign the given prehashed message [`Digest`], returning a - /// digital signature on success, or an error if something went wrong. - fn try_sign_digest(&self, digest: D) -> Result; -} - -/// Sign the given message using the provided external randomness source. -#[cfg(feature = "rand_core")] -pub trait RandomizedSigner { - /// Sign the given message and return a digital signature - fn sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> S { - self.try_sign_with_rng(rng, msg) - .expect("signature operation failed") - } - - /// Attempt to sign the given message, returning a digital signature on - /// success, or an error if something went wrong. - /// - /// The main intended use case for signing errors is when communicating - /// with external signers, e.g. cloud KMS, HSMs, or other hardware tokens. - fn try_sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> Result; -} - -/// Combination of [`DigestSigner`] and [`RandomizedSigner`] with support for -/// computing a signature over a digest which requires entropy from an RNG. -#[cfg(all(feature = "digest", feature = "rand_core"))] -pub trait RandomizedDigestSigner { - /// Sign the given prehashed message `Digest`, returning a signature. - /// - /// Panics in the event of a signing error. - fn sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D) -> S { - self.try_sign_digest_with_rng(rng, digest) - .expect("signature operation failed") - } - - /// Attempt to sign the given prehashed message `Digest`, returning a - /// digital signature on success, or an error if something went wrong. - fn try_sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D) - -> Result; -} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/verifier.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/verifier.rs deleted file mode 100644 index 65409a9296e1..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/verifier.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Trait for verifying digital signatures - -use crate::error::Error; - -#[cfg(feature = "digest")] -use crate::digest::Digest; - -/// Verify the provided message bytestring using `Self` (e.g. a public key) -pub trait Verifier { - /// Use `Self` to verify that the provided signature for a given message - /// bytestring is authentic. - /// - /// Returns `Error` if it is inauthentic, or otherwise returns `()`. - fn verify(&self, msg: &[u8], signature: &S) -> Result<(), Error>; -} - -/// Verify the provided signature for the given prehashed message [`Digest`] -/// is authentic. -/// -/// ## Notes -/// -/// This trait is primarily intended for signature algorithms based on the -/// [Fiat-Shamir heuristic], a method for converting an interactive -/// challenge/response-based proof-of-knowledge protocol into an offline -/// digital signature through the use of a random oracle, i.e. a digest -/// function. -/// -/// The security of such protocols critically rests upon the inability of -/// an attacker to solve for the output of the random oracle, as generally -/// otherwise such signature algorithms are a system of linear equations and -/// therefore doing so would allow the attacker to trivially forge signatures. -/// -/// To prevent misuse which would potentially allow this to be possible, this -/// API accepts a [`Digest`] instance, rather than a raw digest value. -/// -/// [Fiat-Shamir heuristic]: https://en.wikipedia.org/wiki/Fiat%E2%80%93Shamir_heuristic -#[cfg(feature = "digest")] -pub trait DigestVerifier { - /// Verify the signature against the given [`Digest`] output. - fn verify_digest(&self, digest: D, signature: &S) -> Result<(), Error>; -} diff --git a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/tests/derive.rs b/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/tests/derive.rs deleted file mode 100644 index b54eec8231f1..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/tests/derive.rs +++ /dev/null @@ -1,82 +0,0 @@ -//! Tests for code generated by `signature_derive` - -#![cfg(all(feature = "derive", feature = "digest"))] - -use digest::{generic_array::GenericArray, Digest, OutputSizeUser}; -use hex_literal::hex; -use sha2::Sha256; -use signature::{ - hazmat::{PrehashSigner, PrehashVerifier}, - DigestSigner, DigestVerifier, Error, PrehashSignature, SignatureEncoding, Signer, Verifier, -}; - -/// Test vector to compute SHA-256 digest of -const INPUT_STRING: &[u8] = b"abc"; - -/// Expected SHA-256 digest for the input string -const INPUT_STRING_DIGEST: [u8; 32] = - hex!("ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad"); - -type Repr = GenericArray::OutputSize>; - -/// Dummy signature which just contains a digest output -#[derive(Clone, Debug)] -struct DummySignature(Repr); - -impl PrehashSignature for DummySignature { - type Digest = Sha256; -} - -impl SignatureEncoding for DummySignature { - type Repr = Repr; -} - -impl TryFrom<&[u8]> for DummySignature { - type Error = Error; - - fn try_from(bytes: &[u8]) -> Result { - Ok(DummySignature(GenericArray::clone_from_slice(bytes))) - } -} - -impl From for Repr { - fn from(sig: DummySignature) -> Repr { - sig.0 - } -} - -/// Dummy signer which just returns the message digest as a `DummySignature` -#[derive(Signer, DigestSigner, Default)] -struct DummySigner {} - -impl PrehashSigner for DummySigner { - fn sign_prehash(&self, prehash: &[u8]) -> signature::Result { - DummySignature::try_from(prehash) - } -} - -/// Dummy verifier which ensures the `DummySignature` digest matches the -/// expected value. -/// -/// Panics (via `assert_eq!`) if the value is not what is expected. -#[derive(Verifier, DigestVerifier, Default)] -struct DummyVerifier {} - -impl PrehashVerifier for DummyVerifier { - fn verify_prehash(&self, prehash: &[u8], signature: &DummySignature) -> signature::Result<()> { - assert_eq!(signature.to_bytes().as_slice(), prehash); - Ok(()) - } -} - -#[test] -fn derived_signer_impl() { - let sig: DummySignature = DummySigner::default().sign(INPUT_STRING); - assert_eq!(sig.to_bytes().as_slice(), INPUT_STRING_DIGEST.as_ref()) -} - -#[test] -fn derived_verifier_impl() { - let sig: DummySignature = DummySigner::default().sign(INPUT_STRING); - assert!(DummyVerifier::default().verify(INPUT_STRING, &sig).is_ok()); -} diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/.cargo-checksum.json deleted file mode 100644 index 697c9ce2fbb4..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{}} diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/.cargo_vcs_info.json deleted file mode 100644 index a390d723b2cc..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "15ea461dc3484d48710deed932e4d3d9052c1f9b" - }, - "path_in_vcs": "spki" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/CHANGELOG.md b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/CHANGELOG.md deleted file mode 100644 index cf3722ddee06..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/CHANGELOG.md +++ /dev/null @@ -1,152 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## 0.7.3 (2023-11-28) -### Added -- public key to `SubjectPublicKeyInfoOwned` helper ([#1269]) - -[#1269]: https://github.com/RustCrypto/formats/pull/1269 - -## 0.7.2 (2023-05-04) - -### Added -- `AlgorithmIdentifierWithOid` trait ([#986]) -- `SignatureBitStringEncoding` trait ([#1047]) - -### Changed -- Bump `hex-literal` to v0.4.1 ([#999]) - -[#986]: https://github.com/RustCrypto/formats/pull/986 -[#999]: https://github.com/RustCrypto/formats/pull/999 -[#1047]: https://github.com/RustCrypto/formats/pull/1047 - - -## 0.7.1 (2023-04-04) -### Added -- `AssociatedAlgorithmIdentifier` trait ([#962], [#966]) -- `DynAssociatedAlgorithmIdentifier` trait ([#962]) -- `SignatureAlgorithmIdentifier` trait ([#967]) -- `DynSignatureAlgorithmIdentifier` trait ([#967]) - -### Changed -- Bump `der` dependency to v0.7.2 ([#979]) - -[#962]: https://github.com/RustCrypto/formats/pull/962 -[#966]: https://github.com/RustCrypto/formats/pull/966 -[#967]: https://github.com/RustCrypto/formats/pull/967 -[#979]: https://github.com/RustCrypto/formats/pull/979 - -## 0.7.0 (2023-02-26) -### Changed -- Make `AlgorithmIdentifier` generic around `Params` ([#769]) -- Use blanket impls for `Decode*` traits ([#785]) -- Make `SubjectPublicKeyInfo` own the public key ([#790]) -- Rename `to_owned` method ([#835]) -- Bump `der` dependency to v0.7 ([#899]) - -[#769]: https://github.com/RustCrypto/formats/pull/769 -[#785]: https://github.com/RustCrypto/formats/pull/785 -[#790]: https://github.com/RustCrypto/formats/pull/790 -[#835]: https://github.com/RustCrypto/formats/pull/835 -[#899]: https://github.com/RustCrypto/formats/pull/899 - -## 0.6.0 (2022-05-08) -### Added -- `AlgorithmIdentifier::oids()` helper function ([#443]) -- Impl `PartialOrd` for `AlgorithmIdentifier` ([#476]) -- Impl `DecodeValue` for `AlgorithmIdentifier` ([#449]) -- Impl `ValueOrd` for `SubjectPublicKeyInfo` ([#522]) - -### Changed -- Replace `PublicKeyDocument` with `der` crate's `Document` type ([#571]) -- Streaming fingerprint builder ([#616]) -- Bump `der` crate dependency to v0.6 ([#653]) - -### Removed -- `PublicKeyDocument` ([#571]) - -[#443]: https://github.com/RustCrypto/formats/pull/443 -[#449]: https://github.com/RustCrypto/formats/pull/449 -[#476]: https://github.com/RustCrypto/formats/pull/476 -[#522]: https://github.com/RustCrypto/formats/pull/522 -[#571]: https://github.com/RustCrypto/formats/pull/571 -[#616]: https://github.com/RustCrypto/formats/pull/616 -[#653]: https://github.com/RustCrypto/formats/pull/653 - -## 0.5.4 (2022-01-05) -### Added -- `Error::KeyMalformed` variant ([#318]) - -[#318]: https://github.com/RustCrypto/formats/pull/318 - -## 0.5.3 (2021-12-19) -### Added -- Impl `ValueOrd` for `AlgorithmIdentifier` ([#289]) - -[#289]: https://github.com/RustCrypto/formats/pull/289 - -## 0.5.2 (2021-11-17) -### Changed -- Relax `base64ct` version requirement to `^1` ([#239]) - -[#239]: https://github.com/RustCrypto/formats/pull/239 - -## 0.5.1 (2021-11-17) -### Changed -- Replace `from_spki` with `TryFrom` ([#231]) - -[#231]: https://github.com/RustCrypto/formats/pull/231 - -## 0.5.0 (2021-11-15) [YANKED] -### Added -- SPKI fingerprint support ([#36]) -- `PublicKeyDocument` type originally from `pkcs8` crate ([#118]) -- `Error` type ([#143]) - -### Changed -- Rename `From/ToPublicKey` => `DecodePublicKey`/`EncodePublicKey` ([#119]) -- Use `der::Document` to impl `PublicKeyDocument` ([#134]) -- Rust 2021 edition upgrade; MSRV 1.56 ([#136]) -- Bump `der` dependency to v0.5 ([#222]) - -[#36]: https://github.com/RustCrypto/formats/pull/36 -[#118]: https://github.com/RustCrypto/formats/pull/118 -[#119]: https://github.com/RustCrypto/formats/pull/119 -[#134]: https://github.com/RustCrypto/formats/pull/134 -[#136]: https://github.com/RustCrypto/formats/pull/136 -[#143]: https://github.com/RustCrypto/formats/pull/143 -[#222]: https://github.com/RustCrypto/formats/pull/222 - -## 0.4.1 (2021-09-14) -### Changed -- Moved to `formats` repo ([#2]) - -[#2]: https://github.com/RustCrypto/formats/pull/2 - -## 0.4.0 (2021-06-07) -### Added -- `AlgorithmIdentifier::assert_oids` - -### Changed -- Bump `der` to v0.4 - -## 0.3.0 (2021-03-22) -### Changed -- Bump `der` to v0.3 - -### Removed -- `AlgorithmParameters` enum - -## 0.2.1 (2021-02-22) -### Added -- Impl `Choice` for `AlgorithmParameters` - -## 0.2.0 (2021-02-18) -### Changed -- Return `Result` from `AlgorithmIdentifier::params_*` - -## 0.1.0 (2021-02-16) -- Initial release diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/Cargo.toml deleted file mode 100644 index 1c7f3054445e..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/Cargo.toml +++ /dev/null @@ -1,87 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -rust-version = "1.65" -name = "spki" -version = "0.7.3" -authors = ["RustCrypto Developers"] -description = """ -X.509 Subject Public Key Info (RFC5280) describing public keys as well as their -associated AlgorithmIdentifiers (i.e. OIDs) -""" -readme = "README.md" -keywords = [ - "crypto", - "x509", -] -categories = [ - "cryptography", - "data-structures", - "encoding", - "no-std", -] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/formats/tree/master/spki" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = [ - "--cfg", - "docsrs", -] - -[dependencies.arbitrary] -version = "1.2" -features = ["derive"] -optional = true - -[dependencies.base64ct] -version = "1" -optional = true -default-features = false - -[dependencies.der] -version = "0.7.2" -features = ["oid"] - -[dependencies.sha2] -version = "0.10" -optional = true -default-features = false - -[dev-dependencies.hex-literal] -version = "0.4" - -[dev-dependencies.tempfile] -version = "3" - -[features] -alloc = [ - "base64ct?/alloc", - "der/alloc", -] -arbitrary = [ - "std", - "dep:arbitrary", - "der/arbitrary", -] -base64 = ["dep:base64ct"] -fingerprint = ["sha2"] -pem = [ - "alloc", - "der/pem", -] -std = [ - "der/std", - "alloc", -] diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/Cargo.toml.orig deleted file mode 100644 index e9e268731237..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/Cargo.toml.orig +++ /dev/null @@ -1,40 +0,0 @@ -[package] -name = "spki" -version = "0.7.3" -description = """ -X.509 Subject Public Key Info (RFC5280) describing public keys as well as their -associated AlgorithmIdentifiers (i.e. OIDs) -""" -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" -repository = "https://github.com/RustCrypto/formats/tree/master/spki" -categories = ["cryptography", "data-structures", "encoding", "no-std"] -keywords = ["crypto", "x509"] -readme = "README.md" -edition = "2021" -rust-version = "1.65" - -[dependencies] -der = { version = "0.7.2", features = ["oid"] } - -# Optional dependencies -arbitrary = { version = "1.2", features = ["derive"], optional = true } -base64ct = { version = "1", optional = true, default-features = false } -sha2 = { version = "0.10", optional = true, default-features = false } - -[dev-dependencies] -hex-literal = "0.4" -tempfile = "3" - -[features] -alloc = ["base64ct?/alloc", "der/alloc"] -std = ["der/std", "alloc"] - -arbitrary = ["std", "dep:arbitrary", "der/arbitrary"] -base64 = ["dep:base64ct"] -fingerprint = ["sha2"] -pem = ["alloc", "der/pem"] - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-APACHE b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-APACHE deleted file mode 100644 index 78173fa2e753..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - 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. diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-MIT b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-MIT deleted file mode 100644 index 3294d74345ef..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2021-2023 The RustCrypto Project Developers - -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. diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/README.md b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/README.md deleted file mode 100644 index 4ac8554bfb8c..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# [RustCrypto]: X.509 Subject Public Key Info (SPKI) - -[![crate][crate-image]][crate-link] -[![Docs][docs-image]][docs-link] -[![Build Status][build-image]][build-link] -![Apache2/MIT licensed][license-image] -![Rust Version][rustc-image] -[![Project Chat][chat-image]][chat-link] - -[X.509] Subject Public Key Info types describing public keys as well as their -associated AlgorithmIdentifiers (i.e. OIDs). - -Specified in [RFC 5280 § 4.1]. - -[Documentation][docs-link] - -## Minimum Supported Rust Version - -This crate requires **Rust 1.65** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - -## License - -Licensed under either of: - - * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) - * [MIT license](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. - -[//]: # (badges) - -[crate-image]: https://buildstats.info/crate/spki -[crate-link]: https://crates.io/crates/spki -[docs-image]: https://docs.rs/spki/badge.svg -[docs-link]: https://docs.rs/spki/ -[build-image]: https://github.com/RustCrypto/formats/actions/workflows/spki.yml/badge.svg -[build-link]: https://github.com/RustCrypto/formats/actions/workflows/spki.yml -[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.65+-blue.svg -[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg -[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/300570-formats - -[//]: # (links) - -[RustCrypto]: https://github.com/rustcrypto -[X.509]: https://en.wikipedia.org/wiki/X.509 -[RFC 5280 § 4.1]: https://tools.ietf.org/html/rfc5280#section-4.1 diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/algorithm.rs b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/algorithm.rs deleted file mode 100644 index 5f4b5e8c2411..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/algorithm.rs +++ /dev/null @@ -1,194 +0,0 @@ -//! X.509 `AlgorithmIdentifier` - -use crate::{Error, Result}; -use core::cmp::Ordering; -use der::{ - asn1::{AnyRef, Choice, ObjectIdentifier}, - Decode, DecodeValue, DerOrd, Encode, EncodeValue, Header, Length, Reader, Sequence, ValueOrd, - Writer, -}; - -#[cfg(feature = "alloc")] -use der::asn1::Any; - -/// X.509 `AlgorithmIdentifier` as defined in [RFC 5280 Section 4.1.1.2]. -/// -/// ```text -/// AlgorithmIdentifier ::= SEQUENCE { -/// algorithm OBJECT IDENTIFIER, -/// parameters ANY DEFINED BY algorithm OPTIONAL } -/// ``` -/// -/// [RFC 5280 Section 4.1.1.2]: https://tools.ietf.org/html/rfc5280#section-4.1.1.2 -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct AlgorithmIdentifier { - /// Algorithm OID, i.e. the `algorithm` field in the `AlgorithmIdentifier` - /// ASN.1 schema. - pub oid: ObjectIdentifier, - - /// Algorithm `parameters`. - pub parameters: Option, -} - -impl<'a, Params> DecodeValue<'a> for AlgorithmIdentifier -where - Params: Choice<'a>, -{ - fn decode_value>(reader: &mut R, header: Header) -> der::Result { - reader.read_nested(header.length, |reader| { - Ok(Self { - oid: reader.decode()?, - parameters: reader.decode()?, - }) - }) - } -} - -impl EncodeValue for AlgorithmIdentifier -where - Params: Encode, -{ - fn value_len(&self) -> der::Result { - self.oid.encoded_len()? + self.parameters.encoded_len()? - } - - fn encode_value(&self, writer: &mut impl Writer) -> der::Result<()> { - self.oid.encode(writer)?; - self.parameters.encode(writer)?; - Ok(()) - } -} - -impl<'a, Params> Sequence<'a> for AlgorithmIdentifier where Params: Choice<'a> + Encode {} - -impl<'a, Params> TryFrom<&'a [u8]> for AlgorithmIdentifier -where - Params: Choice<'a> + Encode, -{ - type Error = Error; - - fn try_from(bytes: &'a [u8]) -> Result { - Ok(Self::from_der(bytes)?) - } -} - -impl ValueOrd for AlgorithmIdentifier -where - Params: DerOrd, -{ - fn value_cmp(&self, other: &Self) -> der::Result { - match self.oid.der_cmp(&other.oid)? { - Ordering::Equal => self.parameters.der_cmp(&other.parameters), - other => Ok(other), - } - } -} - -/// `AlgorithmIdentifier` reference which has `AnyRef` parameters. -pub type AlgorithmIdentifierRef<'a> = AlgorithmIdentifier>; - -/// `AlgorithmIdentifier` with `ObjectIdentifier` parameters. -pub type AlgorithmIdentifierWithOid = AlgorithmIdentifier; - -/// `AlgorithmIdentifier` reference which has `Any` parameters. -#[cfg(feature = "alloc")] -pub type AlgorithmIdentifierOwned = AlgorithmIdentifier; - -impl AlgorithmIdentifier { - /// Assert the `algorithm` OID is an expected value. - pub fn assert_algorithm_oid(&self, expected_oid: ObjectIdentifier) -> Result { - if self.oid == expected_oid { - Ok(expected_oid) - } else { - Err(Error::OidUnknown { oid: expected_oid }) - } - } -} - -impl<'a> AlgorithmIdentifierRef<'a> { - /// Assert `parameters` is an OID and has the expected value. - pub fn assert_parameters_oid( - &self, - expected_oid: ObjectIdentifier, - ) -> Result { - let actual_oid = self.parameters_oid()?; - - if actual_oid == expected_oid { - Ok(actual_oid) - } else { - Err(Error::OidUnknown { oid: expected_oid }) - } - } - - /// Assert the values of the `algorithm` and `parameters` OIDs. - pub fn assert_oids( - &self, - algorithm: ObjectIdentifier, - parameters: ObjectIdentifier, - ) -> Result<()> { - self.assert_algorithm_oid(algorithm)?; - self.assert_parameters_oid(parameters)?; - Ok(()) - } - - /// Get the `parameters` field as an [`AnyRef`]. - /// - /// Returns an error if `parameters` are `None`. - pub fn parameters_any(&self) -> Result> { - self.parameters.ok_or(Error::AlgorithmParametersMissing) - } - - /// Get the `parameters` field as an [`ObjectIdentifier`]. - /// - /// Returns an error if it is absent or not an OID. - pub fn parameters_oid(&self) -> Result { - Ok(ObjectIdentifier::try_from(self.parameters_any()?)?) - } - - /// Convert to a pair of [`ObjectIdentifier`]s. - /// - /// This method is helpful for decomposing in match statements. Note in - /// particular that `NULL` parameters are treated the same as missing - /// parameters. - /// - /// Returns an error if parameters are present but not an OID. - pub fn oids(&self) -> der::Result<(ObjectIdentifier, Option)> { - Ok(( - self.oid, - match self.parameters { - None => None, - Some(p) => match p { - AnyRef::NULL => None, - _ => Some(p.decode_as::()?), - }, - }, - )) - } -} - -#[cfg(feature = "alloc")] -mod allocating { - use super::*; - use der::referenced::*; - - impl<'a> RefToOwned<'a> for AlgorithmIdentifierRef<'a> { - type Owned = AlgorithmIdentifierOwned; - fn ref_to_owned(&self) -> Self::Owned { - AlgorithmIdentifier { - oid: self.oid, - parameters: self.parameters.ref_to_owned(), - } - } - } - - impl OwnedToRef for AlgorithmIdentifierOwned { - type Borrowed<'a> = AlgorithmIdentifierRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - AlgorithmIdentifier { - oid: self.oid, - parameters: self.parameters.owned_to_ref(), - } - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/error.rs b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/error.rs deleted file mode 100644 index 9d05990f3bb9..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/error.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! Error types - -use core::fmt; -use der::asn1::ObjectIdentifier; - -/// Result type with `spki` crate's [`Error`] type. -pub type Result = core::result::Result; - -#[cfg(feature = "pem")] -use der::pem; - -/// Error type -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[non_exhaustive] -pub enum Error { - /// Algorithm parameters are missing. - AlgorithmParametersMissing, - - /// ASN.1 DER-related errors. - Asn1(der::Error), - - /// Malformed cryptographic key contained in a SPKI document. - /// - /// This is intended for relaying errors related to the raw data contained - /// in [`SubjectPublicKeyInfo::subject_public_key`][`crate::SubjectPublicKeyInfo::subject_public_key`]. - KeyMalformed, - - /// Unknown algorithm OID. - OidUnknown { - /// Unrecognized OID value found in e.g. a SPKI `AlgorithmIdentifier`. - oid: ObjectIdentifier, - }, -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Error::AlgorithmParametersMissing => { - f.write_str("AlgorithmIdentifier parameters missing") - } - Error::Asn1(err) => write!(f, "ASN.1 error: {}", err), - Error::KeyMalformed => f.write_str("SPKI cryptographic key data malformed"), - Error::OidUnknown { oid } => { - write!(f, "unknown/unsupported algorithm OID: {}", oid) - } - } - } -} - -impl From for Error { - fn from(err: der::Error) -> Error { - if let der::ErrorKind::OidUnknown { oid } = err.kind() { - Error::OidUnknown { oid } - } else { - Error::Asn1(err) - } - } -} - -#[cfg(feature = "pem")] -impl From for Error { - fn from(err: pem::Error) -> Error { - der::Error::from(err).into() - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/fingerprint.rs b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/fingerprint.rs deleted file mode 100644 index ba06e62e819b..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/fingerprint.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! SPKI fingerprint support. - -use der::Writer; -use sha2::{Digest, Sha256}; - -/// Size of a SHA-256 SPKI fingerprint in bytes. -pub(crate) const SIZE: usize = 32; - -/// Raw bytes of a SPKI fingerprint i.e. SHA-256 digest of -/// `SubjectPublicKeyInfo`'s DER encoding. -/// -/// See [RFC7469 § 2.1.1] for more information. -/// -/// [RFC7469 § 2.1.1]: https://datatracker.ietf.org/doc/html/rfc7469#section-2.1.1 -pub type FingerprintBytes = [u8; SIZE]; - -/// Writer newtype which accepts DER being serialized on-the-fly and computes a -/// hash of the contents. -#[derive(Clone, Default)] -pub(crate) struct Builder { - /// In-progress digest being computed from streaming DER. - digest: Sha256, -} - -impl Builder { - /// Create a new fingerprint builder. - pub fn new() -> Self { - Self::default() - } - - /// Finish computing a fingerprint, returning the computed digest. - pub fn finish(self) -> FingerprintBytes { - self.digest.finalize().into() - } -} - -impl Writer for Builder { - fn write(&mut self, der_bytes: &[u8]) -> der::Result<()> { - self.digest.update(der_bytes); - Ok(()) - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/lib.rs deleted file mode 100644 index 6c0caa72a9ba..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/lib.rs +++ /dev/null @@ -1,71 +0,0 @@ -#![no_std] -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![doc = include_str!("../README.md")] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" -)] -#![forbid(unsafe_code)] -#![warn( - clippy::mod_module_files, - clippy::unwrap_used, - missing_docs, - rust_2018_idioms, - unused_lifetimes, - unused_qualifications -)] -//! # Usage -//! The following example demonstrates how to use an OID as the `parameters` -//! of an [`AlgorithmIdentifier`]. -//! -//! Borrow the [`ObjectIdentifier`] first then use [`der::AnyRef::from`] or `.into()`: -//! -//! ``` -//! use spki::{AlgorithmIdentifier, ObjectIdentifier}; -//! -//! let alg_oid = "1.2.840.10045.2.1".parse::().unwrap(); -//! let params_oid = "1.2.840.10045.3.1.7".parse::().unwrap(); -//! -//! let alg_id = AlgorithmIdentifier { -//! oid: alg_oid, -//! parameters: Some(params_oid) -//! }; -//! ``` - -#[cfg(feature = "alloc")] -#[allow(unused_extern_crates)] -extern crate alloc; -#[cfg(feature = "std")] -extern crate std; - -mod algorithm; -mod error; -mod spki; -mod traits; - -#[cfg(feature = "fingerprint")] -mod fingerprint; - -pub use crate::{ - algorithm::{AlgorithmIdentifier, AlgorithmIdentifierRef, AlgorithmIdentifierWithOid}, - error::{Error, Result}, - spki::{SubjectPublicKeyInfo, SubjectPublicKeyInfoRef}, - traits::{AssociatedAlgorithmIdentifier, DecodePublicKey, SignatureAlgorithmIdentifier}, -}; -pub use der::{self, asn1::ObjectIdentifier}; - -#[cfg(feature = "alloc")] -pub use { - crate::{ - algorithm::AlgorithmIdentifierOwned, - spki::SubjectPublicKeyInfoOwned, - traits::{ - DynAssociatedAlgorithmIdentifier, DynSignatureAlgorithmIdentifier, EncodePublicKey, - SignatureBitStringEncoding, - }, - }, - der::Document, -}; - -#[cfg(feature = "fingerprint")] -pub use crate::fingerprint::FingerprintBytes; diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/spki.rs b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/spki.rs deleted file mode 100644 index b7e4c928002c..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/spki.rs +++ /dev/null @@ -1,217 +0,0 @@ -//! X.509 `SubjectPublicKeyInfo` - -use crate::{AlgorithmIdentifier, Error, Result}; -use core::cmp::Ordering; -use der::{ - asn1::{AnyRef, BitStringRef}, - Choice, Decode, DecodeValue, DerOrd, Encode, EncodeValue, FixedTag, Header, Length, Reader, - Sequence, ValueOrd, Writer, -}; - -#[cfg(feature = "alloc")] -use der::{ - asn1::{Any, BitString}, - Document, -}; - -#[cfg(feature = "fingerprint")] -use crate::{fingerprint, FingerprintBytes}; - -#[cfg(feature = "pem")] -use der::pem::PemLabel; - -/// [`SubjectPublicKeyInfo`] with [`AnyRef`] algorithm parameters, and [`BitStringRef`] params. -pub type SubjectPublicKeyInfoRef<'a> = SubjectPublicKeyInfo, BitStringRef<'a>>; - -/// [`SubjectPublicKeyInfo`] with [`Any`] algorithm parameters, and [`BitString`] params. -#[cfg(feature = "alloc")] -pub type SubjectPublicKeyInfoOwned = SubjectPublicKeyInfo; - -/// X.509 `SubjectPublicKeyInfo` (SPKI) as defined in [RFC 5280 § 4.1.2.7]. -/// -/// ASN.1 structure containing an [`AlgorithmIdentifier`] and public key -/// data in an algorithm specific format. -/// -/// ```text -/// SubjectPublicKeyInfo ::= SEQUENCE { -/// algorithm AlgorithmIdentifier, -/// subjectPublicKey BIT STRING } -/// ``` -/// -/// [RFC 5280 § 4.1.2.7]: https://tools.ietf.org/html/rfc5280#section-4.1.2.7 -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct SubjectPublicKeyInfo { - /// X.509 [`AlgorithmIdentifier`] for the public key type - pub algorithm: AlgorithmIdentifier, - - /// Public key data - pub subject_public_key: Key, -} - -impl<'a, Params, Key> SubjectPublicKeyInfo -where - Params: Choice<'a> + Encode, - // TODO: replace FixedTag with FixedTag once - // https://github.com/rust-lang/rust/issues/92827 is fixed - Key: Decode<'a> + Encode + FixedTag, -{ - /// Calculate the SHA-256 fingerprint of this [`SubjectPublicKeyInfo`] and - /// encode it as a Base64 string. - /// - /// See [RFC7469 § 2.1.1] for more information. - /// - /// [RFC7469 § 2.1.1]: https://datatracker.ietf.org/doc/html/rfc7469#section-2.1.1 - #[cfg(all(feature = "fingerprint", feature = "alloc", feature = "base64"))] - pub fn fingerprint_base64(&self) -> Result { - use base64ct::{Base64, Encoding}; - Ok(Base64::encode_string(&self.fingerprint_bytes()?)) - } - - /// Calculate the SHA-256 fingerprint of this [`SubjectPublicKeyInfo`] as - /// a raw byte array. - /// - /// See [RFC7469 § 2.1.1] for more information. - /// - /// [RFC7469 § 2.1.1]: https://datatracker.ietf.org/doc/html/rfc7469#section-2.1.1 - #[cfg(feature = "fingerprint")] - pub fn fingerprint_bytes(&self) -> Result { - let mut builder = fingerprint::Builder::new(); - self.encode(&mut builder)?; - Ok(builder.finish()) - } -} - -impl<'a: 'k, 'k, Params, Key: 'k> DecodeValue<'a> for SubjectPublicKeyInfo -where - Params: Choice<'a> + Encode, - Key: Decode<'a>, -{ - fn decode_value>(reader: &mut R, header: Header) -> der::Result { - reader.read_nested(header.length, |reader| { - Ok(Self { - algorithm: reader.decode()?, - subject_public_key: Key::decode(reader)?, - }) - }) - } -} - -impl<'a, Params, Key> EncodeValue for SubjectPublicKeyInfo -where - Params: Choice<'a> + Encode, - Key: Encode, -{ - fn value_len(&self) -> der::Result { - self.algorithm.encoded_len()? + self.subject_public_key.encoded_len()? - } - - fn encode_value(&self, writer: &mut impl Writer) -> der::Result<()> { - self.algorithm.encode(writer)?; - self.subject_public_key.encode(writer)?; - Ok(()) - } -} - -impl<'a, Params, Key> Sequence<'a> for SubjectPublicKeyInfo -where - Params: Choice<'a> + Encode, - Key: Decode<'a> + Encode + FixedTag, -{ -} - -impl<'a, Params, Key> TryFrom<&'a [u8]> for SubjectPublicKeyInfo -where - Params: Choice<'a> + Encode, - Key: Decode<'a> + Encode + FixedTag, -{ - type Error = Error; - - fn try_from(bytes: &'a [u8]) -> Result { - Ok(Self::from_der(bytes)?) - } -} - -impl<'a, Params, Key> ValueOrd for SubjectPublicKeyInfo -where - Params: Choice<'a> + DerOrd + Encode, - Key: ValueOrd, -{ - fn value_cmp(&self, other: &Self) -> der::Result { - match self.algorithm.der_cmp(&other.algorithm)? { - Ordering::Equal => self.subject_public_key.value_cmp(&other.subject_public_key), - other => Ok(other), - } - } -} - -#[cfg(feature = "alloc")] -impl<'a: 'k, 'k, Params, Key: 'k> TryFrom> for Document -where - Params: Choice<'a> + Encode, - Key: Decode<'a> + Encode + FixedTag, - BitStringRef<'a>: From<&'k Key>, -{ - type Error = Error; - - fn try_from(spki: SubjectPublicKeyInfo) -> Result { - Self::try_from(&spki) - } -} - -#[cfg(feature = "alloc")] -impl<'a: 'k, 'k, Params, Key: 'k> TryFrom<&SubjectPublicKeyInfo> for Document -where - Params: Choice<'a> + Encode, - Key: Decode<'a> + Encode + FixedTag, - BitStringRef<'a>: From<&'k Key>, -{ - type Error = Error; - - fn try_from(spki: &SubjectPublicKeyInfo) -> Result { - Ok(Self::encode_msg(spki)?) - } -} - -#[cfg(feature = "pem")] -impl PemLabel for SubjectPublicKeyInfo { - const PEM_LABEL: &'static str = "PUBLIC KEY"; -} - -#[cfg(feature = "alloc")] -mod allocating { - use super::*; - use crate::EncodePublicKey; - use der::referenced::*; - - impl<'a> RefToOwned<'a> for SubjectPublicKeyInfoRef<'a> { - type Owned = SubjectPublicKeyInfoOwned; - fn ref_to_owned(&self) -> Self::Owned { - SubjectPublicKeyInfo { - algorithm: self.algorithm.ref_to_owned(), - subject_public_key: self.subject_public_key.ref_to_owned(), - } - } - } - - impl OwnedToRef for SubjectPublicKeyInfoOwned { - type Borrowed<'a> = SubjectPublicKeyInfoRef<'a>; - fn owned_to_ref(&self) -> Self::Borrowed<'_> { - SubjectPublicKeyInfo { - algorithm: self.algorithm.owned_to_ref(), - subject_public_key: self.subject_public_key.owned_to_ref(), - } - } - } - - impl SubjectPublicKeyInfoOwned { - /// Create a [`SubjectPublicKeyInfoOwned`] from any object that implements - /// [`EncodePublicKey`]. - pub fn from_key(source: T) -> Result - where - T: EncodePublicKey, - { - Ok(source.to_public_key_der()?.decode_msg::()?) - } - } -} diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/traits.rs b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/traits.rs deleted file mode 100644 index 764b02a4a5fa..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/traits.rs +++ /dev/null @@ -1,184 +0,0 @@ -//! Traits for encoding/decoding SPKI public keys. - -use crate::{AlgorithmIdentifier, Error, Result, SubjectPublicKeyInfoRef}; -use der::{EncodeValue, Tagged}; - -#[cfg(feature = "alloc")] -use { - crate::AlgorithmIdentifierOwned, - der::{asn1::BitString, Any, Document}, -}; - -#[cfg(feature = "pem")] -use { - alloc::string::String, - der::pem::{LineEnding, PemLabel}, -}; - -#[cfg(feature = "std")] -use std::path::Path; - -#[cfg(doc)] -use crate::SubjectPublicKeyInfo; - -/// Parse a public key object from an encoded SPKI document. -pub trait DecodePublicKey: Sized { - /// Deserialize object from ASN.1 DER-encoded [`SubjectPublicKeyInfo`] - /// (binary format). - fn from_public_key_der(bytes: &[u8]) -> Result; - - /// Deserialize PEM-encoded [`SubjectPublicKeyInfo`]. - /// - /// Keys in this format begin with the following delimiter: - /// - /// ```text - /// -----BEGIN PUBLIC KEY----- - /// ``` - #[cfg(feature = "pem")] - fn from_public_key_pem(s: &str) -> Result { - let (label, doc) = Document::from_pem(s)?; - SubjectPublicKeyInfoRef::validate_pem_label(label)?; - Self::from_public_key_der(doc.as_bytes()) - } - - /// Load public key object from an ASN.1 DER-encoded file on the local - /// filesystem (binary format). - #[cfg(feature = "std")] - fn read_public_key_der_file(path: impl AsRef) -> Result { - let doc = Document::read_der_file(path)?; - Self::from_public_key_der(doc.as_bytes()) - } - - /// Load public key object from a PEM-encoded file on the local filesystem. - #[cfg(all(feature = "pem", feature = "std"))] - fn read_public_key_pem_file(path: impl AsRef) -> Result { - let (label, doc) = Document::read_pem_file(path)?; - SubjectPublicKeyInfoRef::validate_pem_label(&label)?; - Self::from_public_key_der(doc.as_bytes()) - } -} - -impl DecodePublicKey for T -where - T: for<'a> TryFrom, Error = Error>, -{ - fn from_public_key_der(bytes: &[u8]) -> Result { - Self::try_from(SubjectPublicKeyInfoRef::try_from(bytes)?) - } -} - -/// Serialize a public key object to a SPKI-encoded document. -#[cfg(feature = "alloc")] -pub trait EncodePublicKey { - /// Serialize a [`Document`] containing a SPKI-encoded public key. - fn to_public_key_der(&self) -> Result; - - /// Serialize this public key as PEM-encoded SPKI with the given [`LineEnding`]. - #[cfg(feature = "pem")] - fn to_public_key_pem(&self, line_ending: LineEnding) -> Result { - let doc = self.to_public_key_der()?; - Ok(doc.to_pem(SubjectPublicKeyInfoRef::PEM_LABEL, line_ending)?) - } - - /// Write ASN.1 DER-encoded public key to the given path - #[cfg(feature = "std")] - fn write_public_key_der_file(&self, path: impl AsRef) -> Result<()> { - Ok(self.to_public_key_der()?.write_der_file(path)?) - } - - /// Write ASN.1 DER-encoded public key to the given path - #[cfg(all(feature = "pem", feature = "std"))] - fn write_public_key_pem_file( - &self, - path: impl AsRef, - line_ending: LineEnding, - ) -> Result<()> { - let doc = self.to_public_key_der()?; - Ok(doc.write_pem_file(path, SubjectPublicKeyInfoRef::PEM_LABEL, line_ending)?) - } -} - -/// Returns `AlgorithmIdentifier` associated with the structure. -/// -/// This is useful for e.g. keys for digital signature algorithms. -pub trait AssociatedAlgorithmIdentifier { - /// Algorithm parameters. - type Params: Tagged + EncodeValue; - - /// `AlgorithmIdentifier` for this structure. - const ALGORITHM_IDENTIFIER: AlgorithmIdentifier; -} - -/// Returns `AlgorithmIdentifier` associated with the structure. -/// -/// This is useful for e.g. keys for digital signature algorithms. -#[cfg(feature = "alloc")] -pub trait DynAssociatedAlgorithmIdentifier { - /// `AlgorithmIdentifier` for this structure. - fn algorithm_identifier(&self) -> Result; -} - -#[cfg(feature = "alloc")] -impl DynAssociatedAlgorithmIdentifier for T -where - T: AssociatedAlgorithmIdentifier, -{ - fn algorithm_identifier(&self) -> Result { - Ok(AlgorithmIdentifierOwned { - oid: T::ALGORITHM_IDENTIFIER.oid, - parameters: T::ALGORITHM_IDENTIFIER - .parameters - .as_ref() - .map(Any::encode_from) - .transpose()?, - }) - } -} - -/// Returns `AlgorithmIdentifier` associated with the signature system. -/// -/// Unlike AssociatedAlgorithmIdentifier this is intended to be implemented for public and/or -/// private keys. -pub trait SignatureAlgorithmIdentifier { - /// Algorithm parameters. - type Params: Tagged + EncodeValue; - - /// `AlgorithmIdentifier` for the corresponding singature system. - const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier; -} - -/// Returns `AlgorithmIdentifier` associated with the signature system. -/// -/// Unlike AssociatedAlgorithmIdentifier this is intended to be implemented for public and/or -/// private keys. -#[cfg(feature = "alloc")] -pub trait DynSignatureAlgorithmIdentifier { - /// `AlgorithmIdentifier` for the corresponding singature system. - fn signature_algorithm_identifier(&self) -> Result; -} - -#[cfg(feature = "alloc")] -impl DynSignatureAlgorithmIdentifier for T -where - T: SignatureAlgorithmIdentifier, -{ - fn signature_algorithm_identifier(&self) -> Result { - Ok(AlgorithmIdentifierOwned { - oid: T::SIGNATURE_ALGORITHM_IDENTIFIER.oid, - parameters: T::SIGNATURE_ALGORITHM_IDENTIFIER - .parameters - .as_ref() - .map(Any::encode_from) - .transpose()?, - }) - } -} - -/// Returns the `BitString` encoding of the signature. -/// -/// X.509 and CSR structures require signatures to be BitString encoded. -#[cfg(feature = "alloc")] -pub trait SignatureBitStringEncoding { - /// `BitString` encoding for this signature. - fn to_bitstring(&self) -> der::Result; -} diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/ed25519-pub.der b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/ed25519-pub.der deleted file mode 100644 index 1b602ee1f2754f327636c7e58cbbf340dd7ca82b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44 zcmXreGGJw6)=n*8R%Gzi6sxzF6k7Iu?JrF$Rw>Z~amT9r#nq~1LIdu+2;R#J00n>! ARR910 diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/ed25519-pub.pem b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/ed25519-pub.pem deleted file mode 100644 index 6891701f7888..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/ed25519-pub.pem +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEATSkWfz8ZEqb3rfopOgUaFcBexnuPFyZ7HFVQ3OhTvQ0= ------END PUBLIC KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/p256-pub.der b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/p256-pub.der deleted file mode 100644 index 67c719c7641d6bc2b1b122bcd287e2947daed3d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 91 zcmXqrG!SNE*J|@PXUoLM#sOw9GqN)~F|f$2`M)(@U+4Xext*`gz112;Re~CH-z}Ia u#@1+l!}5Ink;Wx1lMH<8zGWR0-}kS1#f5&+c0ondAf&n5h4F(A+hDe6@4FLfG1potr0S^E$f&mHwf&l>lw!|z^Ul69M@`A=b z+u}k)p>Xs1CNsTAGh=^8%1>`L;5uC?@531y$PYOUhf6u*4?$1P!Tg}@f#pZ-!p%4= zcJ>^Q7?(Y{`crvwr^f;Iw|)tN-@#wN87J;ueA!D+S)cH56Q{^18{Z<_yqed_yL>|t z$%6Hc+j0}FMOd>kCT(;&?SYcfh)k`xu}3+m+S+E^mk0*g$E-yRu{{lZS6{K1Q%}Yl z#2diyS56KAFvq*Uz5U7drsCt`ukp+3$eX2jgi?)F&#;3hq3Fn;P5?aeh>nvoLD|-o syt}O2khD%d316ddSn4IQKVB(ZzN~HNIIE0MuVLbtms^J~0s{d60e+T>_W%F@ diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/rsa2048-pub.pem b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/rsa2048-pub.pem deleted file mode 100644 index 5ecd892394ee..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/examples/rsa2048-pub.pem +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtsQsUV8QpqrygsY+2+JC -Q6Fw8/omM71IM2N/R8pPbzbgOl0p78MZGsgPOQ2HSznjD0FPzsH8oO2B5Uftws04 -LHb2HJAYlz25+lN5cqfHAfa3fgmC38FfwBkn7l582UtPWZ/wcBOnyCgb3yLcvJrX -yrt8QxHJgvWO23ITrUVYszImbXQ67YGS0YhMrbixRzmo2tpm3JcIBtnHrEUMsT0N -fFdfsZhTT8YbxBvA8FdODgEwx7u/vf3J9qbi4+Kv8cvqyJuleIRSjVXPsIMnoejI -n04APPKIjpMyQdnWlby7rNyQtE4+CV+jcFjqJbE/Xilcvqxt6DirjFCvYeKYl1uH -LwIDAQAB ------END PUBLIC KEY----- diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/spki.rs b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/spki.rs deleted file mode 100644 index f912d4875dfc..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/spki.rs +++ /dev/null @@ -1,161 +0,0 @@ -//! `SubjectPublicKeyInfo` tests. - -use der::asn1::ObjectIdentifier; -use hex_literal::hex; -use spki::SubjectPublicKeyInfoRef; - -#[cfg(feature = "alloc")] -use der::Encode; - -#[cfg(feature = "pem")] -use der::{pem::LineEnding, EncodePem}; - -/// Elliptic Curve (P-256) `SubjectPublicKeyInfo` encoded as ASN.1 DER -const EC_P256_DER_EXAMPLE: &[u8] = include_bytes!("examples/p256-pub.der"); - -/// Ed25519 `SubjectPublicKeyInfo` encoded as ASN.1 DER -#[cfg(any(feature = "alloc", feature = "fingerprint"))] -const ED25519_DER_EXAMPLE: &[u8] = include_bytes!("examples/ed25519-pub.der"); - -/// RSA-2048 `SubjectPublicKeyInfo` encoded as ASN.1 DER -const RSA_2048_DER_EXAMPLE: &[u8] = include_bytes!("examples/rsa2048-pub.der"); - -/// Elliptic Curve (P-256) public key encoded as PEM -#[cfg(feature = "pem")] -const EC_P256_PEM_EXAMPLE: &str = include_str!("examples/p256-pub.pem"); - -/// Ed25519 public key encoded as PEM -#[cfg(feature = "pem")] -const ED25519_PEM_EXAMPLE: &str = include_str!("examples/ed25519-pub.pem"); - -/// RSA-2048 PKCS#8 public key encoded as PEM -#[cfg(feature = "pem")] -const RSA_2048_PEM_EXAMPLE: &str = include_str!("examples/rsa2048-pub.pem"); - -/// The SPKI fingerprint for `ED25519_SPKI_FINGERPRINT` as a Base64 string -/// -/// Generated using `cat ed25519-pub.der | openssl dgst -binary -sha256 | base64` -#[cfg(all(feature = "alloc", feature = "base64", feature = "fingerprint"))] -const ED25519_SPKI_FINGERPRINT_BASE64: &str = "Vd1MdLDkhTTi9OFzzs61DfjyenrCqomRzHrpFOAwvO0="; - -/// The SPKI fingerprint for `ED25519_SPKI_FINGERPRINT` as straight hash bytes -/// -/// Generated using `cat ed25519-pub.der | openssl dgst -sha256` -#[cfg(feature = "fingerprint")] -const ED25519_SPKI_FINGERPRINT: &[u8] = - &hex!("55dd4c74b0e48534e2f4e173ceceb50df8f27a7ac2aa8991cc7ae914e030bced"); - -#[test] -fn decode_ec_p256_der() { - let spki = SubjectPublicKeyInfoRef::try_from(EC_P256_DER_EXAMPLE).unwrap(); - - assert_eq!(spki.algorithm.oid, "1.2.840.10045.2.1".parse().unwrap()); - - assert_eq!( - spki.algorithm - .parameters - .unwrap() - .decode_as::() - .unwrap(), - "1.2.840.10045.3.1.7".parse().unwrap() - ); - - assert_eq!(spki.subject_public_key.raw_bytes(), &hex!("041CACFFB55F2F2CEFD89D89EB374B2681152452802DEEA09916068137D839CF7FC481A44492304D7EF66AC117BEFE83A8D08F155F2B52F9F618DD447029048E0F")[..]); -} - -#[test] -#[cfg(feature = "fingerprint")] -fn decode_ed25519_and_fingerprint_spki() { - // Repeat the decode test from the pkcs8 crate - let spki = SubjectPublicKeyInfoRef::try_from(ED25519_DER_EXAMPLE).unwrap(); - - assert_eq!(spki.algorithm.oid, "1.3.101.112".parse().unwrap()); - assert_eq!(spki.algorithm.parameters, None); - assert_eq!( - spki.subject_public_key.raw_bytes(), - &hex!("4D29167F3F1912A6F7ADFA293A051A15C05EC67B8F17267B1C5550DCE853BD0D")[..] - ); - - // Check the fingerprint - assert_eq!( - spki.fingerprint_bytes().unwrap().as_slice(), - ED25519_SPKI_FINGERPRINT - ); -} - -#[test] -#[cfg(all(feature = "alloc", feature = "base64", feature = "fingerprint"))] -fn decode_ed25519_and_fingerprint_base64() { - // Repeat the decode test from the pkcs8 crate - let spki = SubjectPublicKeyInfoRef::try_from(ED25519_DER_EXAMPLE).unwrap(); - - assert_eq!(spki.algorithm.oid, "1.3.101.112".parse().unwrap()); - assert_eq!(spki.algorithm.parameters, None); - assert_eq!( - spki.subject_public_key.raw_bytes(), - &hex!("4D29167F3F1912A6F7ADFA293A051A15C05EC67B8F17267B1C5550DCE853BD0D")[..] - ); - - // Check the fingerprint - assert_eq!( - spki.fingerprint_base64().unwrap(), - ED25519_SPKI_FINGERPRINT_BASE64 - ); -} - -#[test] -fn decode_rsa_2048_der() { - let spki = SubjectPublicKeyInfoRef::try_from(RSA_2048_DER_EXAMPLE).unwrap(); - - assert_eq!(spki.algorithm.oid, "1.2.840.113549.1.1.1".parse().unwrap()); - assert!(spki.algorithm.parameters.unwrap().is_null()); - assert_eq!(spki.subject_public_key.raw_bytes(), &hex!("3082010A0282010100B6C42C515F10A6AAF282C63EDBE24243A170F3FA2633BD4833637F47CA4F6F36E03A5D29EFC3191AC80F390D874B39E30F414FCEC1FCA0ED81E547EDC2CD382C76F61C9018973DB9FA537972A7C701F6B77E0982DFC15FC01927EE5E7CD94B4F599FF07013A7C8281BDF22DCBC9AD7CABB7C4311C982F58EDB7213AD4558B332266D743AED8192D1884CADB8B14739A8DADA66DC970806D9C7AC450CB13D0D7C575FB198534FC61BC41BC0F0574E0E0130C7BBBFBDFDC9F6A6E2E3E2AFF1CBEAC89BA57884528D55CFB08327A1E8C89F4E003CF2888E933241D9D695BCBBACDC90B44E3E095FA37058EA25B13F5E295CBEAC6DE838AB8C50AF61E298975B872F0203010001")[..]); -} - -#[test] -#[cfg(feature = "alloc")] -fn encode_ec_p256_der() { - let pk = SubjectPublicKeyInfoRef::try_from(EC_P256_DER_EXAMPLE).unwrap(); - let pk_encoded = pk.to_der().unwrap(); - assert_eq!(EC_P256_DER_EXAMPLE, pk_encoded.as_slice()); -} - -#[test] -#[cfg(feature = "alloc")] -fn encode_ed25519_der() { - let pk = SubjectPublicKeyInfoRef::try_from(ED25519_DER_EXAMPLE).unwrap(); - let pk_encoded = pk.to_der().unwrap(); - assert_eq!(ED25519_DER_EXAMPLE, pk_encoded.as_slice()); -} - -#[test] -#[cfg(feature = "alloc")] -fn encode_rsa_2048_der() { - let pk = SubjectPublicKeyInfoRef::try_from(RSA_2048_DER_EXAMPLE).unwrap(); - let pk_encoded = pk.to_der().unwrap(); - assert_eq!(RSA_2048_DER_EXAMPLE, pk_encoded.as_slice()); -} - -#[test] -#[cfg(feature = "pem")] -fn encode_ec_p256_pem() { - let pk = SubjectPublicKeyInfoRef::try_from(EC_P256_DER_EXAMPLE).unwrap(); - let pk_encoded = pk.to_pem(LineEnding::LF).unwrap(); - assert_eq!(EC_P256_PEM_EXAMPLE, pk_encoded); -} - -#[test] -#[cfg(feature = "pem")] -fn encode_ed25519_pem() { - let pk = SubjectPublicKeyInfoRef::try_from(ED25519_DER_EXAMPLE).unwrap(); - let pk_encoded = pk.to_pem(LineEnding::LF).unwrap(); - assert_eq!(ED25519_PEM_EXAMPLE, pk_encoded); -} - -#[test] -#[cfg(feature = "pem")] -fn encode_rsa_2048_pem() { - let pk = SubjectPublicKeyInfoRef::try_from(RSA_2048_DER_EXAMPLE).unwrap(); - let pk_encoded = pk.to_pem(LineEnding::LF).unwrap(); - assert_eq!(RSA_2048_PEM_EXAMPLE, pk_encoded); -} diff --git a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/traits.rs b/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/traits.rs deleted file mode 100644 index 111433343aa0..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/tests/traits.rs +++ /dev/null @@ -1,102 +0,0 @@ -//! Tests for SPKI encoding/decoding traits. - -#![cfg(any(feature = "pem", feature = "std"))] - -use der::{Decode, Encode}; -use spki::{DecodePublicKey, Document, EncodePublicKey, Error, Result, SubjectPublicKeyInfoRef}; - -#[cfg(feature = "pem")] -use spki::der::pem::LineEnding; - -#[cfg(feature = "std")] -use tempfile::tempdir; - -#[cfg(all(feature = "pem", feature = "std"))] -use std::fs; - -/// Ed25519 `SubjectPublicKeyInfo` encoded as ASN.1 DER -const ED25519_DER_EXAMPLE: &[u8] = include_bytes!("examples/ed25519-pub.der"); - -/// Ed25519 public key encoded as PEM -#[cfg(feature = "pem")] -const ED25519_PEM_EXAMPLE: &str = include_str!("examples/ed25519-pub.pem"); - -/// Mock key type for testing trait impls against. -pub struct MockKey(Vec); - -impl AsRef<[u8]> for MockKey { - fn as_ref(&self) -> &[u8] { - self.0.as_ref() - } -} - -impl EncodePublicKey for MockKey { - fn to_public_key_der(&self) -> Result { - Ok(Document::from_der(self.as_ref())?) - } -} - -impl TryFrom> for MockKey { - type Error = Error; - - fn try_from(spki: SubjectPublicKeyInfoRef<'_>) -> Result { - Ok(MockKey(spki.to_der()?)) - } -} - -#[cfg(feature = "pem")] -#[test] -fn from_public_key_pem() { - let key = MockKey::from_public_key_pem(ED25519_PEM_EXAMPLE).unwrap(); - assert_eq!(key.as_ref(), ED25519_DER_EXAMPLE); -} - -#[cfg(feature = "std")] -#[test] -fn read_public_key_der_file() { - let key = MockKey::read_public_key_der_file("tests/examples/ed25519-pub.der").unwrap(); - assert_eq!(key.as_ref(), ED25519_DER_EXAMPLE); -} - -#[cfg(all(feature = "pem", feature = "std"))] -#[test] -fn read_public_key_pem_file() { - let key = MockKey::read_public_key_pem_file("tests/examples/ed25519-pub.pem").unwrap(); - assert_eq!(key.as_ref(), ED25519_DER_EXAMPLE); -} - -#[cfg(feature = "pem")] -#[test] -fn to_public_key_pem() { - let pem = MockKey(ED25519_DER_EXAMPLE.to_vec()) - .to_public_key_pem(LineEnding::LF) - .unwrap(); - - assert_eq!(pem, ED25519_PEM_EXAMPLE); -} - -#[cfg(feature = "std")] -#[test] -fn write_public_key_der_file() { - let dir = tempdir().unwrap(); - let path = dir.path().join("example.der"); - MockKey(ED25519_DER_EXAMPLE.to_vec()) - .write_public_key_der_file(&path) - .unwrap(); - - let key = MockKey::read_public_key_der_file(&path).unwrap(); - assert_eq!(key.as_ref(), ED25519_DER_EXAMPLE); -} - -#[cfg(all(feature = "pem", feature = "std"))] -#[test] -fn write_public_key_pem_file() { - let dir = tempdir().unwrap(); - let path = dir.path().join("example.pem"); - MockKey(ED25519_DER_EXAMPLE.to_vec()) - .write_public_key_pem_file(&path, LineEnding::LF) - .unwrap(); - - let pem = fs::read_to_string(path).unwrap(); - assert_eq!(&pem, ED25519_PEM_EXAMPLE); -} diff --git a/third_party/rust/const_oid/v0_9/BUILD.gn b/third_party/rust/const_oid/v0_9/BUILD.gn deleted file mode 100644 index 132a3c9ec74f..000000000000 --- a/third_party/rust/const_oid/v0_9/BUILD.gn +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "const_oid" - epoch = "0.9" - crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/lib.rs" - sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/arcs.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/checked.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/db/gen.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/encoder.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/error.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/parser.rs", - ] - inputs = [ "//brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/src/../README.md" ] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "0.9.6" - cargo_pkg_authors = "RustCrypto Developers" - cargo_pkg_name = "const-oid" - cargo_pkg_description = "Const-friendly implementation of the ISO/IEC Object Identifier (OID) standard as defined in ITU X.660, with support for BER/DER encoding/decoding as well as heapless no_std (i.e. embedded) support" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] -} diff --git a/third_party/rust/const_oid/v0_9/README.chromium b/third_party/rust/const_oid/v0_9/README.chromium deleted file mode 100644 index 1d7a0ceb3b2e..000000000000 --- a/third_party/rust/const_oid/v0_9/README.chromium +++ /dev/null @@ -1,12 +0,0 @@ -Name: const-oid -URL: https://crates.io/crates/const-oid -Description: Const-friendly implementation of the ISO/IEC Object Identifier (OID) standard -as defined in ITU X.660, with support for BER/DER encoding/decoding as well as -heapless no_std (i.e. embedded) support - -Version: 0.9.6 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/const-oid-0.9.6/LICENSE-APACHE -Revision: 4432bcc0b2b721865740517e609e166e01726ccc diff --git a/third_party/rust/der/v0_7/BUILD.gn b/third_party/rust/der/v0_7/BUILD.gn deleted file mode 100644 index c4b8b427997c..000000000000 --- a/third_party/rust/der/v0_7/BUILD.gn +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "der" - epoch = "0.7" - crate_type = "rlib" - crate_root = - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/lib.rs" - sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/arrayvec.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/any.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bit_string.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/bmp_string.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/boolean.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/choice.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/context_specific.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/generalized_time.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/ia5_string.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/int.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/integer/uint.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/internal_macros.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/null.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/octet_string.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/oid.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/optional.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/printable_string.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/real.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/sequence_of.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/set_of.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/teletex_string.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utc_time.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/utf8_string.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/asn1/videotex_string.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_owned.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/bytes_ref.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/datetime.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/decode.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/document.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/encode_ref.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/error.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/header.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/length.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/ord.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/nested.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/pem.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/reader/slice.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/referenced.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_owned.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/str_ref.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/class.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/mode.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/tag/number.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/pem.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/writer/slice.rs", - ] - inputs = [ "//brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/src/../README.md" ] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "0.7.9" - cargo_pkg_authors = "RustCrypto Developers" - cargo_pkg_name = "der" - cargo_pkg_description = "Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules (DER) for Abstract Syntax Notation One (ASN.1) as described in ITU X.690 with full support for heapless no_std targets" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ - "//brave/third_party/rust/const_oid/v0_9:lib", - "//brave/third_party/rust/zeroize/v1:lib", - ] - features = [ - "alloc", - "oid", - "std", - "zeroize", - ] -} diff --git a/third_party/rust/der/v0_7/README.chromium b/third_party/rust/der/v0_7/README.chromium deleted file mode 100644 index df9a79b1fb12..000000000000 --- a/third_party/rust/der/v0_7/README.chromium +++ /dev/null @@ -1,12 +0,0 @@ -Name: der -URL: https://crates.io/crates/der -Description: Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules -(DER) for Abstract Syntax Notation One (ASN.1) as described in ITU X.690 with -full support for heapless no_std targets - -Version: 0.7.9 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/der-0.7.9/LICENSE-APACHE -Revision: 9bf880934c350a5af67df17ba12bf8636486f7f9 diff --git a/third_party/rust/derivation_path/v0_2/BUILD.gn b/third_party/rust/derivation_path/v0_2/BUILD.gn deleted file mode 100644 index 7b59b12d881c..000000000000 --- a/third_party/rust/derivation_path/v0_2/BUILD.gn +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "derivation_path" - epoch = "0.2" - crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/src/lib.rs" - sources = [ "//brave/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/src/lib.rs" ] - inputs = [] - - build_native_rust_unit_tests = false - edition = "2018" - cargo_pkg_version = "0.2.0" - cargo_pkg_authors = "Julian Popescu " - cargo_pkg_name = "derivation-path" - cargo_pkg_description = - "Simple struct for dealing with BIP32/44/49 derivation paths" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - features = [ "std" ] -} diff --git a/third_party/rust/derivation_path/v0_2/README.chromium b/third_party/rust/derivation_path/v0_2/README.chromium deleted file mode 100644 index dc26367cd127..000000000000 --- a/third_party/rust/derivation_path/v0_2/README.chromium +++ /dev/null @@ -1,9 +0,0 @@ -Name: derivation-path -URL: https://crates.io/crates/derivation-path -Description: Simple struct for dealing with BIP32/44/49 derivation paths -Version: 0.2.0 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/derivation-path-0.2.0/../../../../../common/licenses/Apache-2.0 -Revision: dec9b215770cc5d4445edc02b61586b29b4f3dfb diff --git a/third_party/rust/ed25519/v2/BUILD.gn b/third_party/rust/ed25519/v2/BUILD.gn deleted file mode 100644 index 5d6beb921ab6..000000000000 --- a/third_party/rust/ed25519/v2/BUILD.gn +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "ed25519" - epoch = "2" - crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/lib.rs" - sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/hex.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/pkcs8.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/serde.rs", - ] - inputs = [ "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/src/../README.md" ] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "2.2.3" - cargo_pkg_authors = "RustCrypto Developers" - cargo_pkg_name = "ed25519" - cargo_pkg_description = "Edwards Digital Signature Algorithm (EdDSA) over Curve25519 (as specified in RFC 8032) support library providing signature type definitions and PKCS#8 private key decoding/encoding support" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ - "//brave/third_party/rust/pkcs8/v0_10:lib", - "//brave/third_party/rust/signature/v2:lib", - ] - features = [ - "alloc", - "std", - ] -} diff --git a/third_party/rust/ed25519/v2/README.chromium b/third_party/rust/ed25519/v2/README.chromium deleted file mode 100644 index 67ee70335766..000000000000 --- a/third_party/rust/ed25519/v2/README.chromium +++ /dev/null @@ -1,12 +0,0 @@ -Name: ed25519 -URL: https://crates.io/crates/ed25519 -Description: Edwards Digital Signature Algorithm (EdDSA) over Curve25519 (as specified in RFC 8032) -support library providing signature type definitions and PKCS#8 private key -decoding/encoding support - -Version: 2.2.3 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/ed25519-2.2.3/LICENSE-APACHE -Revision: 07b095c32a3527ee47da5c4878bf203557b36e5e diff --git a/third_party/rust/ed25519_dalek/v2/BUILD.gn b/third_party/rust/ed25519_dalek/v2/BUILD.gn deleted file mode 100644 index 15fcb151682f..000000000000 --- a/third_party/rust/ed25519_dalek/v2/BUILD.gn +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "ed25519_dalek" - epoch = "2" - crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/lib.rs" - sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/batch.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/constants.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/context.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/errors.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/hazmat.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signature.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/signing.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/src/verifying.rs", - ] - inputs = [] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "2.1.1" - cargo_pkg_authors = "isis lovecruft , Tony Arcieri , Michael Rosenberg " - cargo_pkg_name = "ed25519-dalek" - cargo_pkg_description = "Fast and efficient ed25519 EdDSA key generations, signing, and verification in pure Rust." - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ - "//brave/third_party/rust/curve25519_dalek/v4:lib", - "//brave/third_party/rust/ed25519/v2:lib", - "//brave/third_party/rust/rand_core/v0_6:lib", - "//brave/third_party/rust/serde/v1:lib", - "//brave/third_party/rust/sha2/v0_10:lib", - "//brave/third_party/rust/subtle/v2:lib", - "//brave/third_party/rust/zeroize/v1:lib", - ] - features = [ - "alloc", - "rand_core", - "std", - "zeroize", - ] -} diff --git a/third_party/rust/ed25519_dalek/v2/README.chromium b/third_party/rust/ed25519_dalek/v2/README.chromium deleted file mode 100644 index d285a496a6f4..000000000000 --- a/third_party/rust/ed25519_dalek/v2/README.chromium +++ /dev/null @@ -1,9 +0,0 @@ -Name: ed25519-dalek -URL: https://crates.io/crates/ed25519-dalek -Description: Fast and efficient ed25519 EdDSA key generations, signing, and verification in pure Rust. -Version: 2.1.1 -Security Critical: yes -Shipped: yes -License: BSD 3-Clause -License File: //brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-2.1.1/LICENSE -Revision: 4ac84dd0668b1d2e51654fcdffe4ae6a687bef00 diff --git a/third_party/rust/ed25519_dalek_bip32/v0_3/BUILD.gn b/third_party/rust/ed25519_dalek_bip32/v0_3/BUILD.gn deleted file mode 100644 index 51bacdfb596c..000000000000 --- a/third_party/rust/ed25519_dalek_bip32/v0_3/BUILD.gn +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "ed25519_dalek_bip32" - epoch = "0.3" - crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/src/lib.rs" - sources = [ "//brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/src/lib.rs" ] - inputs = [] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "0.3.0" - cargo_pkg_authors = "Julian Popescu " - cargo_pkg_name = "ed25519-dalek-bip32" - cargo_pkg_description = "Simplified ed25519 BIP32 derivations" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ - "//brave/third_party/rust/derivation_path/v0_2:lib", - "//brave/third_party/rust/ed25519_dalek/v2:lib", - "//brave/third_party/rust/hmac/v0_12:lib", - "//brave/third_party/rust/sha2/v0_10:lib", - ] - features = [ "std" ] -} diff --git a/third_party/rust/ed25519_dalek_bip32/v0_3/README.chromium b/third_party/rust/ed25519_dalek_bip32/v0_3/README.chromium deleted file mode 100644 index 303074e1653d..000000000000 --- a/third_party/rust/ed25519_dalek_bip32/v0_3/README.chromium +++ /dev/null @@ -1,9 +0,0 @@ -Name: ed25519-dalek-bip32 -URL: https://crates.io/crates/ed25519-dalek-bip32 -Description: Simplified ed25519 BIP32 derivations -Version: 0.3.0 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/ed25519-dalek-bip32-0.3.0/../../../../../common/licenses/Apache-2.0 -Revision: cfa4df6c621d99429d4357b6823fb48f8e4fe8ad diff --git a/third_party/rust/pkcs8/v0_10/BUILD.gn b/third_party/rust/pkcs8/v0_10/BUILD.gn deleted file mode 100644 index 72dd2f106315..000000000000 --- a/third_party/rust/pkcs8/v0_10/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "pkcs8" - epoch = "0.10" - crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/lib.rs" - sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/encrypted_private_key_info.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/error.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/private_key_info.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/traits.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/version.rs", - ] - inputs = [ "//brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/src/../README.md" ] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "0.10.2" - cargo_pkg_authors = "RustCrypto Developers" - cargo_pkg_name = "pkcs8" - cargo_pkg_description = "Pure Rust implementation of Public-Key Cryptography Standards (PKCS) #8: Private-Key Information Syntax Specification (RFC 5208), with additional support for PKCS#8v2 asymmetric key packages (RFC 5958)" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ - "//brave/third_party/rust/der/v0_7:lib", - "//brave/third_party/rust/spki/v0_7:lib", - ] - features = [ - "alloc", - "std", - ] -} diff --git a/third_party/rust/pkcs8/v0_10/README.chromium b/third_party/rust/pkcs8/v0_10/README.chromium deleted file mode 100644 index 57dcd379d1f9..000000000000 --- a/third_party/rust/pkcs8/v0_10/README.chromium +++ /dev/null @@ -1,12 +0,0 @@ -Name: pkcs8 -URL: https://crates.io/crates/pkcs8 -Description: Pure Rust implementation of Public-Key Cryptography Standards (PKCS) #8: -Private-Key Information Syntax Specification (RFC 5208), with additional -support for PKCS#8v2 asymmetric key packages (RFC 5958) - -Version: 0.10.2 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/pkcs8-0.10.2/LICENSE-APACHE -Revision: 7736dd21389b8820dfeb396e8c4c932de93d3ddf diff --git a/third_party/rust/signature/v2/BUILD.gn b/third_party/rust/signature/v2/BUILD.gn deleted file mode 100644 index 5f37b9fdbab2..000000000000 --- a/third_party/rust/signature/v2/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "signature" - epoch = "2" - crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/lib.rs" - sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/encoding.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/error.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/hazmat.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/keypair.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/prehash_signature.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/signer.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/verifier.rs", - ] - inputs = [ "//brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/src/../README.md" ] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "2.2.0" - cargo_pkg_authors = "RustCrypto Developers" - cargo_pkg_name = "signature" - cargo_pkg_description = - "Traits for cryptographic signature algorithms (e.g. ECDSA, Ed25519)" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ "//brave/third_party/rust/rand_core/v0_6:lib" ] - features = [ - "alloc", - "std", - ] -} diff --git a/third_party/rust/signature/v2/README.chromium b/third_party/rust/signature/v2/README.chromium deleted file mode 100644 index 7cf2894de601..000000000000 --- a/third_party/rust/signature/v2/README.chromium +++ /dev/null @@ -1,9 +0,0 @@ -Name: signature -URL: https://crates.io/crates/signature -Description: Traits for cryptographic signature algorithms (e.g. ECDSA, Ed25519) -Version: 2.2.0 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/signature-2.2.0/LICENSE-APACHE -Revision: 5adcd4819b380b4aaec2b57c6bf3f2239a109060 diff --git a/third_party/rust/spki/v0_7/BUILD.gn b/third_party/rust/spki/v0_7/BUILD.gn deleted file mode 100644 index 7ec52e57747e..000000000000 --- a/third_party/rust/spki/v0_7/BUILD.gn +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by -# tools/crates/gnrt. -# Do not edit! - -import("//build/rust/cargo_crate.gni") - -cargo_crate("lib") { - crate_name = "spki" - epoch = "0.7" - crate_type = "rlib" - crate_root = - "//brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/lib.rs" - sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/algorithm.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/error.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/fingerprint.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/spki.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/traits.rs", - ] - inputs = [ "//brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/src/../README.md" ] - - build_native_rust_unit_tests = false - edition = "2021" - cargo_pkg_version = "0.7.3" - cargo_pkg_authors = "RustCrypto Developers" - cargo_pkg_name = "spki" - cargo_pkg_description = "X.509 Subject Public Key Info (RFC5280) describing public keys as well as their associated AlgorithmIdentifiers (i.e. OIDs)" - library_configs -= [ "//build/config/compiler:chromium_code" ] - library_configs += [ "//build/config/compiler:no_chromium_code" ] - executable_configs -= [ "//build/config/compiler:chromium_code" ] - executable_configs += [ "//build/config/compiler:no_chromium_code" ] - proc_macro_configs -= [ "//build/config/compiler:chromium_code" ] - proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ - "//brave/third_party/rust/base64ct/v1:lib", - "//brave/third_party/rust/der/v0_7:lib", - ] - features = [ - "alloc", - "std", - ] -} diff --git a/third_party/rust/spki/v0_7/README.chromium b/third_party/rust/spki/v0_7/README.chromium deleted file mode 100644 index b94842271724..000000000000 --- a/third_party/rust/spki/v0_7/README.chromium +++ /dev/null @@ -1,11 +0,0 @@ -Name: spki -URL: https://crates.io/crates/spki -Description: X.509 Subject Public Key Info (RFC5280) describing public keys as well as their -associated AlgorithmIdentifiers (i.e. OIDs) - -Version: 0.7.3 -Security Critical: yes -Shipped: yes -License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/spki-0.7.3/LICENSE-APACHE -Revision: 15ea461dc3484d48710deed932e4d3d9052c1f9b From ee9e32cf820cf8ebdf7013e6e3c580468e1c96c7 Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Wed, 27 Nov 2024 16:01:26 +0700 Subject: [PATCH 3/5] fix ci --- .../brave_wallet/browser/internal/hd_key_ed25519.cc | 1 + .../brave_wallet/browser/internal/hd_key_ed25519.h | 10 +++++----- .../browser/internal/hd_key_ed25519_unittest.cc | 2 ++ components/brave_wallet/common/DEPS | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/brave_wallet/browser/internal/hd_key_ed25519.cc b/components/brave_wallet/browser/internal/hd_key_ed25519.cc index 475e161801c6..e2558b5e65c6 100644 --- a/components/brave_wallet/browser/internal/hd_key_ed25519.cc +++ b/components/brave_wallet/browser/internal/hd_key_ed25519.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_wallet/browser/internal/hd_key_ed25519.h" #include +#include #include "base/check.h" #include "base/containers/span.h" diff --git a/components/brave_wallet/browser/internal/hd_key_ed25519.h b/components/brave_wallet/browser/internal/hd_key_ed25519.h index c7f48dbed4c0..ae5992fba707 100644 --- a/components/brave_wallet/browser/internal/hd_key_ed25519.h +++ b/components/brave_wallet/browser/internal/hd_key_ed25519.h @@ -13,12 +13,12 @@ namespace brave_wallet { -constexpr size_t kEd25519SecretKeySize = 32; -constexpr size_t kEd25519PublicKeySize = 32; -constexpr size_t kEd25519KeypairSize = +inline constexpr size_t kEd25519SecretKeySize = 32; +inline constexpr size_t kEd25519PublicKeySize = 32; +inline constexpr size_t kEd25519KeypairSize = kEd25519SecretKeySize + kEd25519PublicKeySize; -constexpr size_t kEd25519ChainCodeSize = 32; -constexpr size_t kEd25519SignatureSize = 64; +inline constexpr size_t kEd25519ChainCodeSize = 32; +inline constexpr size_t kEd25519SignatureSize = 64; // This class implements basic EdDSA over ed25519 functionality of SLIP-0010 // spec with 32 bytes private key and only allows private key derivation with diff --git a/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc b/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc index ff2035200887..7d655a26b76a 100644 --- a/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc +++ b/components/brave_wallet/browser/internal/hd_key_ed25519_unittest.cc @@ -5,6 +5,8 @@ #include "brave/components/brave_wallet/browser/internal/hd_key_ed25519.h" +#include + #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "brave/components/brave_wallet/common/hex_utils.h" diff --git a/components/brave_wallet/common/DEPS b/components/brave_wallet/common/DEPS index 9a079c726293..9a396c433879 100644 --- a/components/brave_wallet/common/DEPS +++ b/components/brave_wallet/common/DEPS @@ -13,6 +13,7 @@ specific_include_rules = { ], "hash_utils\.cc": [ "+brave/third_party/bitcoin-core/src/src/crypto/ripemd160.h", + "+third_party/boringssl", ], "zcash_utils\.cc": [ "+brave/third_party/bitcoin-core/src/src/base58.h", From 766ec3a2acd159f924587a339856dd2501a55f3b Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Wed, 27 Nov 2024 20:59:48 +0700 Subject: [PATCH 4/5] fix ci --- components/brave_wallet/browser/BUILD.gn | 1 + components/brave_wallet/common/BUILD.gn | 1 + 2 files changed, 2 insertions(+) diff --git a/components/brave_wallet/browser/BUILD.gn b/components/brave_wallet/browser/BUILD.gn index d35b9f5379dd..064517c7d370 100644 --- a/components/brave_wallet/browser/BUILD.gn +++ b/components/brave_wallet/browser/BUILD.gn @@ -432,6 +432,7 @@ source_set("hd_keyring") { "//brave/components/brave_wallet/common:buildflags", "//brave/components/brave_wallet/common:common_constants", "//brave/components/brave_wallet/common:mojom", + "//brave/components/brave_wallet/rust:rust_lib", "//brave/components/filecoin/rs:rust_lib", "//crypto", ] diff --git a/components/brave_wallet/common/BUILD.gn b/components/brave_wallet/common/BUILD.gn index c03313270678..77ebce97ad4d 100644 --- a/components/brave_wallet/common/BUILD.gn +++ b/components/brave_wallet/common/BUILD.gn @@ -75,6 +75,7 @@ static_library("common") { ":generated_eth_requests", ":generated_json_rpc_requests", ":pref_names", + "//brave/components/brave_wallet/rust:rust_lib", "//brave/net/base:utils", "//brave/third_party/argon2", "//brave/third_party/bitcoin-core", From 1cd34846c47d9e783e0240f8ea85f1d31453211a Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Wed, 27 Nov 2024 22:24:43 +0700 Subject: [PATCH 5/5] fix ci --- components/brave_wallet/browser/internal/hd_key_utils.cc | 2 +- components/brave_wallet/browser/solana_keyring_unittest.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/brave_wallet/browser/internal/hd_key_utils.cc b/components/brave_wallet/browser/internal/hd_key_utils.cc index 04af08342922..1de62153bc6b 100644 --- a/components/brave_wallet/browser/internal/hd_key_utils.cc +++ b/components/brave_wallet/browser/internal/hd_key_utils.cc @@ -17,7 +17,7 @@ namespace brave_wallet { std::optional> ParseFullHDPath(std::string_view path) { auto entries = base::SplitStringPiece( path, "/", base::WhitespaceHandling::TRIM_WHITESPACE, - base::SplitResult::SPLIT_WANT_NONEMPTY); + base::SplitResult::SPLIT_WANT_ALL); if (entries.empty()) { return std::nullopt; diff --git a/components/brave_wallet/browser/solana_keyring_unittest.cc b/components/brave_wallet/browser/solana_keyring_unittest.cc index cf11f5484e17..e85c4887685b 100644 --- a/components/brave_wallet/browser/solana_keyring_unittest.cc +++ b/components/brave_wallet/browser/solana_keyring_unittest.cc @@ -107,7 +107,8 @@ TEST(SolanaKeyringUnitTest, ImportAccount) { private_key.clear(); ASSERT_TRUE(base::HexStringToBytes( - "bee602cc7dd4c1be27d8459892ab4e23f7a1d31ffde8cdd50542068ada52a201", + "bee602cc7dd4c1be27d8459892ab4e23f7a1d31ffde8cdd50542068ada52a201" + "b2d66b28055a98f8e4c19afeb026fd0c2f6755bf1830ad542d86d64b24da43c2", &private_key)); keyring.ImportAccount(private_key); EXPECT_EQ(keyring.GetImportedAccountsForTesting().size(), 2u);