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