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

Side by Side Diff: components/gcm_driver/crypto/gcm_encryption_provider.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
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 <vector> 7 #include <vector>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 std::string shared_secret; 240 std::string shared_secret;
241 if (!ComputeSharedP256Secret(pair.private_key(), pair.public_key_x509(), dh, 241 if (!ComputeSharedP256Secret(pair.private_key(), pair.public_key_x509(), dh,
242 &shared_secret)) { 242 &shared_secret)) {
243 DLOG(ERROR) << "Unable to calculate the shared secret."; 243 DLOG(ERROR) << "Unable to calculate the shared secret.";
244 callback.Run(DECRYPTION_RESULT_INVALID_SHARED_SECRET, IncomingMessage()); 244 callback.Run(DECRYPTION_RESULT_INVALID_SHARED_SECRET, IncomingMessage());
245 return; 245 return;
246 } 246 }
247 247
248 std::string plaintext; 248 std::string plaintext;
249 249
250 GCMMessageCryptographer cryptographer(GCMMessageCryptographer::Label::P256, 250 GCMMessageCryptographer cryptographer(pair.public_key(), dh, auth_secret);
251 pair.public_key(), dh, auth_secret);
252 if (!cryptographer.Decrypt(message.raw_data, shared_secret, salt, rs, 251 if (!cryptographer.Decrypt(message.raw_data, shared_secret, salt, rs,
253 &plaintext)) { 252 &plaintext)) {
254 DLOG(ERROR) << "Unable to decrypt the incoming data."; 253 DLOG(ERROR) << "Unable to decrypt the incoming data.";
255 callback.Run(DECRYPTION_RESULT_INVALID_PAYLOAD, IncomingMessage()); 254 callback.Run(DECRYPTION_RESULT_INVALID_PAYLOAD, IncomingMessage());
256 return; 255 return;
257 } 256 }
258 257
259 IncomingMessage decrypted_message; 258 IncomingMessage decrypted_message;
260 decrypted_message.collapse_key = message.collapse_key; 259 decrypted_message.collapse_key = message.collapse_key;
261 decrypted_message.sender_id = message.sender_id; 260 decrypted_message.sender_id = message.sender_id;
262 decrypted_message.raw_data.swap(plaintext); 261 decrypted_message.raw_data.swap(plaintext);
263 decrypted_message.decrypted = true; 262 decrypted_message.decrypted = true;
264 263
265 // There must be no data associated with the decrypted message at this point, 264 // There must be no data associated with the decrypted message at this point,
266 // to make sure that we don't end up in an infinite decryption loop. 265 // to make sure that we don't end up in an infinite decryption loop.
267 DCHECK_EQ(0u, decrypted_message.data.size()); 266 DCHECK_EQ(0u, decrypted_message.data.size());
268 267
269 callback.Run(DECRYPTION_RESULT_DECRYPTED, decrypted_message); 268 callback.Run(DECRYPTION_RESULT_DECRYPTED, decrypted_message);
270 } 269 }
271 270
272 } // namespace gcm 271 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698