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

Side by Side Diff: crypto/hmac_win.cc

Issue 9695058: Don't enforce the old HMAC key size requirement in FIPS 198 Sec. 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « crypto/hmac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "crypto/hmac.h" 5 #include "crypto/hmac.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <wincrypt.h> 8 #include <wincrypt.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 bool HMAC::Init(const unsigned char* key, int key_length) { 99 bool HMAC::Init(const unsigned char* key, int key_length) {
100 if (plat_->provider_ || plat_->key_ || !plat_->raw_key_.empty()) { 100 if (plat_->provider_ || plat_->key_ || !plat_->raw_key_.empty()) {
101 // Init must not be called more than once on the same HMAC object. 101 // Init must not be called more than once on the same HMAC object.
102 NOTREACHED(); 102 NOTREACHED();
103 return false; 103 return false;
104 } 104 }
105 105
106 if (hash_alg_ == SHA256) { 106 if (hash_alg_ == SHA256) {
107 if (key_length < SHA256_LENGTH / 2)
108 return false; // Key is too short.
109 plat_->raw_key_.assign(key, key + key_length); 107 plat_->raw_key_.assign(key, key + key_length);
110 return true; 108 return true;
111 } 109 }
112 110
113 if (!CryptAcquireContext(plat_->provider_.receive(), NULL, NULL, 111 if (!CryptAcquireContext(plat_->provider_.receive(), NULL, NULL,
114 PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { 112 PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
115 NOTREACHED(); 113 NOTREACHED();
116 return false; 114 return false;
117 } 115 }
118 116
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 187
190 if (!CryptHashData(hash, reinterpret_cast<const BYTE*>(data.data()), 188 if (!CryptHashData(hash, reinterpret_cast<const BYTE*>(data.data()),
191 static_cast<DWORD>(data.size()), 0)) 189 static_cast<DWORD>(data.size()), 0))
192 return false; 190 return false;
193 191
194 DWORD sha1_size = digest_length; 192 DWORD sha1_size = digest_length;
195 return !!CryptGetHashParam(hash, HP_HASHVAL, digest, &sha1_size, 0); 193 return !!CryptGetHashParam(hash, HP_HASHVAL, digest, &sha1_size, 0);
196 } 194 }
197 195
198 } // namespace crypto 196 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/hmac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698