summaryrefslogtreecommitdiffstats
path: root/base/hmac_nss.cc
diff options
context:
space:
mode:
authoralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 20:08:41 +0000
committeralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 20:08:41 +0000
commit41c78fa1896c5f849c2160ae5de84c232e2c3de9 (patch)
treedbfa2145004d5de028626fb674c479c888b6183d /base/hmac_nss.cc
parent7e563816b35dcc102eb69849295b5f6f9d048a63 (diff)
downloadchromium_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/hmac_nss.cc')
-rw-r--r--base/hmac_nss.cc37
1 files changed, 7 insertions, 30 deletions
diff --git a/base/hmac_nss.cc b/base/hmac_nss.cc
index d55bc64..8f63d04 100644
--- a/base/hmac_nss.cc
+++ b/base/hmac_nss.cc
@@ -7,39 +7,16 @@
#include <nss.h>
#include <pk11pub.h>
+#include "base/crypto/scoped_nss_types.h"
#include "base/logging.h"
#include "base/nss_util.h"
#include "base/scoped_ptr.h"
-namespace {
-
-template <typename Type, void (*Destroyer)(Type*)>
-struct NSSDestroyer {
- void operator()(Type* ptr) const {
- if (ptr)
- Destroyer(ptr);
- }
-};
-
-void DestroyContext(PK11Context* context) {
- PK11_DestroyContext(context, PR_TRUE);
-}
-
-// Define some convenient scopers around NSS pointers.
-typedef scoped_ptr_malloc<
- PK11SlotInfo, NSSDestroyer<PK11SlotInfo, PK11_FreeSlot> > ScopedNSSSlot;
-typedef scoped_ptr_malloc<
- PK11SymKey, NSSDestroyer<PK11SymKey, PK11_FreeSymKey> > ScopedNSSSymKey;
-typedef scoped_ptr_malloc<
- PK11Context, NSSDestroyer<PK11Context, DestroyContext> > ScopedNSSContext;
-
-} // namespace
-
namespace base {
struct HMACPlatformData {
- ScopedNSSSlot slot_;
- ScopedNSSSymKey sym_key_;
+ ScopedPK11Slot slot_;
+ ScopedPK11SymKey sym_key_;
};
HMAC::HMAC(HashAlgorithm hash_alg)
@@ -100,10 +77,10 @@ bool HMAC::Sign(const std::string& data,
}
SECItem param = { siBuffer, NULL, 0 };
- ScopedNSSContext context(PK11_CreateContextBySymKey(CKM_SHA_1_HMAC,
- CKA_SIGN,
- plat_->sym_key_.get(),
- &param));
+ ScopedPK11Context context(PK11_CreateContextBySymKey(CKM_SHA_1_HMAC,
+ CKA_SIGN,
+ plat_->sym_key_.get(),
+ &param));
if (!context.get()) {
NOTREACHED();
return false;