diff options
author | albertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 20:08:41 +0000 |
---|---|---|
committer | albertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 20:08:41 +0000 |
commit | 41c78fa1896c5f849c2160ae5de84c232e2c3de9 (patch) | |
tree | dbfa2145004d5de028626fb674c479c888b6183d /base/crypto/symmetric_key.h | |
parent | 7e563816b35dcc102eb69849295b5f6f9d048a63 (diff) | |
download | chromium_src-41c78fa1896c5f849c2160ae5de84c232e2c3de9.zip chromium_src-41c78fa1896c5f849c2160ae5de84c232e2c3de9.tar.gz chromium_src-41c78fa1896c5f849c2160ae5de84c232e2c3de9.tar.bz2 |
PBKDF2 implemetation using NSS.
BUG=none
TEST=unit test
Review URL: http://codereview.chromium.org/1024001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/crypto/symmetric_key.h')
-rw-r--r-- | base/crypto/symmetric_key.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/base/crypto/symmetric_key.h b/base/crypto/symmetric_key.h new file mode 100644 index 0000000..c298048 --- /dev/null +++ b/base/crypto/symmetric_key.h @@ -0,0 +1,46 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_CRYPTO_SYMMETRIC_KEY_H_ +#define BASE_CRYPTO_SYMMETRIC_KEY_H_ + +#include <string> + +#include "base/basictypes.h" + +#if defined(USE_NSS) +#include "base/crypto/scoped_nss_types.h" +#endif // USE_NSS + +namespace base { + +// Wraps a platform-specific symmetric key and allows it to be held in a +// scoped_ptr. +class SymmetricKey { + public: +#if defined(USE_NSS) + explicit SymmetricKey(PK11SymKey* key) : key_(key) {} +#endif // USE_NSS + + virtual ~SymmetricKey() {} + +#if defined(USE_NSS) + PK11SymKey* key() const { return key_.get(); } +#endif // USE_NSS + + // Extracts the raw key from the platform specific data. This should only be + // done in unit tests to verify that keys are generated correctly. + bool GetRawKey(std::string* raw_key); + + private: +#if defined(USE_NSS) + ScopedPK11SymKey key_; +#endif // USE_NSS + + DISALLOW_COPY_AND_ASSIGN(SymmetricKey); +}; + +} // namespace base + +#endif // BASE_CRYPTO_SYMMETRIC_KEY_H_ |