summaryrefslogtreecommitdiffstats
path: root/base/crypto/symmetric_key.h
diff options
context:
space:
mode:
authoralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 21:59:16 +0000
committeralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 21:59:16 +0000
commitbb2eb35a70fcbc47be253bf50c8648c65271a19e (patch)
treece04914685bddb9dc7187d8aed2cf674e456bd07 /base/crypto/symmetric_key.h
parent3a7faa316a96f8fa452c36bf1d4d13674eb62b73 (diff)
downloadchromium_src-bb2eb35a70fcbc47be253bf50c8648c65271a19e.zip
chromium_src-bb2eb35a70fcbc47be253bf50c8648c65271a19e.tar.gz
chromium_src-bb2eb35a70fcbc47be253bf50c8648c65271a19e.tar.bz2
Add support for SymmetricKey to import raw keys when using NSS.
BUG=48512 TEST=unittests Review URL: http://codereview.chromium.org/2811045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/crypto/symmetric_key.h')
-rw-r--r--base/crypto/symmetric_key.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/base/crypto/symmetric_key.h b/base/crypto/symmetric_key.h
index 48b3708..c1e6f97 100644
--- a/base/crypto/symmetric_key.h
+++ b/base/crypto/symmetric_key.h
@@ -44,12 +44,13 @@ class SymmetricKey {
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);
+#if defined(USE_NSS) || defined(OS_WIN)
+ // TODO(albertb): Port this method to mac.
+ // Imports a raw key. For this call to be successful, |raw_key| must have been
+ // generated by either GenerateRandomKey or DeriveKeyFromPassword, and
+ // must have been exported with GetRawKey. The caller owns the returned
+ // SymmetricKey.
+ static SymmetricKey* Import(Algorithm algorithm, const std::string& raw_key);
#endif
#if defined(USE_NSS)
@@ -60,13 +61,14 @@ class SymmetricKey {
HCRYPTKEY key() const { return key_.get(); }
#endif
- // Extracts the raw key from the platform specific data. This should only be
- // done in unit tests to verify that keys are generated correctly.
+ // Extracts the raw key from the platform specific data.
+ // Warning: |raw_key| holds the raw key as bytes and thus must be handled
+ // carefully.
bool GetRawKey(std::string* raw_key);
private:
#if defined(USE_NSS)
- explicit SymmetricKey(PK11SymKey* key) : key_(key) {}
+ explicit SymmetricKey(PK11SymKey* key);
ScopedPK11SymKey key_;
#elif defined(OS_MACOSX)
SymmetricKey(const void* key_data, size_t key_size_in_bits);