| 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> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "crypto/hmac.h" | 10 #include "crypto/hmac.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 280 } |
| 281 | 281 |
| 282 TEST(HMACTest, EmptyKey) { | 282 TEST(HMACTest, EmptyKey) { |
| 283 // Test vector from https://en.wikipedia.org/wiki/HMAC | 283 // Test vector from https://en.wikipedia.org/wiki/HMAC |
| 284 const char* kExpectedDigest = | 284 const char* kExpectedDigest = |
| 285 "\xFB\xDB\x1D\x1B\x18\xAA\x6C\x08\x32\x4B\x7D\x64\xB7\x1F\xB7\x63" | 285 "\xFB\xDB\x1D\x1B\x18\xAA\x6C\x08\x32\x4B\x7D\x64\xB7\x1F\xB7\x63" |
| 286 "\x70\x69\x0E\x1D"; | 286 "\x70\x69\x0E\x1D"; |
| 287 base::StringPiece data(""); | 287 base::StringPiece data(""); |
| 288 | 288 |
| 289 crypto::HMAC hmac(crypto::HMAC::SHA1); | 289 crypto::HMAC hmac(crypto::HMAC::SHA1); |
| 290 ASSERT_TRUE(hmac.Init(NULL, 0)); | 290 ASSERT_TRUE(hmac.Init(nullptr, 0)); |
| 291 | 291 |
| 292 unsigned char digest[kSHA1DigestSize]; | 292 unsigned char digest[kSHA1DigestSize]; |
| 293 EXPECT_TRUE(hmac.Sign(data, digest, kSHA1DigestSize)); | 293 EXPECT_TRUE(hmac.Sign(data, digest, kSHA1DigestSize)); |
| 294 EXPECT_EQ(0, memcmp(kExpectedDigest, digest, kSHA1DigestSize)); | 294 EXPECT_EQ(0, memcmp(kExpectedDigest, digest, kSHA1DigestSize)); |
| 295 | 295 |
| 296 EXPECT_TRUE(hmac.Verify( | 296 EXPECT_TRUE(hmac.Verify( |
| 297 data, base::StringPiece(kExpectedDigest, kSHA1DigestSize))); | 297 data, base::StringPiece(kExpectedDigest, kSHA1DigestSize))); |
| 298 } | 298 } |
| OLD | NEW |