diff options
author | peter <peter@chromium.org> | 2015-11-16 07:21:38 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-16 15:22:34 +0000 |
commit | 471cd60ba3695e430ca3bb42baabe35485a84834 (patch) | |
tree | 3c4f1d7c6d1fbc60c6b45351aaff39241a5d1233 /components/gcm_driver | |
parent | 4e96b1de65143bac77420ed8610b5df8a7237cd0 (diff) | |
download | chromium_src-471cd60ba3695e430ca3bb42baabe35485a84834.zip chromium_src-471cd60ba3695e430ca3bb42baabe35485a84834.tar.gz chromium_src-471cd60ba3695e430ca3bb42baabe35485a84834.tar.bz2 |
Rename Encryption-Key to Crypto-Key, "key" parameter to "aesgcm128".
Mechanical renames to align us with draft-thomson-http-encryption-02.
Beyond -02, this CL also integrates the rename from the Encryption-Key
header to Crypto-Key[1], and the "key" parameter to "aesgcm128"[2].
Note that the algorithmic changes of [1] have not been implemented yet.
[1] https://goo.gl/f9ktM0
[2] https://goo.gl/hX9g3C
BUG=486040
Review URL: https://codereview.chromium.org/1446163002
Cr-Commit-Position: refs/heads/master@{#359840}
Diffstat (limited to 'components/gcm_driver')
6 files changed, 109 insertions, 111 deletions
diff --git a/components/gcm_driver/crypto/encryption_header_parsers.cc b/components/gcm_driver/crypto/encryption_header_parsers.cc index 20061c2..ccfae9f 100644 --- a/components/gcm_driver/crypto/encryption_header_parsers.cc +++ b/components/gcm_driver/crypto/encryption_header_parsers.cc @@ -15,7 +15,7 @@ namespace gcm { namespace { // The default record size in bytes, as defined in section two of -// https://tools.ietf.org/html/draft-thomson-http-encryption-01. +// https://tools.ietf.org/html/draft-thomson-http-encryption-02. const uint64_t kDefaultRecordSizeBytes = 4096; // Decodes the string between |begin| and |end| using base64url, and writes the @@ -63,7 +63,7 @@ bool RecordSizeToInt(const std::string::const_iterator& begin, // This implementation applies the parameters defined in section 3.1 of the // HTTP encryption encoding document: // -// https://tools.ietf.org/html/draft-thomson-http-encryption-01#section-3.1 +// https://tools.ietf.org/html/draft-thomson-http-encryption-02#section-3.1 // // This means that the three supported parameters are: // @@ -103,24 +103,24 @@ bool ParseEncryptionHeaderValuesImpl(std::string::const_iterator input_begin, } // Parses the string between |input_begin| and |input_end| according to the -// extended ABNF syntax for the Encryption-Key HTTP header, per the "parameter" -// rule from RFC 7231 (https://tools.ietf.org/html/rfc7231). +// extended ABNF syntax for the Crypto-Key HTTP header, per the "parameter" rule +// from RFC 7231 (https://tools.ietf.org/html/rfc7231). // // encryption_params = [ parameter *( ";" parameter ) ] // // This implementation applies the parameters defined in section 4 of the // HTTP encryption encoding document: // -//https://tools.ietf.org/html/draft-thomson-http-encryption-01#section-4 +//https://tools.ietf.org/html/draft-thomson-http-encryption-02#section-4 // // This means that the three supported parameters are: // // [ "keyid" "=" string ] -// [ ";" "key" "=" base64url ] +// [ ";" "aesgcm128" "=" base64url ] // [ ";" "dh" "=" base64url ] -bool ParseEncryptionKeyHeaderValuesImpl(std::string::const_iterator input_begin, - std::string::const_iterator input_end, - EncryptionKeyHeaderValues* values) { +bool ParseCryptoKeyHeaderValuesImpl(std::string::const_iterator input_begin, + std::string::const_iterator input_end, + CryptoKeyHeaderValues* values) { net::HttpUtil::NameValuePairsIterator name_value_pairs( input_begin, input_end, ';', net::HttpUtil::NameValuePairsIterator::VALUES_NOT_OPTIONAL); @@ -132,9 +132,10 @@ bool ParseEncryptionKeyHeaderValuesImpl(std::string::const_iterator input_begin, if (base::LowerCaseEqualsASCII(name, "keyid")) { values->keyid.assign(name_value_pairs.value_begin(), name_value_pairs.value_end()); - } else if (base::LowerCaseEqualsASCII(name, "key")) { + } else if (base::LowerCaseEqualsASCII(name, "aesgcm128")) { if (!ValueToDecodedString(name_value_pairs.value_begin(), - name_value_pairs.value_end(), &values->key)) { + name_value_pairs.value_end(), + &values->aesgcm128)) { return false; } } else if (base::LowerCaseEqualsASCII(name, "dh")) { @@ -176,18 +177,18 @@ bool ParseEncryptionHeader(const std::string& input, return true; } -bool ParseEncryptionKeyHeader(const std::string& input, - std::vector<EncryptionKeyHeaderValues>* values) { +bool ParseCryptoKeyHeader(const std::string& input, + std::vector<CryptoKeyHeaderValues>* values) { DCHECK(values); - std::vector<EncryptionKeyHeaderValues> candidate_values; + std::vector<CryptoKeyHeaderValues> candidate_values; net::HttpUtil::ValuesIterator value_iterator(input.begin(), input.end(), ','); while (value_iterator.GetNext()) { - EncryptionKeyHeaderValues candidate_value; - if (!ParseEncryptionKeyHeaderValuesImpl(value_iterator.value_begin(), - value_iterator.value_end(), - &candidate_value)) { + CryptoKeyHeaderValues candidate_value; + if (!ParseCryptoKeyHeaderValuesImpl(value_iterator.value_begin(), + value_iterator.value_end(), + &candidate_value)) { return false; } diff --git a/components/gcm_driver/crypto/encryption_header_parsers.h b/components/gcm_driver/crypto/encryption_header_parsers.h index 4bf7713..79fe7d2 100644 --- a/components/gcm_driver/crypto/encryption_header_parsers.h +++ b/components/gcm_driver/crypto/encryption_header_parsers.h @@ -22,7 +22,7 @@ struct EncryptionHeaderValues { // Parses |input| following the syntax of the Encryption HTTP header. The parsed // values will be stored in the |*values| argument. // -// https://tools.ietf.org/html/draft-thomson-http-encryption-01#section-3 +// https://tools.ietf.org/html/draft-thomson-http-encryption-02#section-3 // // This header follows the #list syntax from the extended ABNF syntax // defined in section 1.2 of RFC 7230: @@ -35,18 +35,18 @@ struct EncryptionHeaderValues { bool ParseEncryptionHeader(const std::string& input, std::vector<EncryptionHeaderValues>* values); -// Structure representing the parsed values from the Encryption-Key HTTP header. -// |key| and |dh| are stored after having been base64url decoded. -struct EncryptionKeyHeaderValues { +// Structure representing the parsed values from the Crypto-Key HTTP header. +// |aesgcm128| and |dh| are stored after having been base64url decoded. +struct CryptoKeyHeaderValues { std::string keyid; - std::string key; + std::string aesgcm128; std::string dh; }; -// Parses |input| following the syntax of the Encryption-Key HTTP header. The -// parsed values will be stored in the |*values| argument. +// Parses |input| following the syntax of the Crypto-Key HTTP header. The parsed +// values will be stored in the |*values| argument. // -// https://tools.ietf.org/html/draft-thomson-http-encryption-01#section-4 +// https://tools.ietf.org/html/draft-thomson-http-encryption-02#section-4 // // This header follows the #list syntax from the extended ABNF syntax // defined in section 1.2 of RFC 7230: @@ -56,8 +56,8 @@ struct EncryptionKeyHeaderValues { // Returns whether the |input| could be successfully parsed, and the resulting // values are now available in the |*values| argument. Does not modify |*values| // unless parsing was successful. -bool ParseEncryptionKeyHeader(const std::string& input, - std::vector<EncryptionKeyHeaderValues>* values); +bool ParseCryptoKeyHeader(const std::string& input, + std::vector<CryptoKeyHeaderValues>* values); } // namespace gcm diff --git a/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc b/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc index 5fe00ba..c8a1e0b 100644 --- a/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc +++ b/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc @@ -129,27 +129,28 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidEncryptionHeaders) { } } -TEST(EncryptionHeaderParsersTest, ParseValidEncryptionKeyHeaders) { +TEST(EncryptionHeaderParsersTest, ParseValidCryptoKeyHeaders) { struct { const char* const header; const char* const parsed_keyid; - const char* const parsed_key; + const char* const parsed_aesgcm128; const char* const parsed_dh; } expected_results[] = { - { "keyid=foo;key=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz", + { "keyid=foo;aesgcm128=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz", "foo", "sixteencoolbytes", "twelvecoolbytes" }, - { "keyid=foo; key=c2l4dGVlbmNvb2xieXRlcw; dh=dHdlbHZlY29vbGJ5dGVz", + { "keyid=foo; aesgcm128=c2l4dGVlbmNvb2xieXRlcw; dh=dHdlbHZlY29vbGJ5dGVz", "foo", "sixteencoolbytes", "twelvecoolbytes" }, - { "keyid = foo ; key = c2l4dGVlbmNvb2xieXRlcw ; dh = dHdlbHZlY29vbGJ5dGVz ", + { "keyid = foo ; aesgcm128 = c2l4dGVlbmNvb2xieXRlcw ; dh = dHdlbHZlY29vbGJ5" + "dGVz ", "foo", "sixteencoolbytes", "twelvecoolbytes" }, - { "KEYID=foo;KEY=c2l4dGVlbmNvb2xieXRlcw;DH=dHdlbHZlY29vbGJ5dGVz", + { "KEYID=foo;AESGCM128=c2l4dGVlbmNvb2xieXRlcw;DH=dHdlbHZlY29vbGJ5dGVz", "foo", "sixteencoolbytes", "twelvecoolbytes" }, { "keyid=foo", "foo", "", "" }, - { "key=c2l4dGVlbmNvb2xieXRlcw", "", "sixteencoolbytes", "" }, - { "key=\"c2l4dGVlbmNvb2xieXRlcw\"", "", "sixteencoolbytes", "" }, - { "key='c2l4dGVlbmNvb2xieXRlcw'", "", "sixteencoolbytes", "" }, + { "aesgcm128=c2l4dGVlbmNvb2xieXRlcw", "", "sixteencoolbytes", "" }, + { "aesgcm128=\"c2l4dGVlbmNvb2xieXRlcw\"", "", "sixteencoolbytes", "" }, + { "aesgcm128='c2l4dGVlbmNvb2xieXRlcw'", "", "sixteencoolbytes", "" }, { "dh=dHdlbHZlY29vbGJ5dGVz", "", "", "twelvecoolbytes" }, - { "keyid=foo;someothervalue=bar;key=dHdlbHZlY29vbGJ5dGVz", + { "keyid=foo;someothervalue=bar;aesgcm128=dHdlbHZlY29vbGJ5dGVz", "foo", "twelvecoolbytes", "" }, { "keyid=foo;keyid=bar", "bar", "", "" }, }; @@ -157,38 +158,38 @@ TEST(EncryptionHeaderParsersTest, ParseValidEncryptionKeyHeaders) { for (size_t i = 0; i < arraysize(expected_results); i++) { SCOPED_TRACE(i); - std::vector<EncryptionKeyHeaderValues> values; - ASSERT_TRUE(ParseEncryptionKeyHeader(expected_results[i].header, &values)); + std::vector<CryptoKeyHeaderValues> values; + ASSERT_TRUE(ParseCryptoKeyHeader(expected_results[i].header, &values)); ASSERT_EQ(1u, values.size()); EXPECT_EQ(expected_results[i].parsed_keyid, values[0].keyid); - EXPECT_EQ(expected_results[i].parsed_key, values[0].key); + EXPECT_EQ(expected_results[i].parsed_aesgcm128, values[0].aesgcm128); EXPECT_EQ(expected_results[i].parsed_dh, values[0].dh); } } -TEST(EncryptionHeaderParsersTest, ParseValidMultiValueEncryptionKeyHeaders) { +TEST(EncryptionHeaderParsersTest, ParseValidMultiValueCryptoKeyHeaders) { const size_t kNumberOfValues = 2u; struct { const char* const header; struct { const char* const keyid; - const char* const key; + const char* const aesgcm128; const char* const dh; } parsed_values[kNumberOfValues]; } expected_results[] = { - { "keyid=foo;key=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz,keyid=bar;" - "key=dHdlbHZlY29vbGJ5dGVz;dh=c2l4dGVlbmNvb2xieXRlcw", + { "keyid=foo;aesgcm128=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz," + "keyid=bar;aesgcm128=dHdlbHZlY29vbGJ5dGVz;dh=c2l4dGVlbmNvb2xieXRlcw", { { "foo", "sixteencoolbytes", "twelvecoolbytes" }, { "bar", "twelvecoolbytes", "sixteencoolbytes" } } }, - { "keyid=foo,key=c2l4dGVlbmNvb2xieXRlcw", + { "keyid=foo,aesgcm128=c2l4dGVlbmNvb2xieXRlcw", { { "foo", "", "" }, { "", "sixteencoolbytes", "" } } }, { "keyid=foo,keyid=bar;dh=dHdlbHZlY29vbGJ5dGVz", { { "foo", "", "" }, { "bar", "", "twelvecoolbytes" } } }, - { "keyid=\"foo,keyid=bar\",key=c2l4dGVlbmNvb2xieXRlcw", + { "keyid=\"foo,keyid=bar\",aesgcm128=c2l4dGVlbmNvb2xieXRlcw", { { "foo,keyid=bar", "", "" }, { "", "sixteencoolbytes", "" } } }, }; @@ -196,28 +197,29 @@ TEST(EncryptionHeaderParsersTest, ParseValidMultiValueEncryptionKeyHeaders) { for (size_t i = 0; i < arraysize(expected_results); i++) { SCOPED_TRACE(i); - std::vector<EncryptionKeyHeaderValues> values; - ASSERT_TRUE(ParseEncryptionKeyHeader(expected_results[i].header, &values)); + std::vector<CryptoKeyHeaderValues> values; + ASSERT_TRUE(ParseCryptoKeyHeader(expected_results[i].header, &values)); ASSERT_EQ(kNumberOfValues, values.size()); for (size_t j = 0; j < kNumberOfValues; ++j) { EXPECT_EQ(expected_results[i].parsed_values[j].keyid, values[j].keyid); - EXPECT_EQ(expected_results[i].parsed_values[j].key, values[j].key); + EXPECT_EQ(expected_results[i].parsed_values[j].aesgcm128, + values[j].aesgcm128); EXPECT_EQ(expected_results[i].parsed_values[j].dh, values[j].dh); } } } -TEST(EncryptionHeaderParsersTest, ParseInvalidEncryptionKeyHeaders) { +TEST(EncryptionHeaderParsersTest, ParseInvalidCryptoKeyHeaders) { const char* const expected_failures[] = { "keyid", "keyid=", "keyid=foo,keyid", "keyid=foo;novaluekey", - "key", - "key=", - "key=123$xyz", - "key=foobar,key=123$xyz", + "aesgcm128", + "aesgcm128=", + "aesgcm128=123$xyz", + "aesgcm128=foobar,aesgcm128=123$xyz", "dh", "dh=", "dh=YmV/2ZXJ-sMDA", @@ -228,8 +230,8 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidEncryptionKeyHeaders) { for (size_t i = 0; i < arraysize(expected_failures); i++) { SCOPED_TRACE(i); - std::vector<EncryptionKeyHeaderValues> values; - EXPECT_FALSE(ParseEncryptionKeyHeader(expected_failures[i], &values)); + std::vector<CryptoKeyHeaderValues> values; + EXPECT_FALSE(ParseCryptoKeyHeader(expected_failures[i], &values)); EXPECT_EQ(0u, values.size()); } } @@ -240,11 +242,11 @@ TEST(EncryptionHeaderParsersTest, SixValueHeader) { std::vector<EncryptionHeaderValues> encryption_values; ASSERT_TRUE(ParseEncryptionHeader(header, &encryption_values)); - std::vector<EncryptionKeyHeaderValues> encryption_key_values; - ASSERT_TRUE(ParseEncryptionKeyHeader(header, &encryption_key_values)); + std::vector<CryptoKeyHeaderValues> crypto_key_values; + ASSERT_TRUE(ParseCryptoKeyHeader(header, &crypto_key_values)); ASSERT_EQ(6u, encryption_values.size()); - ASSERT_EQ(6u, encryption_key_values.size()); + ASSERT_EQ(6u, crypto_key_values.size()); for (size_t i = 0; i < encryption_values.size(); i++) { SCOPED_TRACE(i); @@ -252,7 +254,7 @@ TEST(EncryptionHeaderParsersTest, SixValueHeader) { const std::string value = base::IntToString(i); EXPECT_EQ(value, encryption_values[i].keyid); - EXPECT_EQ(value, encryption_key_values[i].keyid); + EXPECT_EQ(value, crypto_key_values[i].keyid); } } @@ -272,20 +274,20 @@ TEST(EncryptionHeaderParsersTest, InvalidHeadersDoNotModifyOutput) { EXPECT_EQ("somesalt", encryption_values[0].salt); EXPECT_EQ(42u, encryption_values[0].rs); - EncryptionKeyHeaderValues encryption_key_value; - encryption_key_value.keyid = "myotherkeyid"; - encryption_key_value.key = "akey"; - encryption_key_value.dh = "yourdh"; + CryptoKeyHeaderValues crypto_key_value; + crypto_key_value.keyid = "myotherkeyid"; + crypto_key_value.aesgcm128 = "akey"; + crypto_key_value.dh = "yourdh"; - std::vector<EncryptionKeyHeaderValues> encryption_key_values; - encryption_key_values.push_back(encryption_key_value); + std::vector<CryptoKeyHeaderValues> crypto_key_values; + crypto_key_values.push_back(crypto_key_value); - ASSERT_FALSE(ParseEncryptionKeyHeader("key=$$$", &encryption_key_values)); - ASSERT_EQ(1u, encryption_key_values.size()); + ASSERT_FALSE(ParseCryptoKeyHeader("aesgcm128=$$$", &crypto_key_values)); + ASSERT_EQ(1u, crypto_key_values.size()); - EXPECT_EQ("myotherkeyid", encryption_key_values[0].keyid); - EXPECT_EQ("akey", encryption_key_values[0].key); - EXPECT_EQ("yourdh", encryption_key_values[0].dh); + EXPECT_EQ("myotherkeyid", crypto_key_values[0].keyid); + EXPECT_EQ("akey", crypto_key_values[0].aesgcm128); + EXPECT_EQ("yourdh", crypto_key_values[0].dh); } } // namespace diff --git a/components/gcm_driver/crypto/gcm_encryption_provider.cc b/components/gcm_driver/crypto/gcm_encryption_provider.cc index 486ba16..5ed56e4 100644 --- a/components/gcm_driver/crypto/gcm_encryption_provider.cc +++ b/components/gcm_driver/crypto/gcm_encryption_provider.cc @@ -21,7 +21,7 @@ namespace gcm { namespace { const char kEncryptionProperty[] = "encryption"; -const char kEncryptionKeyProperty[] = "encryption_key"; +const char kCryptoKeyProperty[] = "crypto_key"; // Directory in the GCM Store in which the encryption database will be stored. const base::FilePath::CharType kEncryptionDirectoryName[] = @@ -62,15 +62,12 @@ void GCMEncryptionProvider::GetPublicKey(const std::string& app_id, bool GCMEncryptionProvider::IsEncryptedMessage(const IncomingMessage& message) const { - // The Web Push protocol requires the encryption and encryption_key properties - // to be set, and the raw_data field to be populated with the payload. + // The Web Push protocol requires the encryption and crypto_key properties to + // be set, and the raw_data field to be populated with the payload. if (message.data.find(kEncryptionProperty) == message.data.end() || - message.data.find(kEncryptionKeyProperty) == message.data.end()) + message.data.find(kCryptoKeyProperty) == message.data.end()) return false; - // TODO(peter): Support decrypting messages that were sent using the existing - // GCM protocol, as opposed to the Web Push protocol. - return message.raw_data.size() > 0; } @@ -82,11 +79,11 @@ void GCMEncryptionProvider::DecryptMessage( DCHECK(key_store_); const auto& encryption_header = message.data.find(kEncryptionProperty); - const auto& encryption_key_header = message.data.find(kEncryptionKeyProperty); + const auto& crypto_key_header = message.data.find(kCryptoKeyProperty); // Callers are expected to call IsEncryptedMessage() prior to this method. DCHECK(encryption_header != message.data.end()); - DCHECK(encryption_key_header != message.data.end()); + DCHECK(crypto_key_header != message.data.end()); std::vector<EncryptionHeaderValues> encryption_header_values; if (!ParseEncryptionHeader(encryption_header->second, @@ -104,18 +101,18 @@ void GCMEncryptionProvider::DecryptMessage( return; } - std::vector<EncryptionKeyHeaderValues> encryption_key_header_values; - if (!ParseEncryptionKeyHeader(encryption_key_header->second, - &encryption_key_header_values)) { - DLOG(ERROR) << "Unable to parse the value of the Encryption-Key header"; - failure_callback.Run(DECRYPTION_FAILURE_INVALID_ENCRYPTION_KEY_HEADER); + std::vector<CryptoKeyHeaderValues> crypto_key_header_values; + if (!ParseCryptoKeyHeader(crypto_key_header->second, + &crypto_key_header_values)) { + DLOG(ERROR) << "Unable to parse the value of the Crypto-Key header"; + failure_callback.Run(DECRYPTION_FAILURE_INVALID_CRYPTO_KEY_HEADER); return; } - if (encryption_key_header_values.size() != 1u || - !encryption_key_header_values[0].dh.size()) { - DLOG(ERROR) << "Invalid values supplied in the Encryption-Key header"; - failure_callback.Run(DECRYPTION_FAILURE_INVALID_ENCRYPTION_KEY_HEADER); + if (crypto_key_header_values.size() != 1u || + !crypto_key_header_values[0].dh.size()) { + DLOG(ERROR) << "Invalid values supplied in the Crypto-Key header"; + failure_callback.Run(DECRYPTION_FAILURE_INVALID_CRYPTO_KEY_HEADER); return; } @@ -124,7 +121,7 @@ void GCMEncryptionProvider::DecryptMessage( weak_ptr_factory_.GetWeakPtr(), message, success_callback, failure_callback, encryption_header_values[0].salt, - encryption_key_header_values[0].dh, + crypto_key_header_values[0].dh, encryption_header_values[0].rs)); } diff --git a/components/gcm_driver/crypto/gcm_encryption_provider.h b/components/gcm_driver/crypto/gcm_encryption_provider.h index 50772802..2e7f81b 100644 --- a/components/gcm_driver/crypto/gcm_encryption_provider.h +++ b/components/gcm_driver/crypto/gcm_encryption_provider.h @@ -41,13 +41,13 @@ class GCMEncryptionProvider { // The contents of the Encryption HTTP header could not be parsed. DECRYPTION_FAILURE_INVALID_ENCRYPTION_HEADER, - // The contents of the Encryption-Key HTTP header could not be parsed. - DECRYPTION_FAILURE_INVALID_ENCRYPTION_KEY_HEADER, + // The contents of the Crypto-Key HTTP header could not be parsed. + DECRYPTION_FAILURE_INVALID_CRYPTO_KEY_HEADER, // No public/private key-pair was associated with the app_id. DECRYPTION_FAILURE_NO_KEYS, - // The public key provided in the Encryption-Key header is invalid. + // The public key provided in the Crypto-Key header is invalid. DECRYPTION_FAILURE_INVALID_PUBLIC_KEY, // The payload could not be decrypted as AES-128-GCM. diff --git a/components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc b/components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc index 036073b..c8ad5dd 100644 --- a/components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc +++ b/components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc @@ -32,10 +32,10 @@ const char kValidEncryptionHeader[] = "keyid=foo;salt=MTIzNDU2Nzg5MDEyMzQ1Ng;rs=1024"; const char kInvalidEncryptionHeader[] = "keyid"; -const char kValidEncryptionKeyHeader[] = +const char kValidCryptoKeyHeader[] = "keyid=foo;dh=BL_UGhfudEkXMUd4U4-D4nP5KHxKjQHsW6j88ybbehXM7fqi1OMFefDUEi0eJ" "vsKfyVBWYkQjH-lSPJKxjAyslg"; -const char kInvalidEncryptionKeyHeader[] = "keyid"; +const char kInvalidCryptoKeyHeader[] = "keyid"; } // namespace @@ -142,13 +142,13 @@ TEST_F(GCMEncryptionProviderTest, IsEncryptedMessage) { IncomingMessage double_header_message; double_header_message.data["encryption"] = ""; - double_header_message.data["encryption_key"] = ""; + double_header_message.data["crypto_key"] = ""; EXPECT_FALSE(encryption_provider()->IsEncryptedMessage( double_header_message)); IncomingMessage double_header_with_data_message; double_header_with_data_message.data["encryption"] = ""; - double_header_with_data_message.data["encryption_key"] = ""; + double_header_with_data_message.data["crypto_key"] = ""; double_header_with_data_message.raw_data = "foo"; EXPECT_TRUE(encryption_provider()->IsEncryptedMessage( double_header_with_data_message)); @@ -160,7 +160,7 @@ TEST_F(GCMEncryptionProviderTest, VerifiesEncryptionHeaderParsing) { IncomingMessage invalid_message; invalid_message.data["encryption"] = kInvalidEncryptionHeader; - invalid_message.data["encryption_key"] = kValidEncryptionKeyHeader; + invalid_message.data["crypto_key"] = kValidCryptoKeyHeader; ASSERT_NO_FATAL_FAILURE(Decrypt(invalid_message)); ASSERT_EQ(DECRYPTION_FAILED, decryption_result()); @@ -169,7 +169,7 @@ TEST_F(GCMEncryptionProviderTest, VerifiesEncryptionHeaderParsing) { IncomingMessage valid_message; valid_message.data["encryption"] = kValidEncryptionHeader; - valid_message.data["encryption_key"] = kInvalidEncryptionKeyHeader; + valid_message.data["crypto_key"] = kInvalidCryptoKeyHeader; ASSERT_NO_FATAL_FAILURE(Decrypt(valid_message)); ASSERT_EQ(DECRYPTION_FAILED, decryption_result()); @@ -177,29 +177,27 @@ TEST_F(GCMEncryptionProviderTest, VerifiesEncryptionHeaderParsing) { failure_reason()); } -TEST_F(GCMEncryptionProviderTest, VerifiesEncryptionKeyHeaderParsing) { +TEST_F(GCMEncryptionProviderTest, VerifiesCryptoKeyHeaderParsing) { // The Encryption-Key header must be parsable and contain valid values. // Note that this is more extensively tested in EncryptionHeaderParsersTest. IncomingMessage invalid_message; invalid_message.data["encryption"] = kValidEncryptionHeader; - invalid_message.data["encryption_key"] = kInvalidEncryptionKeyHeader; + invalid_message.data["crypto_key"] = kInvalidCryptoKeyHeader; ASSERT_NO_FATAL_FAILURE(Decrypt(invalid_message)); ASSERT_EQ(DECRYPTION_FAILED, decryption_result()); - EXPECT_EQ( - GCMEncryptionProvider::DECRYPTION_FAILURE_INVALID_ENCRYPTION_KEY_HEADER, - failure_reason()); + EXPECT_EQ(GCMEncryptionProvider::DECRYPTION_FAILURE_INVALID_CRYPTO_KEY_HEADER, + failure_reason()); IncomingMessage valid_message; valid_message.data["encryption"] = kInvalidEncryptionHeader; - valid_message.data["encryption_key"] = kValidEncryptionKeyHeader; + valid_message.data["crypto_key"] = kValidCryptoKeyHeader; ASSERT_NO_FATAL_FAILURE(Decrypt(valid_message)); ASSERT_EQ(DECRYPTION_FAILED, decryption_result()); - EXPECT_NE( - GCMEncryptionProvider::DECRYPTION_FAILURE_INVALID_ENCRYPTION_KEY_HEADER, - failure_reason()); + EXPECT_NE(GCMEncryptionProvider::DECRYPTION_FAILURE_INVALID_CRYPTO_KEY_HEADER, + failure_reason()); } TEST_F(GCMEncryptionProviderTest, VerifiesExistingKeys) { @@ -208,7 +206,7 @@ TEST_F(GCMEncryptionProviderTest, VerifiesExistingKeys) { IncomingMessage message; message.data["encryption"] = kValidEncryptionHeader; - message.data["encryption_key"] = kValidEncryptionKeyHeader; + message.data["crypto_key"] = kValidCryptoKeyHeader; ASSERT_NO_FATAL_FAILURE(Decrypt(message)); ASSERT_EQ(DECRYPTION_FAILED, decryption_result()); @@ -296,7 +294,7 @@ TEST_F(GCMEncryptionProviderTest, EncryptionRoundTrip) { encryption_header << "salt=" << encoded_salt; message.data["encryption"] = encryption_header.str(); - message.data["encryption_key"] = "dh=" + encoded_key; + message.data["crypto_key"] = "dh=" + encoded_key; ASSERT_TRUE(encryption_provider()->IsEncryptedMessage(message)); |