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

Unified Diff: crypto/hmac_openssl.cc

Issue 975273002: Update some comments and code to reflect the fact that HMAC() is no longer hostile to NULL key data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
Index: crypto/hmac_openssl.cc
diff --git a/crypto/hmac_openssl.cc b/crypto/hmac_openssl.cc
index 92eea19d780270cde6fa593986ed2015e9687f85..6cbd1b2b2ff1a8fe0c356f61fc98cbf7879a5f76 100644
--- a/crypto/hmac_openssl.cc
+++ b/crypto/hmac_openssl.cc
@@ -32,11 +32,8 @@ bool HMAC::Init(const unsigned char* key, size_t key_length) {
plat_->key.assign(key, key + key_length);
if (key_length == 0) {
davidben 2015/03/04 19:40:59 Hrm. This seems to conflict with the documentation
- // Special-case: if the key is empty, use a key with one zero
- // byte. OpenSSL's HMAC function breaks when passed a NULL key. (It calls
- // HMAC_Init_ex which treats a NULL key as having already been initialized
- // with a key previously.) HMAC pads keys with zeros, so this key is
- // equivalent.
+ // HMAC::Sign() assumes that plat_->key is not empty.
+ // HMAC pads keys with zeros, so this key is equivalent.
davidben 2015/03/04 19:40:59 Hrm. This seems to only be relevant for the DCHECK
plat_->key.push_back(0);
}
return true;

Powered by Google App Engine
This is Rietveld 408576698