OLD | NEW |
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 "base/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 |
11 // TODO(wtc): replace scoped_array by std::vector. | 11 // TODO(wtc): replace scoped_array by std::vector. |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 | 13 |
14 namespace base { | 14 namespace crypto { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // The following is a non-public Microsoft header documented in MSDN under | 18 // The following is a non-public Microsoft header documented in MSDN under |
19 // CryptImportKey / CryptExportKey. Following the header is the byte array of | 19 // CryptImportKey / CryptExportKey. Following the header is the byte array of |
20 // the actual plaintext key. | 20 // the actual plaintext key. |
21 struct PlaintextBlobHeader { | 21 struct PlaintextBlobHeader { |
22 BLOBHEADER hdr; | 22 BLOBHEADER hdr; |
23 DWORD cbKeySize; | 23 DWORD cbKeySize; |
24 }; | 24 }; |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 SymmetricKey::SymmetricKey(HCRYPTPROV provider, | 526 SymmetricKey::SymmetricKey(HCRYPTPROV provider, |
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 base | 536 } // namespace crypto |
OLD | NEW |