summaryrefslogtreecommitdiffstats
path: root/base/crypto/symmetric_key_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/crypto/symmetric_key_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/crypto/symmetric_key_nss.cc')
-rw-r--r--base/crypto/symmetric_key_nss.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/base/crypto/symmetric_key_nss.cc b/base/crypto/symmetric_key_nss.cc
new file mode 100644
index 0000000..2c6c1ac
--- /dev/null
+++ b/base/crypto/symmetric_key_nss.cc
@@ -0,0 +1,27 @@
+// 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.
+
+#include "base/crypto/symmetric_key.h"
+
+#include <nss.h>
+#include <pk11pub.h>
+
+#include "base/logging.h"
+
+namespace base {
+
+bool SymmetricKey::GetRawKey(std::string* raw_key) {
+ SECStatus rv = PK11_ExtractKeyValue(key_.get());
+ if (SECSuccess != rv)
+ return false;
+
+ SECItem* key_item = PK11_GetKeyData(key_.get());
+ if (!key_item)
+ return false;
+
+ raw_key->assign(reinterpret_cast<char*>(key_item->data), key_item->len);
+ return true;
+}
+
+} // namespace base