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

Side by Side Diff: crypto/symmetric_key_win.cc

Issue 8949056: This adds support for encrypted ONC import (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handling decryption errors better Created 8 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 | Annotate | Revision Log
« crypto/symmetric_key.h ('K') | « crypto/symmetric_key_openssl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "crypto/symmetric_key.h" 5 #include "crypto/symmetric_key.h"
6 6
7 #include <winsock2.h> // For htonl. 7 #include <winsock2.h> // For htonl.
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 return NULL; 488 return NULL;
489 489
490 ScopedHCRYPTKEY key; 490 ScopedHCRYPTKEY key;
491 if (!ImportRawKey(provider, alg, raw_key.data(), raw_key.size(), &key)) 491 if (!ImportRawKey(provider, alg, raw_key.data(), raw_key.size(), &key))
492 return NULL; 492 return NULL;
493 493
494 return new SymmetricKey(provider.release(), key.release(), 494 return new SymmetricKey(provider.release(), key.release(),
495 raw_key.data(), raw_key.size()); 495 raw_key.data(), raw_key.size());
496 } 496 }
497 497
498 bool SymmetricKey::GetRawKey(std::string* raw_key) { 498 bool SymmetricKey::GetRawKey(std::string* raw_key) const {
499 // Short circuit for when the key was supplied to the constructor. 499 // Short circuit for when the key was supplied to the constructor.
500 if (!raw_key_.empty()) { 500 if (!raw_key_.empty()) {
501 *raw_key = raw_key_; 501 *raw_key = raw_key_;
502 return true; 502 return true;
503 } 503 }
504 504
505 DWORD size = 0; 505 DWORD size = 0;
506 BOOL ok = CryptExportKey(key_, 0, PLAINTEXTKEYBLOB, 0, NULL, &size); 506 BOOL ok = CryptExportKey(key_, 0, PLAINTEXTKEYBLOB, 0, NULL, &size);
507 if (!ok) 507 if (!ok)
508 return false; 508 return false;
(...skipping 18 matching lines...) Expand all
527 HCRYPTKEY key, 527 HCRYPTKEY key,
528 const void* key_data, size_t key_size_in_bytes) 528 const void* key_data, size_t key_size_in_bytes)
529 : provider_(provider), key_(key) { 529 : provider_(provider), key_(key) {
530 if (key_data) { 530 if (key_data) {
531 raw_key_.assign(reinterpret_cast<const char*>(key_data), 531 raw_key_.assign(reinterpret_cast<const char*>(key_data),
532 key_size_in_bytes); 532 key_size_in_bytes);
533 } 533 }
534 } 534 }
535 535
536 } // namespace crypto 536 } // namespace crypto
OLDNEW
« crypto/symmetric_key.h ('K') | « crypto/symmetric_key_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698