diff --git a/components/gcm_driver/crypto/gcm_crypto_test_helpers.cc b/components/gcm_driver/crypto/gcm_crypto_test_helpers.cc index ff405bfdcfd7de..3b11cd3252c2bf 100644 --- a/components/gcm_driver/crypto/gcm_crypto_test_helpers.cc +++ b/components/gcm_driver/crypto/gcm_crypto_test_helpers.cc @@ -33,8 +33,7 @@ bool CreateEncryptedPayloadForTesting(const base::StringPiece& payload, std::string shared_secret; // Calculate the shared secret between the sender and its peer. - if (!ComputeSharedP256Secret(private_key, public_key_x509, peer_public_key, - &shared_secret)) { + if (!ComputeSharedP256Secret(private_key, peer_public_key, &shared_secret)) { return false; } diff --git a/components/gcm_driver/crypto/gcm_encryption_provider.cc b/components/gcm_driver/crypto/gcm_encryption_provider.cc index 6145a55d179887..770206e129cf21 100644 --- a/components/gcm_driver/crypto/gcm_encryption_provider.cc +++ b/components/gcm_driver/crypto/gcm_encryption_provider.cc @@ -265,8 +265,8 @@ void GCMEncryptionProvider::DecryptMessageWithKey( DCHECK_EQ(KeyPair::ECDH_P256, pair.type()); std::string shared_secret; - if (!ComputeSharedP256Secret(pair.private_key(), pair.public_key_x509(), - public_key, &shared_secret)) { + if (!ComputeSharedP256Secret(pair.private_key(), public_key, + &shared_secret)) { DLOG(ERROR) << "Unable to calculate the shared secret."; callback.Run(GCMDecryptionResult::INVALID_SHARED_SECRET, IncomingMessage()); return; diff --git a/components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc b/components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc index 3d18c61fbc2107..384dc76b43e240 100644 --- a/components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc +++ b/components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc @@ -489,8 +489,7 @@ void GCMEncryptionProviderTest::TestEncryptionRoundTrip( std::string shared_secret; ASSERT_TRUE(ComputeSharedP256Secret( - pair.private_key(), pair.public_key_x509(), server_pair.public_key(), - &shared_secret)); + pair.private_key(), server_pair.public_key(), &shared_secret)); IncomingMessage message; size_t record_size; diff --git a/components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc b/components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc index cfca8b16902ae2..5e9a7335e5987b 100644 --- a/components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc +++ b/components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc @@ -49,16 +49,6 @@ const unsigned char kCommonRecipientPublicKey[] = { static_assert(arraysize(kCommonRecipientPublicKey) == 65, "Raw P-256 public keys must be 65 bytes in size."); -const unsigned char kCommonRecipientPublicKeyX509[] = { - 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, - 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, - 0x42, 0x00, 0x04, 0x35, 0x02, 0x67, 0xB9, 0x10, 0x8F, 0x9B, 0xF1, 0x85, - 0xF5, 0x1B, 0xD7, 0xA4, 0xEF, 0xBD, 0x28, 0xB3, 0x11, 0x40, 0xBA, 0xD0, - 0xEE, 0xB2, 0x97, 0xDA, 0x6A, 0x93, 0x2D, 0x26, 0x45, 0xBD, 0xB2, 0x9A, - 0x9F, 0xB8, 0x19, 0xD8, 0x21, 0x6F, 0x66, 0xE3, 0xF6, 0x0B, 0x74, 0xB2, - 0x28, 0x38, 0xDC, 0xA7, 0x8A, 0x58, 0x0D, 0x56, 0x47, 0x3E, 0xD0, 0x5B, - 0x5C, 0x93, 0x4E, 0xB3, 0x89, 0x87, 0x64}; - const unsigned char kCommonRecipientPrivateKey[] = { 0x30, 0x81, 0xB0, 0x30, 0x1B, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x03, 0x30, 0x0D, 0x04, 0x08, 0xF3, 0xD6, 0x39, @@ -260,16 +250,8 @@ class GCMMessageCryptographerTestBase : public ::testing::Test { kCommonRecipientPrivateKey, kCommonRecipientPrivateKey + arraysize(kCommonRecipientPrivateKey)); - // TODO(peter): Remove the dependency on the x509 keying material when - // crbug.com/618025 has been resolved. - std::string recipient_public_key_x509( - kCommonRecipientPublicKeyX509, - kCommonRecipientPublicKeyX509 + - arraysize(kCommonRecipientPublicKeyX509)); - ASSERT_TRUE(ComputeSharedP256Secret( - recipient_private_key, recipient_public_key_x509, sender_public_key_, - &ecdh_shared_secret_)); + recipient_private_key, sender_public_key_, &ecdh_shared_secret_)); auth_secret_.assign(kCommonAuthSecret, kCommonAuthSecret + arraysize(kCommonAuthSecret)); @@ -707,28 +689,22 @@ TEST_F(GCMMessageCryptographerTestVectorTest, DecryptionVectorsDraft08) { class GCMMessageCryptographerReferenceTest : public ::testing::Test { protected: // Computes the shared secret between the sender and the receiver. The sender - // must have a key-pair containing a X.509 SubjectPublicKeyInfo block and a - // ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo block, whereas the receiver - // must have a public key in uncompressed EC point format. + // must have a ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo block, whereas + // the receiver must have a public key in uncompressed EC point format. void ComputeSharedSecret( const base::StringPiece& encoded_sender_private_key, - const base::StringPiece& encoded_sender_public_key_x509, const base::StringPiece& encoded_receiver_public_key, std::string* shared_secret) const { - std::string sender_private_key, sender_public_key_x509, receiver_public_key; + std::string sender_private_key, receiver_public_key; ASSERT_TRUE(base::Base64UrlDecode( encoded_sender_private_key, base::Base64UrlDecodePolicy::IGNORE_PADDING, &sender_private_key)); - ASSERT_TRUE(base::Base64UrlDecode( - encoded_sender_public_key_x509, - base::Base64UrlDecodePolicy::IGNORE_PADDING, &sender_public_key_x509)); ASSERT_TRUE(base::Base64UrlDecode( encoded_receiver_public_key, base::Base64UrlDecodePolicy::IGNORE_PADDING, &receiver_public_key)); - ASSERT_TRUE(ComputeSharedP256Secret( - sender_private_key, sender_public_key_x509, receiver_public_key, - shared_secret)); + ASSERT_TRUE(ComputeSharedP256Secret(sender_private_key, receiver_public_key, + shared_secret)); } }; @@ -751,9 +727,6 @@ TEST_F(GCMMessageCryptographerReferenceTest, ReferenceDraft03) { const char kSenderPublicKeyUncompressed[] = "BNoRDbb84JGm8g5Z5CFxurSqsXWJ11ItfXEWYVLE85Y7CYkDjXsIEc4aqxYaQ1G8BqkXCJ6D" "PpDrWtdWj_mugHU"; - const char kSenderPublicX509[] = - "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE2hENtvzgkabyDlnkIXG6tKqxdYnXUi19cRZh" - "UsTzljsJiQONewgRzhqrFhpDUbwGqRcInoM-kOta11aP-a6AdQ"; // The keying material used by the recipient to decrypt the |kCiphertext|. const char kRecipientPrivate[] = @@ -764,9 +737,6 @@ TEST_F(GCMMessageCryptographerReferenceTest, ReferenceDraft03) { const char kRecipientPublicKeyUncompressed[] = "BCEkBjzL8Z3C-oi2Q7oE5t2Np-p7osjGLg93qUP0wvqRT21EEWyf0cQDQcakQMqz4hQKYOQ3" "il2nNZct4HgAUQU"; - const char kRecipientPublicX509[] = - "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEISQGPMvxncL6iLZDugTm3Y2n6nuiyMYuD3ep" - "Q_TC-pFPbUQRbJ_RxANBxqRAyrPiFApg5DeKXac1ly3geABRBQ"; // The ciphertext and associated plaintext of the message. const char kCiphertext[] = "6nqAQUME8hNqw5J3kl8cpVVJylXKYqZOeseZG8UueKpA"; @@ -775,12 +745,11 @@ TEST_F(GCMMessageCryptographerReferenceTest, ReferenceDraft03) { std::string sender_shared_secret, receiver_shared_secret; // Compute the shared secrets between the sender and receiver's keys. - ASSERT_NO_FATAL_FAILURE(ComputeSharedSecret(kSenderPrivate, kSenderPublicX509, - kRecipientPublicKeyUncompressed, - &sender_shared_secret)); ASSERT_NO_FATAL_FAILURE(ComputeSharedSecret( - kRecipientPrivate, kRecipientPublicX509, kSenderPublicKeyUncompressed, - &receiver_shared_secret)); + kSenderPrivate, kRecipientPublicKeyUncompressed, &sender_shared_secret)); + ASSERT_NO_FATAL_FAILURE(ComputeSharedSecret(kRecipientPrivate, + kSenderPublicKeyUncompressed, + &receiver_shared_secret)); ASSERT_GT(sender_shared_secret.size(), 0u); ASSERT_EQ(sender_shared_secret, receiver_shared_secret); @@ -835,9 +804,6 @@ TEST_F(GCMMessageCryptographerReferenceTest, ReferenceDraft08) { "AyQzjG7jdSXooDx_yPXgwMskoNzKhBXIG0AZF7MBimdXFTg_wlv38empWRr_-x4fnQiIBKya" "pt6uBOfYVuE_nnhqudqvSxiiv6hikBvxS2zabgph8-vFPQG10uUv8xkAO6vPdtTABCUzCXQU" "p1QmuP471ZdaNAMuCPmxry-C"; - const char kSenderPublicX509[] = - "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE_jP0qw3qcZFNtVgj9ztUlI9BMG2SBzLbuaWa" - "UyhkgiAOWXp7e8JguhwieZhYCZLpOXMALzASooro8Gu7eOXsDw"; // The keying material used by the recipient to decrypt the |kCiphertext|. const char kRecipientPrivate[] = @@ -848,9 +814,6 @@ TEST_F(GCMMessageCryptographerReferenceTest, ReferenceDraft08) { const char kRecipientPublicKeyUncompressed[] = "BCVxsr7N_eNgVRqvHtD0zTZsEc6-VV-JvLexhqUzORcxaOzi6-AYWXvTBHm4bjyPjs7Vd8pZ" "GH6SRpkNtoIAiw4"; - const char kRecipientPublicX509[] = - "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEJXGyvs3942BVGq8e0PTNNmwRzr5VX4m8t7GG" - "pTM5FzFo7OLr4BhZe9MEebhuPI-OztV3ylkYfpJGmQ22ggCLDg"; // The plain text of the message, as well as the encrypted reference message. const char kPlaintext[] = "When I grow up, I want to be a watermelon"; @@ -876,22 +839,17 @@ TEST_F(GCMMessageCryptographerReferenceTest, ReferenceDraft08) { std::string sender_shared_secret, receiver_shared_secret; // Compute the shared secrets between the sender and receiver's keys. - ASSERT_NO_FATAL_FAILURE(ComputeSharedSecret(kSenderPrivate, kSenderPublicX509, - kRecipientPublicKeyUncompressed, - &sender_shared_secret)); + ASSERT_NO_FATAL_FAILURE(ComputeSharedSecret( + kSenderPrivate, kRecipientPublicKeyUncompressed, &sender_shared_secret)); // Compute the shared secret based on the sender's public key, which isn't a // constant but instead is included in the message's binary header. - std::string sender_private_key, sender_public_key_x509; + std::string sender_private_key; ASSERT_TRUE(base::Base64UrlDecode(kRecipientPrivate, base::Base64UrlDecodePolicy::IGNORE_PADDING, &sender_private_key)); - ASSERT_TRUE(base::Base64UrlDecode(kRecipientPublicX509, - base::Base64UrlDecodePolicy::IGNORE_PADDING, - &sender_public_key_x509)); - ASSERT_TRUE(ComputeSharedP256Secret(sender_private_key, - sender_public_key_x509, sender_public_key, + ASSERT_TRUE(ComputeSharedP256Secret(sender_private_key, sender_public_key, &receiver_shared_secret)); ASSERT_GT(sender_shared_secret.size(), 0u); diff --git a/components/gcm_driver/crypto/p256_key_util.cc b/components/gcm_driver/crypto/p256_key_util.cc index 18f927d27f56de..3d484130ac47c5 100644 --- a/components/gcm_driver/crypto/p256_key_util.cc +++ b/components/gcm_driver/crypto/p256_key_util.cc @@ -92,7 +92,6 @@ bool CreateP256KeyPair(std::string* out_private_key, } bool ComputeSharedP256Secret(const base::StringPiece& private_key, - const base::StringPiece& public_key_x509, const base::StringPiece& peer_public_key, std::string* out_shared_secret) { DCHECK(out_shared_secret); @@ -100,10 +99,7 @@ bool ComputeSharedP256Secret(const base::StringPiece& private_key, std::unique_ptr local_key_pair( crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( std::vector(private_key.data(), - private_key.data() + private_key.size()), - std::vector( - public_key_x509.data(), - public_key_x509.data() + public_key_x509.size()))); + private_key.data() + private_key.size()))); if (!local_key_pair) { DLOG(ERROR) << "Unable to create the local key pair."; diff --git a/components/gcm_driver/crypto/p256_key_util.h b/components/gcm_driver/crypto/p256_key_util.h index bf24adcf64a2f7..aa3bfe13a53240 100644 --- a/components/gcm_driver/crypto/p256_key_util.h +++ b/components/gcm_driver/crypto/p256_key_util.h @@ -28,13 +28,11 @@ bool CreateP256KeyPair(std::string* out_private_key, // whether the secret could be computed, and was written to the out argument. // // The |private_key| must be an ASN.1-encoded PKCS#8 EncryptedPrivateKeyInfo -// block together, where |public_key_x509| must be an X.509 SubjectPublicKeyInfo -// block. This is necessary for NSS to be able to import the |private_key|. +// block. This is legacy from the NSS implementation. // // The |peer_public_key| must be an octet string in uncompressed form per // SEC1 2.3.3. bool ComputeSharedP256Secret(const base::StringPiece& private_key, - const base::StringPiece& public_key_x509, const base::StringPiece& peer_public_key, std::string* out_shared_secret) WARN_UNUSED_RESULT; diff --git a/components/gcm_driver/crypto/p256_key_util_unittest.cc b/components/gcm_driver/crypto/p256_key_util_unittest.cc index 1b5908556c879a..6144a00c4f8d65 100644 --- a/components/gcm_driver/crypto/p256_key_util_unittest.cc +++ b/components/gcm_driver/crypto/p256_key_util_unittest.cc @@ -26,9 +26,6 @@ const char kBobPrivateKey[] = "1RglXKiPdy+Ue5eubZ3Xe/pz/5yQWvysXLaTT+/LeuAoq2gwKK2AINTWglIEMCmcveERa0gZDW" "avhYEYtEynNLVop4bHlii5DcUY1/e9DY5Dxh7b2dYdWI2Ev+529KughVKK8qFu12wn3cSSlfXh" "9Hb8Nh/4yP0jg6k5k="; -const char kBobPublicKeyX509[] = - "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEVVJqpW6OqkeXNhDBZjweZb+he+5Iyca7vwIYU3" - "IdDHup4xG3A1Ih03GQE6jBz+0g9x/Rf/J2tgEg2DWl2TxD/Q=="; const char kBobPublicKey[] = "BFVSaqVujqpHlzYQwWY8HmW/oXvuSMnGu78CGFNyHQx7qeMRtwNSIdNxkBOowc/tIPcf0X/ydr" "YBINg1pdk8Q/0="; @@ -38,9 +35,6 @@ const char kCarolPrivateKey[] = "J4KT/C32F6K3edQnZ2J750g6nMVtkoK9TF23UcEIVB0Lo7FG4T5WF03wjC4A+5FC/1mYzsWFHO" "6AugLhum5psqX3fq6UmgYoir9dJsI7Rmmn1JH8Gtw6KJHMncPi1lGriLZqzcrw+oULVf6dcnH1" "z9F39GuYob5+sY7ak="; -const char kCarolPublicKeyX509[] = - "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAETqNDkapziFRUvEXfP9zEpwJi+kYh/+JbV5BZDD" - "QKS9kmXvKz+ahuKVmpYNkDI0ZdYM1KkNMUxd4/hprQ1L9sEA=="; const char kCarolPublicKey[] = "BE6jQ5Gqc4hUVLxF3z/cxKcCYvpGIf/iW1eQWQw0CkvZJl7ys/mobilZqWDZAyNGXWDNSpDTFM" "XeP4aa0NS/bBA="; @@ -87,10 +81,10 @@ TEST(P256KeyUtilTest, SharedSecretCalculation) { ASSERT_NE(bob_private_key, alice_private_key); std::string bob_shared_secret, alice_shared_secret; - ASSERT_TRUE(ComputeSharedP256Secret(bob_private_key, bob_public_key_x509, - alice_public_key, &bob_shared_secret)); - ASSERT_TRUE(ComputeSharedP256Secret(alice_private_key, alice_public_key_x509, - bob_public_key, &alice_shared_secret)); + ASSERT_TRUE(ComputeSharedP256Secret(bob_private_key, alice_public_key, + &bob_shared_secret)); + ASSERT_TRUE(ComputeSharedP256Secret(alice_private_key, bob_public_key, + &alice_shared_secret)); EXPECT_GT(bob_shared_secret.size(), 0u); EXPECT_EQ(bob_shared_secret, alice_shared_secret); @@ -98,20 +92,17 @@ TEST(P256KeyUtilTest, SharedSecretCalculation) { std::string unused_shared_secret; // Empty and too short peer public values should be considered invalid. - ASSERT_FALSE(ComputeSharedP256Secret(bob_private_key, bob_public_key_x509, - "", &unused_shared_secret)); - ASSERT_FALSE(ComputeSharedP256Secret(bob_private_key, bob_public_key_x509, - bob_public_key.substr(1), - &unused_shared_secret)); - + ASSERT_FALSE( + ComputeSharedP256Secret(bob_private_key, "", &unused_shared_secret)); + ASSERT_FALSE(ComputeSharedP256Secret( + bob_private_key, bob_public_key.substr(1), &unused_shared_secret)); } TEST(P256KeyUtilTest, SharedSecretWithPreExistingKey) { - std::string bob_private_key, bob_public_key_x509, bob_public_key; + std::string bob_private_key, bob_public_key; std::string alice_private_key, alice_public_key_x509, alice_public_key; ASSERT_TRUE(base::Base64Decode(kBobPrivateKey, &bob_private_key)); - ASSERT_TRUE(base::Base64Decode(kBobPublicKeyX509, &bob_public_key_x509)); ASSERT_TRUE(base::Base64Decode(kBobPublicKey, &bob_public_key)); // First verify against a newly created, ephemeral key-pair. @@ -119,28 +110,27 @@ TEST(P256KeyUtilTest, SharedSecretWithPreExistingKey) { &alice_private_key, &alice_public_key_x509, &alice_public_key)); std::string bob_shared_secret, alice_shared_secret; - ASSERT_TRUE(ComputeSharedP256Secret(bob_private_key, bob_public_key_x509, - alice_public_key, &bob_shared_secret)); - ASSERT_TRUE(ComputeSharedP256Secret(alice_private_key, alice_public_key_x509, - bob_public_key, &alice_shared_secret)); + ASSERT_TRUE(ComputeSharedP256Secret(bob_private_key, alice_public_key, + &bob_shared_secret)); + ASSERT_TRUE(ComputeSharedP256Secret(alice_private_key, bob_public_key, + &alice_shared_secret)); EXPECT_GT(bob_shared_secret.size(), 0u); EXPECT_EQ(bob_shared_secret, alice_shared_secret); - std::string carol_private_key, carol_public_key_x509, carol_public_key; + std::string carol_private_key, carol_public_key; ASSERT_TRUE(base::Base64Decode(kCarolPrivateKey, &carol_private_key)); - ASSERT_TRUE(base::Base64Decode(kCarolPublicKeyX509, &carol_public_key_x509)); ASSERT_TRUE(base::Base64Decode(kCarolPublicKey, &carol_public_key)); bob_shared_secret.clear(); std::string carol_shared_secret; // Then verify against another stored key-pair and shared secret. - ASSERT_TRUE(ComputeSharedP256Secret(bob_private_key, bob_public_key_x509, - carol_public_key, &bob_shared_secret)); - ASSERT_TRUE(ComputeSharedP256Secret(carol_private_key, carol_public_key_x509, - bob_public_key, &carol_shared_secret)); + ASSERT_TRUE(ComputeSharedP256Secret(bob_private_key, carol_public_key, + &bob_shared_secret)); + ASSERT_TRUE(ComputeSharedP256Secret(carol_private_key, bob_public_key, + &carol_shared_secret)); EXPECT_GT(carol_shared_secret.size(), 0u); EXPECT_EQ(carol_shared_secret, bob_shared_secret); diff --git a/crypto/ec_private_key.cc b/crypto/ec_private_key.cc index 75b86c0c0577e6..4297716f6ec8fb 100644 --- a/crypto/ec_private_key.cc +++ b/crypto/ec_private_key.cc @@ -59,10 +59,7 @@ std::unique_ptr ECPrivateKey::CreateFromPrivateKeyInfo( // static std::unique_ptr ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( - const std::vector& encrypted_private_key_info, - const std::vector& subject_public_key_info) { - // TODO(davidben): The |subject_public_key_info| parameter is a remnant of - // the NSS implementation. Remove it. + const std::vector& encrypted_private_key_info) { OpenSSLErrStackTracer err_tracer(FROM_HERE); CBS cbs; diff --git a/crypto/ec_private_key.h b/crypto/ec_private_key.h index 432019be5d7eb9..c087d238f9dc01 100644 --- a/crypto/ec_private_key.h +++ b/crypto/ec_private_key.h @@ -47,8 +47,7 @@ class CRYPTO_EXPORT ECPrivateKey { // This function is deprecated. Use CreateFromPrivateKeyInfo for new code. // See https://crbug.com/603319. static std::unique_ptr CreateFromEncryptedPrivateKeyInfo( - const std::vector& encrypted_private_key_info, - const std::vector& subject_public_key_info); + const std::vector& encrypted_private_key_info); // Returns a copy of the object. std::unique_ptr Copy() const; diff --git a/crypto/ec_private_key_unittest.cc b/crypto/ec_private_key_unittest.cc index 534564703df040..00aa8a8d218a4b 100644 --- a/crypto/ec_private_key_unittest.cc +++ b/crypto/ec_private_key_unittest.cc @@ -54,11 +54,9 @@ TEST(ECPrivateKeyUnitTest, InitRandomTest) { // Re-import as an EncryptedPrivateKeyInfo with kPassword1. std::vector encrypted_privkey; - std::vector pubkey; EXPECT_TRUE(keypair->ExportEncryptedPrivateKey(&encrypted_privkey)); - EXPECT_TRUE(keypair->ExportPublicKey(&pubkey)); keypair_copy = crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( - encrypted_privkey, pubkey); + encrypted_privkey); ASSERT_TRUE(keypair_copy); ExpectKeysEqual(keypair.get(), keypair_copy.get()); } @@ -207,22 +205,10 @@ TEST(ECPrivateKeyUnitTest, LoadNSSKeyTest) { 0x9f, 0x41, 0x83, 0x72, 0xf2, 0x0a, 0xe9, 0xe1, 0x2c, 0x12, 0xb0, 0xb0, 0x0a, 0xb2, 0x1d, 0xca, 0x15, 0xb2, 0xca, }; - static const uint8_t kNSSPublicKey[] = { - 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, - 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, - 0x42, 0x00, 0x04, 0x85, 0x92, 0x9e, 0x95, 0x5c, 0x6b, 0x9e, 0xd6, 0x1e, - 0xb8, 0x64, 0xea, 0xc2, 0xb3, 0xef, 0x18, 0xed, 0x3a, 0x5e, 0xc4, 0x5c, - 0x15, 0x37, 0x6a, 0xe9, 0xaa, 0x0b, 0x34, 0x03, 0xfd, 0xca, 0x83, 0x0f, - 0xd7, 0x5c, 0x5d, 0xc5, 0x53, 0x6e, 0xe5, 0xa9, 0x33, 0xd5, 0xcc, 0xab, - 0x53, 0x78, 0xdd, 0xd6, 0x12, 0x3a, 0x5e, 0xeb, 0xbf, 0xdf, 0x16, 0xd3, - 0x2c, 0x3b, 0xe8, 0xdb, 0x19, 0xfc, 0x5e, - }; std::unique_ptr keypair_nss( crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( - std::vector(std::begin(kNSSKey), std::end(kNSSKey)), - std::vector(std::begin(kNSSPublicKey), - std::end(kNSSPublicKey)))); + std::vector(std::begin(kNSSKey), std::end(kNSSKey)))); EXPECT_TRUE(keypair_nss); } @@ -266,9 +252,8 @@ TEST(ECPrivateKeyUnitTest, LoadOpenSSLKeyTest) { std::unique_ptr keypair_openssl( crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( - std::vector(std::begin(kOpenSSLKey), std::end(kOpenSSLKey)), - std::vector(std::begin(kOpenSSLPublicKey), - std::end(kOpenSSLPublicKey)))); + std::vector(std::begin(kOpenSSLKey), + std::end(kOpenSSLKey)))); EXPECT_TRUE(keypair_openssl); @@ -327,42 +312,11 @@ TEST(ECPrivateKeyUnitTest, LoadOldOpenSSLKeyTest) { 0x35, 0xc5, 0xe3, 0xc5, 0xaa, 0x15, 0x3c, 0xac, 0x30, 0xbc, 0x45, 0x16, 0xed, }; - static const uint8_t kOpenSSLPublicKey[] = { - 0x30, 0x82, 0x01, 0x4b, 0x30, 0x82, 0x01, 0x03, 0x06, 0x07, 0x2a, 0x86, - 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30, 0x81, 0xf7, 0x02, 0x01, 0x01, 0x30, - 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, - 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x30, 0x5b, 0x04, - 0x20, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x04, 0x20, 0x5a, - 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, 0xb3, 0xeb, 0xbd, 0x55, 0x76, - 0x98, 0x86, 0xbc, 0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53, 0xb0, 0xf6, 0x3b, - 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b, 0x03, 0x15, 0x00, 0xc4, 0x9d, - 0x36, 0x08, 0x86, 0xe7, 0x04, 0x93, 0x6a, 0x66, 0x78, 0xe1, 0x13, 0x9d, - 0x26, 0xb7, 0x81, 0x9f, 0x7e, 0x90, 0x04, 0x41, 0x04, 0x6b, 0x17, 0xd1, - 0xf2, 0xe1, 0x2c, 0x42, 0x47, 0xf8, 0xbc, 0xe6, 0xe5, 0x63, 0xa4, 0x40, - 0xf2, 0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb, 0x33, 0xa0, 0xf4, 0xa1, 0x39, - 0x45, 0xd8, 0x98, 0xc2, 0x96, 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, - 0x9b, 0x8e, 0xe7, 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16, 0x2b, 0xce, 0x33, - 0x57, 0x6b, 0x31, 0x5e, 0xce, 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, - 0xf5, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbc, 0xe6, 0xfa, 0xad, - 0xa7, 0x17, 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51, - 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04, 0xde, 0x09, 0x08, 0x07, 0x03, - 0x2e, 0x8f, 0x37, 0x9a, 0xd5, 0xad, 0xe5, 0xc6, 0x9d, 0xd4, 0x63, 0xc7, - 0x4a, 0xe7, 0x20, 0xcb, 0x90, 0xa0, 0x1f, 0x18, 0x18, 0x72, 0xb5, 0x21, - 0x88, 0x38, 0xc0, 0xdb, 0xba, 0xf6, 0x99, 0xd8, 0xa5, 0x3b, 0x83, 0xe9, - 0xe3, 0xd5, 0x61, 0x99, 0x73, 0x42, 0xc6, 0x6c, 0xe8, 0x0a, 0x95, 0x40, - 0x41, 0x3b, 0x0d, 0x10, 0xa7, 0x4a, 0x93, 0xdb, 0x5a, 0xe7, 0xec, - }; std::unique_ptr keypair_openssl( crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( - std::vector(std::begin(kOpenSSLKey), std::end(kOpenSSLKey)), - std::vector(std::begin(kOpenSSLPublicKey), - std::end(kOpenSSLPublicKey)))); + std::vector(std::begin(kOpenSSLKey), + std::end(kOpenSSLKey)))); EXPECT_TRUE(keypair_openssl); } diff --git a/net/extras/sqlite/sqlite_channel_id_store_unittest.cc b/net/extras/sqlite/sqlite_channel_id_store_unittest.cc index 68c1aadb45bbfe..fa940a1396bbba 100644 --- a/net/extras/sqlite/sqlite_channel_id_store_unittest.cc +++ b/net/extras/sqlite/sqlite_channel_id_store_unittest.cc @@ -15,7 +15,6 @@ #include "base/strings/string_number_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "crypto/ec_private_key.h" -#include "net/cert/asn1_util.h" #include "net/ssl/channel_id_service.h" #include "net/ssl/ssl_client_cert_type.h" #include "net/test/cert_test_util.h"