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

Side by Side Diff: crypto/secure_hash_unittest.cc

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 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
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 "base/crypto/secure_hash.h"
wtc 2011/04/07 05:35:53 It's correct to include "crypto/secure_hash.h" fir
6
7 #include "base/basictypes.h" 5 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
9 #include "base/sha2.h" 7 #include "crypto/sha2.h"
8 #include "crypto/secure_hash.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 TEST(SecureHashTest, TestUpdate) { 11 TEST(SecureHashTest, TestUpdate) {
13 // Example B.3 from FIPS 180-2: long message. 12 // Example B.3 from FIPS 180-2: long message.
14 std::string input3(500000, 'a'); // 'a' repeated half a million times 13 std::string input3(500000, 'a'); // 'a' repeated half a million times
15 int expected3[] = { 0xcd, 0xc7, 0x6e, 0x5c, 14 int expected3[] = { 0xcd, 0xc7, 0x6e, 0x5c,
16 0x99, 0x14, 0xfb, 0x92, 15 0x99, 0x14, 0xfb, 0x92,
17 0x81, 0xa1, 0xc7, 0xe2, 16 0x81, 0xa1, 0xc7, 0xe2,
18 0x84, 0xd7, 0x3e, 0x67, 17 0x84, 0xd7, 0x3e, 0x67,
19 0xf1, 0x80, 0x9a, 0x48, 18 0xf1, 0x80, 0x9a, 0x48,
20 0xa4, 0x97, 0x20, 0x0e, 19 0xa4, 0x97, 0x20, 0x0e,
21 0x04, 0x6d, 0x39, 0xcc, 20 0x04, 0x6d, 0x39, 0xcc,
22 0xc7, 0x11, 0x2c, 0xd0 }; 21 0xc7, 0x11, 0x2c, 0xd0 };
23 22
24 uint8 output3[base::SHA256_LENGTH]; 23 uint8 output3[crypto::SHA256_LENGTH];
25 24
26 scoped_ptr<base::SecureHash> ctx(base::SecureHash::Create( 25 scoped_ptr<crypto::SecureHash> ctx(crypto::SecureHash::Create(
27 base::SecureHash::SHA256)); 26 crypto::SecureHash::SHA256));
28 ctx->Update(input3.data(), input3.size()); 27 ctx->Update(input3.data(), input3.size());
29 ctx->Update(input3.data(), input3.size()); 28 ctx->Update(input3.data(), input3.size());
30 29
31 ctx->Finish(output3, sizeof(output3)); 30 ctx->Finish(output3, sizeof(output3));
32 for (size_t i = 0; i < base::SHA256_LENGTH; i++) 31 for (size_t i = 0; i < crypto::SHA256_LENGTH; i++)
33 EXPECT_EQ(expected3[i], static_cast<int>(output3[i])); 32 EXPECT_EQ(expected3[i], static_cast<int>(output3[i]));
34 } 33 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698