diff options
author | snej@chromium.org <snej@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 18:22:24 +0000 |
---|---|---|
committer | snej@chromium.org <snej@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 18:22:24 +0000 |
commit | 10811823389d6dd702212008a8e9f3901b804641 (patch) | |
tree | 611200c403f60748d076b08814e78b9ef441cf0e /base/crypto/symmetric_key.h | |
parent | 7fd5f9355f6c3443ca389c4910baf946892bb5da (diff) | |
download | chromium_src-10811823389d6dd702212008a8e9f3901b804641.zip chromium_src-10811823389d6dd702212008a8e9f3901b804641.tar.gz chromium_src-10811823389d6dd702212008a8e9f3901b804641.tar.bz2 |
Add Mac implementations of new SymmetricKey and Encryptor classes.
BUG=none
TEST=EncryptorTest, SymmetricKeyTest
Review URL: http://codereview.chromium.org/1347002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/crypto/symmetric_key.h')
-rw-r--r-- | base/crypto/symmetric_key.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/base/crypto/symmetric_key.h b/base/crypto/symmetric_key.h index 1e1aed5..f528213 100644 --- a/base/crypto/symmetric_key.h +++ b/base/crypto/symmetric_key.h @@ -11,7 +11,9 @@ #if defined(USE_NSS) #include "base/crypto/scoped_nss_types.h" -#endif // USE_NSS +#elif defined(OS_MACOSX) +#include <Security/cssmtype.h> +#endif namespace base { @@ -26,21 +28,25 @@ class SymmetricKey { virtual ~SymmetricKey() {} - // Generates a random key suitable to be used with |cipher| and of |key_size| - // bytes. The caller is responsible for deleting the returned SymmetricKey. - static SymmetricKey* GenerateRandomKey(Algorithm algorithm, size_t key_size); + // Generates a random key suitable to be used with |cipher| and of + // |key_size_in_bits| bits. + // The caller is responsible for deleting the returned SymmetricKey. + static SymmetricKey* GenerateRandomKey(Algorithm algorithm, + size_t key_size_in_bits); // Derives a key from the supplied password and salt using PBKDF2. The caller - // is respnosible for deleting the returned SymmetricKey. + // is responsible for deleting the returned SymmetricKey. static SymmetricKey* DeriveKeyFromPassword(Algorithm algorithm, const std::string& password, const std::string& salt, size_t iterations, - size_t key_size); + size_t key_size_in_bits); #if defined(USE_NSS) PK11SymKey* key() const { return key_.get(); } -#endif // USE_NSS +#elif defined(OS_MACOSX) + CSSM_DATA cssm_data() const; +#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. @@ -50,7 +56,10 @@ class SymmetricKey { #if defined(USE_NSS) explicit SymmetricKey(PK11SymKey* key) : key_(key) {} ScopedPK11SymKey key_; -#endif // USE_NSS +#elif defined(OS_MACOSX) + SymmetricKey(const void* key_data, size_t key_size_in_bits); + std::string key_; +#endif DISALLOW_COPY_AND_ASSIGN(SymmetricKey); }; |