Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1128)

Unified Diff: base/hmac_mac.cc

Issue 88062: Separate the initialization code in the constructor of HMAC class into Init f... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/hmac.h ('k') | base/hmac_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/hmac_mac.cc
===================================================================
--- base/hmac_mac.cc (revision 15317)
+++ base/hmac_mac.cc (working copy)
@@ -14,9 +14,22 @@
std::string key_;
};
-HMAC::HMAC(HashAlgorithm hash_alg, const unsigned char* key, int key_length)
+HMAC::HMAC(HashAlgorithm hash_alg)
: hash_alg_(hash_alg), plat_(new HMACPlatformData()) {
+ // Only SHA-1 digest is supported now.
+ DCHECK(hash_alg_ == SHA1);
+}
+
+bool HMAC::Init(const unsigned char *key, int key_length) {
+ if (!plat_->key_.empty()) {
+ // Init must not be called more than once on the same HMAC object.
+ NOTREACHED();
+ return false;
+ }
+
plat_->key_.assign(reinterpret_cast<const char*>(key), key_length);
+
+ return true;
}
HMAC::~HMAC() {
« no previous file with comments | « base/hmac.h ('k') | base/hmac_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698