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

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

Issue 2621103002: Remove GCMMessageCryptographer::Label (Closed)
Patch Set: Remove GCMMessageCryptographer::Label Created 3 years, 11 months 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
« no previous file with comments | « no previous file | components/gcm_driver/crypto/gcm_encryption_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_crypto_test_helpers.h" 5 #include "components/gcm_driver/crypto/gcm_crypto_test_helpers.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
(...skipping 26 matching lines...) Expand all
37 &shared_secret)) { 37 &shared_secret)) {
38 return false; 38 return false;
39 } 39 }
40 40
41 std::string salt; 41 std::string salt;
42 42
43 // Generate a cryptographically secure random salt for the message. 43 // Generate a cryptographically secure random salt for the message.
44 const size_t salt_size = GCMMessageCryptographer::kSaltSize; 44 const size_t salt_size = GCMMessageCryptographer::kSaltSize;
45 crypto::RandBytes(base::WriteInto(&salt, salt_size + 1), salt_size); 45 crypto::RandBytes(base::WriteInto(&salt, salt_size + 1), salt_size);
46 46
47 GCMMessageCryptographer cryptographer(GCMMessageCryptographer::Label::P256, 47 GCMMessageCryptographer cryptographer(peer_public_key, public_key,
48 peer_public_key, public_key,
49 auth_secret.as_string()); 48 auth_secret.as_string());
50 49
51 size_t record_size; 50 size_t record_size;
52 std::string ciphertext; 51 std::string ciphertext;
53 52
54 if (!cryptographer.Encrypt(payload, shared_secret, salt, &record_size, 53 if (!cryptographer.Encrypt(payload, shared_secret, salt, &record_size,
55 &ciphertext)) { 54 &ciphertext)) {
56 return false; 55 return false;
57 } 56 }
58 57
(...skipping 15 matching lines...) Expand all
74 std::stringstream crypto_key_header; 73 std::stringstream crypto_key_header;
75 crypto_key_header << "dh=" << encoded_public_key; 74 crypto_key_header << "dh=" << encoded_public_key;
76 75
77 message->data["crypto-key"] = crypto_key_header.str(); 76 message->data["crypto-key"] = crypto_key_header.str();
78 77
79 message->raw_data.swap(ciphertext); 78 message->raw_data.swap(ciphertext);
80 return true; 79 return true;
81 } 80 }
82 81
83 } // namespace gcm 82 } // namespace gcm
OLDNEW
« no previous file with comments | « no previous file | components/gcm_driver/crypto/gcm_encryption_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698