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

Unified Diff: crypto/hmac_win.cc

Issue 11419270: Use size_t as the type of key_length and digest_length arguments of HMAC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove the DCHECK on a digest_length of 0 from hmac_openssl.cc Created 8 years 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 | « crypto/hmac_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/hmac_win.cc
===================================================================
--- crypto/hmac_win.cc (revision 170598)
+++ crypto/hmac_win.cc (working copy)
@@ -109,7 +109,7 @@
DCHECK(hash_alg_ == SHA1 || hash_alg_ == SHA256);
}
-bool HMAC::Init(const unsigned char* key, int key_length) {
+bool HMAC::Init(const unsigned char* key, size_t key_length) {
if (plat_->provider_ || plat_->key_ || !plat_->raw_key_.empty()) {
// Init must not be called more than once on the same HMAC object.
NOTREACHED();
@@ -147,7 +147,7 @@
key_blob->header.bVersion = CUR_BLOB_VERSION;
key_blob->header.reserved = 0;
key_blob->header.aiKeyAlg = CALG_RC2;
- key_blob->key_size = key_length;
+ key_blob->key_size = static_cast<DWORD>(key_length);
memcpy(key_blob->key_data, key, key_length);
if (!CryptImportKey(plat_->provider_, &key_blob_storage[0],
@@ -168,7 +168,7 @@
bool HMAC::Sign(const base::StringPiece& data,
unsigned char* digest,
- int digest_length) const {
+ size_t digest_length) const {
if (hash_alg_ == SHA256) {
if (plat_->raw_key_.empty())
return false;
@@ -202,7 +202,7 @@
static_cast<DWORD>(data.size()), 0))
return false;
- DWORD sha1_size = digest_length;
+ DWORD sha1_size = static_cast<DWORD>(digest_length);
return !!CryptGetHashParam(hash, HP_HASHVAL, digest, &sha1_size, 0);
}
« no previous file with comments | « crypto/hmac_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698