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

Side by Side Diff: crypto/hmac_unittest.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: Fix compilation errors 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 unified diff | Download patch | Annotate | Revision Log
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 <string> 5 #include <string>
6 6
7 #include "crypto/hmac.h" 7 #include "crypto/hmac.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 static const size_t kSHA1DigestSize = 20; 10 static const size_t kSHA1DigestSize = 20;
11 static const size_t kSHA256DigestSize = 32; 11 static const size_t kSHA256DigestSize = 32;
12 12
13 static const char* kSimpleKey = 13 static const char* kSimpleKey =
14 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" 14 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
15 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" 15 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
16 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" 16 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
17 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" 17 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
18 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"; 18 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA";
19 static const int kSimpleKeyLength = 80; 19 static const size_t kSimpleKeyLength = 80;
20 20
21 static const struct { 21 static const struct {
22 const char *data; 22 const char *data;
23 const int data_len; 23 const int data_len;
24 const char *digest; 24 const char *digest;
25 } kSimpleHmacCases[] = { 25 } kSimpleHmacCases[] = {
26 { "Test Using Larger Than Block-Size Key - Hash Key First", 54, 26 { "Test Using Larger Than Block-Size Key - Hash Key First", 54,
27 "\xAA\x4A\xE5\xE1\x52\x72\xD0\x0E\x95\x70\x56\x37\xCE\x8A\x3B\x55" 27 "\xAA\x4A\xE5\xE1\x52\x72\xD0\x0E\x95\x70\x56\x37\xCE\x8A\x3B\x55"
28 "\xED\x40\x21\x12" }, 28 "\xED\x40\x21\x12" },
29 { "Test Using Larger Than Block-Size Key and Larger " 29 { "Test Using Larger Than Block-Size Key and Larger "
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 base::StringPiece(kSimpleHmacCases[i].data, 268 base::StringPiece(kSimpleHmacCases[i].data,
269 kSimpleHmacCases[i].data_len))); 269 kSimpleHmacCases[i].data_len)));
270 270
271 // Expected size, mismatched data 271 // Expected size, mismatched data
272 EXPECT_FALSE(hmac.Verify( 272 EXPECT_FALSE(hmac.Verify(
273 base::StringPiece(kSimpleHmacCases[i].data, 273 base::StringPiece(kSimpleHmacCases[i].data,
274 kSimpleHmacCases[i].data_len), 274 kSimpleHmacCases[i].data_len),
275 base::StringPiece(empty_digest, kSHA1DigestSize))); 275 base::StringPiece(empty_digest, kSHA1DigestSize)));
276 } 276 }
277 } 277 }
OLDNEW
« crypto/hmac_openssl.cc ('K') | « crypto/hmac_openssl.cc ('k') | crypto/hmac_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698