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

Side by Side Diff: crypto/hmac_unittest.cc

Issue 2095523002: Make //crypto factories return std::unique_ptr<>s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: I'm blind Created 4 years, 5 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
« no previous file with comments | « crypto/hmac.cc ('k') | crypto/mock_apple_keychain.h » ('j') | 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 <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
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 }
OLDNEW
« no previous file with comments | « crypto/hmac.cc ('k') | crypto/mock_apple_keychain.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698