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

Side by Side Diff: base/crypto/symmetric_key.h

Issue 3855004: Make USE_OPENSSL and USE_NSS mutually exclusive (Closed)
Patch Set: wtc comments Created 10 years, 2 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 | « base/crypto/signature_verifier_openssl.cc ('k') | base/crypto/symmetric_key_openssl.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef BASE_CRYPTO_SYMMETRIC_KEY_H_ 5 #ifndef BASE_CRYPTO_SYMMETRIC_KEY_H_
6 #define BASE_CRYPTO_SYMMETRIC_KEY_H_ 6 #define BASE_CRYPTO_SYMMETRIC_KEY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #elif defined(OS_WIN) 58 #elif defined(OS_WIN)
59 HCRYPTKEY key() const { return key_.get(); } 59 HCRYPTKEY key() const { return key_.get(); }
60 #endif 60 #endif
61 61
62 // Extracts the raw key from the platform specific data. 62 // Extracts the raw key from the platform specific data.
63 // Warning: |raw_key| holds the raw key as bytes and thus must be handled 63 // Warning: |raw_key| holds the raw key as bytes and thus must be handled
64 // carefully. 64 // carefully.
65 bool GetRawKey(std::string* raw_key); 65 bool GetRawKey(std::string* raw_key);
66 66
67 private: 67 private:
68 #if defined(USE_NSS) 68 #if defined(USE_OPENSSL)
69 // TODO(joth): Add a constructor that accepts OpenSSL symmetric key data, and
70 // the appropriate data members to store it in.
71 #elif defined(USE_NSS)
69 explicit SymmetricKey(PK11SymKey* key); 72 explicit SymmetricKey(PK11SymKey* key);
70 ScopedPK11SymKey key_; 73 ScopedPK11SymKey key_;
71 #elif defined(OS_MACOSX) 74 #elif defined(OS_MACOSX)
72 SymmetricKey(const void* key_data, size_t key_size_in_bits); 75 SymmetricKey(const void* key_data, size_t key_size_in_bits);
73 std::string key_; 76 std::string key_;
74 #elif defined(OS_WIN) 77 #elif defined(OS_WIN)
75 SymmetricKey(HCRYPTPROV provider, HCRYPTKEY key, 78 SymmetricKey(HCRYPTPROV provider, HCRYPTKEY key,
76 const void* key_data, size_t key_size_in_bytes); 79 const void* key_data, size_t key_size_in_bytes);
77 80
78 ScopedHCRYPTPROV provider_; 81 ScopedHCRYPTPROV provider_;
79 ScopedHCRYPTKEY key_; 82 ScopedHCRYPTKEY key_;
80 83
81 // Contains the raw key, if it is known during initialization and when it 84 // Contains the raw key, if it is known during initialization and when it
82 // is likely that the associated |provider_| will be unable to export the 85 // is likely that the associated |provider_| will be unable to export the
83 // |key_|. This is the case of HMAC keys when the key size exceeds 16 bytes 86 // |key_|. This is the case of HMAC keys when the key size exceeds 16 bytes
84 // when using the default RSA provider. 87 // when using the default RSA provider.
85 // TODO(rsleevi): See if KP_EFFECTIVE_KEYLEN is the reason why CryptExportKey 88 // TODO(rsleevi): See if KP_EFFECTIVE_KEYLEN is the reason why CryptExportKey
86 // fails with NTE_BAD_KEY/NTE_BAD_LEN 89 // fails with NTE_BAD_KEY/NTE_BAD_LEN
87 std::string raw_key_; 90 std::string raw_key_;
88 #endif 91 #endif
89 92
90 DISALLOW_COPY_AND_ASSIGN(SymmetricKey); 93 DISALLOW_COPY_AND_ASSIGN(SymmetricKey);
91 }; 94 };
92 95
93 } // namespace base 96 } // namespace base
94 97
95 #endif // BASE_CRYPTO_SYMMETRIC_KEY_H_ 98 #endif // BASE_CRYPTO_SYMMETRIC_KEY_H_
OLDNEW
« no previous file with comments | « base/crypto/signature_verifier_openssl.cc ('k') | base/crypto/symmetric_key_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698