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-20 19:21:18 +0000
committeralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 19:21:18 +0000
commit896200b32f5408f03d395d19565578db57f58e83 (patch)
treef6e6501af3ab2201b9c8d123d1b0f079bd304a2d /base/crypto/symmetric_key.h
parent9e02d6b8b23264cbb4c481ec7b5b07c6ab7583bf (diff)
downloadchromium_src-896200b32f5408f03d395d19565578db57f58e83.zip
chromium_src-896200b32f5408f03d395d19565578db57f58e83.tar.gz
chromium_src-896200b32f5408f03d395d19565578db57f58e83.tar.bz2
Take 2 for: Add support for SymmetricKey to import raw keys when using NSS.
BUG=48701 TEST=unittests Review URL: http://codereview.chromium.org/2985008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53077 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);