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

Unified Diff: base/hmac.h

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 | « no previous file | base/hmac_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/hmac.h
===================================================================
--- base/hmac.h (revision 15317)
+++ base/hmac.h (working copy)
@@ -25,12 +25,23 @@
SHA1
};
- HMAC(HashAlgorithm hash_alg, const unsigned char* key, int key_length);
+ explicit HMAC(HashAlgorithm hash_alg);
~HMAC();
- // Calculates the HMAC for the message in |data| using the algorithm and key
- // supplied to the constructor. The HMAC is returned in |digest|, which
- // has |digest_length| bytes of storage available.
+ // Initializes this instance using |key| of the length |key_length|. Call Init
+ // only once. It returns false on the second or later calls.
+ bool Init(const unsigned char* key, int key_length);
+
+ // Initializes this instance using |key|. Call Init only once. It returns
+ // false on the second or later calls.
+ bool Init(const std::string& key) {
+ return Init(reinterpret_cast<const unsigned char*>(key.data()),
+ static_cast<int>(key.size()));
+ }
+
+ // Calculates the HMAC for the message in |data| using the algorithm supplied
+ // to the constructor and the key supplied to the Init method. The HMAC is
+ // returned in |digest|, which has |digest_length| bytes of storage available.
bool Sign(const std::string& data, unsigned char* digest, int digest_length);
private:
« no previous file with comments | « no previous file | base/hmac_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698