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

Unified Diff: base/crypto/symmetric_key.h

Issue 1528021: Implement PBKDF2-based key derivation, random key generation,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Make albertb's suggested changes. Created 10 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/crypto/signature_verifier_win.cc ('k') | base/crypto/symmetric_key_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/crypto/symmetric_key.h
===================================================================
--- base/crypto/symmetric_key.h (revision 43766)
+++ base/crypto/symmetric_key.h (working copy)
@@ -13,6 +13,8 @@
#include "base/crypto/scoped_nss_types.h"
#elif defined(OS_MACOSX)
#include <Security/cssmtype.h>
+#elif defined(OS_WIN)
+#include "base/crypto/scoped_capi_types.h"
#endif
namespace base {
@@ -26,7 +28,7 @@
HMAC_SHA1,
};
- virtual ~SymmetricKey() {}
+ virtual ~SymmetricKey();
// Generates a random key suitable to be used with |cipher| and of
// |key_size_in_bits| bits.
@@ -42,10 +44,20 @@
size_t iterations,
size_t key_size_in_bits);
+ // TODO(wtc): port this method to Mac and NSS.
+#if defined(OS_WIN)
+ // Imports a raw key. This method is only used by unit tests.
+ static SymmetricKey* Import(Algorithm algorithm,
+ const void* key_data,
+ size_t key_size_in_bytes);
+#endif
+
#if defined(USE_NSS)
PK11SymKey* key() const { return key_.get(); }
#elif defined(OS_MACOSX)
CSSM_DATA cssm_data() const;
+#elif defined(OS_WIN)
+ HCRYPTKEY key() const { return key_.get(); }
#endif
// Extracts the raw key from the platform specific data. This should only be
@@ -59,6 +71,20 @@
#elif defined(OS_MACOSX)
SymmetricKey(const void* key_data, size_t key_size_in_bits);
std::string key_;
+#elif defined(OS_WIN)
+ SymmetricKey(HCRYPTPROV provider, HCRYPTKEY key,
+ const void* key_data, size_t key_size_in_bytes);
+
+ ScopedHCRYPTPROV provider_;
+ ScopedHCRYPTKEY key_;
+
+ // Contains the raw key, if it is known during initialization and when it
+ // is likely that the associated |provider_| will be unable to export the
+ // |key_|. This is the case of HMAC keys when the key size exceeds 16 bytes
+ // when using the default RSA provider.
+ // TODO(rsleevi): See if KP_EFFECTIVE_KEYLEN is the reason why CryptExportKey
+ // fails with NTE_BAD_KEY/NTE_BAD_LEN
+ std::string raw_key_;
#endif
DISALLOW_COPY_AND_ASSIGN(SymmetricKey);
@@ -66,4 +92,4 @@
} // namespace base
-#endif // BASE_CRYPTO_SYMMETRIC_KEY_H_
+#endif // BASE_CRYPTO_SYMMETRIC_KEY_H_
« no previous file with comments | « base/crypto/signature_verifier_win.cc ('k') | base/crypto/symmetric_key_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698