Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc

Issue 1453503002: [NOT FOR REVIEW] Ensure contributory behaviour for Web Push encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@push-renames
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" 5 #include "components/gcm_driver/crypto/gcm_encryption_provider.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64url.h" 10 #include "base/base64url.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 std::string shared_secret; 269 std::string shared_secret;
270 ASSERT_TRUE(ComputeSharedP256Secret( 270 ASSERT_TRUE(ComputeSharedP256Secret(
271 pair.private_key(), pair.public_key_x509(), server_pair.public_key(), 271 pair.private_key(), pair.public_key_x509(), server_pair.public_key(),
272 &shared_secret)); 272 &shared_secret));
273 273
274 IncomingMessage message; 274 IncomingMessage message;
275 size_t record_size; 275 size_t record_size;
276 276
277 // Encrypts the |kExampleMessage| using the generated shared key and the 277 // Encrypts the |kExampleMessage| using the generated shared key and the
278 // random |salt|, storing the result in |record_size| and the message. 278 // random |salt|, storing the result in |record_size| and the message.
279 GCMMessageCryptographer cryptographer; 279 GCMMessageCryptographer cryptographer(pair.public_key(), server_pair.public_ke y());
280 ASSERT_TRUE(cryptographer.Encrypt(kExampleMessage, shared_secret, salt, 280 ASSERT_TRUE(cryptographer.Encrypt(kExampleMessage, shared_secret, salt,
281 &record_size, &message.raw_data)); 281 &record_size, &message.raw_data));
282 282
283 std::string encoded_salt, encoded_key; 283 std::string encoded_salt, encoded_key;
284 284
285 // Compile the incoming GCM message, including the required headers. 285 // Compile the incoming GCM message, including the required headers.
286 base::Base64UrlEncode( 286 base::Base64UrlEncode(
287 salt, base::Base64UrlEncodePolicy::INCLUDE_PADDING, &encoded_salt); 287 salt, base::Base64UrlEncodePolicy::INCLUDE_PADDING, &encoded_salt);
288 base::Base64UrlEncode( 288 base::Base64UrlEncode(
289 server_pair.public_key(), base::Base64UrlEncodePolicy::INCLUDE_PADDING, 289 server_pair.public_key(), base::Base64UrlEncodePolicy::INCLUDE_PADDING,
(...skipping 10 matching lines...) Expand all
300 300
301 // Decrypt the message, and expect everything to go wonderfully well. 301 // Decrypt the message, and expect everything to go wonderfully well.
302 ASSERT_NO_FATAL_FAILURE(Decrypt(message)); 302 ASSERT_NO_FATAL_FAILURE(Decrypt(message));
303 ASSERT_EQ(DECRYPTION_SUCCEEDED, decryption_result()); 303 ASSERT_EQ(DECRYPTION_SUCCEEDED, decryption_result());
304 304
305 EXPECT_TRUE(decrypted_message().decrypted); 305 EXPECT_TRUE(decrypted_message().decrypted);
306 EXPECT_EQ(kExampleMessage, decrypted_message().raw_data); 306 EXPECT_EQ(kExampleMessage, decrypted_message().raw_data);
307 } 307 }
308 308
309 } // namespace gcm 309 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/crypto/gcm_encryption_provider.cc ('k') | components/gcm_driver/crypto/gcm_message_cryptographer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698