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

Side by Side Diff: base/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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/crypto/secure_hash.h"
6
7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/sha2.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 TEST(SecureHashTest, TestUpdate) {
13 // Example B.3 from FIPS 180-2: long message.
14 std::string input3(500000, 'a'); // 'a' repeated half a million times
15 int expected3[] = { 0xcd, 0xc7, 0x6e, 0x5c,
16 0x99, 0x14, 0xfb, 0x92,
17 0x81, 0xa1, 0xc7, 0xe2,
18 0x84, 0xd7, 0x3e, 0x67,
19 0xf1, 0x80, 0x9a, 0x48,
20 0xa4, 0x97, 0x20, 0x0e,
21 0x04, 0x6d, 0x39, 0xcc,
22 0xc7, 0x11, 0x2c, 0xd0 };
23
24 uint8 output3[base::SHA256_LENGTH];
25
26 scoped_ptr<base::SecureHash> ctx(base::SecureHash::Create(
27 base::SecureHash::SHA256));
28 ctx->Update(input3.data(), input3.size());
29 ctx->Update(input3.data(), input3.size());
30
31 ctx->Finish(output3, sizeof(output3));
32 for (size_t i = 0; i < base::SHA256_LENGTH; i++)
33 EXPECT_EQ(expected3[i], static_cast<int>(output3[i]));
34 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698