summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorgspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-11 23:17:14 +0000
committergspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-11 23:17:14 +0000
commit2c9f0def901b383bb003c4d10c198cabec1277f6 (patch)
treeb151b0f99cf928e3aaf4eeddf39a98bf301313db /crypto
parent98a4a4fedccd40287db03233947f48c02906b74d (diff)
downloadchromium_src-2c9f0def901b383bb003c4d10c198cabec1277f6.zip
chromium_src-2c9f0def901b383bb003c4d10c198cabec1277f6.tar.gz
chromium_src-2c9f0def901b383bb003c4d10c198cabec1277f6.tar.bz2
This adds support for encrypted ONC import to Chrome.
We now can import standalone ONC files that are encrypted by the Spigots management app. TBR=joaodasilva@chromium.org BUG=chromium-os:19397 TEST=Ran new unit tests, imported encrypted ONC on device. Review URL: http://codereview.chromium.org/8949056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto')
-rw-r--r--crypto/hmac.cc12
-rw-r--r--crypto/hmac.h7
2 files changed, 17 insertions, 2 deletions
diff --git a/crypto/hmac.cc b/crypto/hmac.cc
index 9131313..7176248 100644
--- a/crypto/hmac.cc
+++ b/crypto/hmac.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -8,9 +8,19 @@
#include "base/logging.h"
#include "crypto/secure_util.h"
+#include "crypto/symmetric_key.h"
namespace crypto {
+bool HMAC::Init(SymmetricKey* key) {
+ std::string raw_key;
+ bool result = key->GetRawKey(&raw_key) && Init(raw_key);
+ // Zero out key copy. This might get optimized away, but one can hope.
+ // Using std::string to store key info at all is a larger problem.
+ std::fill(raw_key.begin(), raw_key.end(), 0);
+ return result;
+}
+
size_t HMAC::DigestLength() const {
switch (hash_alg_) {
case SHA1:
diff --git a/crypto/hmac.h b/crypto/hmac.h
index b170ce7..2e22a15 100644
--- a/crypto/hmac.h
+++ b/crypto/hmac.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -19,6 +19,7 @@ namespace crypto {
// Simplify the interface and reduce includes by abstracting out the internals.
struct HMACPlatformData;
+class SymmetricKey;
class CRYPTO_EXPORT HMAC {
public:
@@ -41,6 +42,10 @@ class CRYPTO_EXPORT HMAC {
// TODO(abarth): key_length should be a size_t.
bool Init(const unsigned char* key, int key_length) WARN_UNUSED_RESULT;
+ // Initializes this instance using |key|. Call Init
+ // only once. It returns false on the second or later calls.
+ bool Init(SymmetricKey* key) WARN_UNUSED_RESULT;
+
// Initializes this instance using |key|. Call Init only once. It returns
// false on the second or later calls.
bool Init(const base::StringPiece& key) WARN_UNUSED_RESULT {