| OLD | NEW |
| 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 <stddef.h> |
| 6 |
| 5 #include <string> | 7 #include <string> |
| 6 | 8 |
| 9 #include "base/macros.h" |
| 7 #include "crypto/hmac.h" | 10 #include "crypto/hmac.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 12 |
| 10 static const size_t kSHA1DigestSize = 20; | 13 static const size_t kSHA1DigestSize = 20; |
| 11 static const size_t kSHA256DigestSize = 32; | 14 static const size_t kSHA256DigestSize = 32; |
| 12 | 15 |
| 13 static const char* kSimpleKey = | 16 static const char* kSimpleKey = |
| 14 "\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" |
| 15 "\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" |
| 16 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" | 19 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 crypto::HMAC hmac(crypto::HMAC::SHA1); | 289 crypto::HMAC hmac(crypto::HMAC::SHA1); |
| 287 ASSERT_TRUE(hmac.Init(NULL, 0)); | 290 ASSERT_TRUE(hmac.Init(NULL, 0)); |
| 288 | 291 |
| 289 unsigned char digest[kSHA1DigestSize]; | 292 unsigned char digest[kSHA1DigestSize]; |
| 290 EXPECT_TRUE(hmac.Sign(data, digest, kSHA1DigestSize)); | 293 EXPECT_TRUE(hmac.Sign(data, digest, kSHA1DigestSize)); |
| 291 EXPECT_EQ(0, memcmp(kExpectedDigest, digest, kSHA1DigestSize)); | 294 EXPECT_EQ(0, memcmp(kExpectedDigest, digest, kSHA1DigestSize)); |
| 292 | 295 |
| 293 EXPECT_TRUE(hmac.Verify( | 296 EXPECT_TRUE(hmac.Verify( |
| 294 data, base::StringPiece(kExpectedDigest, kSHA1DigestSize))); | 297 data, base::StringPiece(kExpectedDigest, kSHA1DigestSize))); |
| 295 } | 298 } |
| OLD | NEW |