Chromium Code Reviews| Index: base/sha2_unittest.cc |
| diff --git a/base/sha2_unittest.cc b/base/sha2_unittest.cc |
| index b0321e84754722636ee033be8393caa067992635..314d7a6820fb8023212b6a756b8795bc1de7a7fb 100644 |
| --- a/base/sha2_unittest.cc |
| +++ b/base/sha2_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include "base/sha2.h" |
| #include "base/basictypes.h" |
| +#include "base/scoped_ptr.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| TEST(Sha256Test, Test1) { |
| @@ -95,3 +96,26 @@ TEST(Sha256Test, Test3) { |
| for (size_t i = 0; i < sizeof(output_truncated3); i++) |
| EXPECT_EQ(expected3[i], static_cast<int>(output_truncated3[i])); |
| } |
| + |
| +TEST(Sha256Test, TestContext) { |
|
wtc
2011/01/21 22:48:51
You'll need to rename this test "TestUpdate" or "T
bulach
2011/01/24 20:54:33
renamed to TestUpdate (in the new file).
|
| + // Example B.3 from FIPS 180-2: long message. |
| + std::string input3(500000, 'a'); // 'a' repeated half a million times |
| + int expected3[] = { 0xcd, 0xc7, 0x6e, 0x5c, |
| + 0x99, 0x14, 0xfb, 0x92, |
| + 0x81, 0xa1, 0xc7, 0xe2, |
| + 0x84, 0xd7, 0x3e, 0x67, |
| + 0xf1, 0x80, 0x9a, 0x48, |
| + 0xa4, 0x97, 0x20, 0x0e, |
| + 0x04, 0x6d, 0x39, 0xcc, |
| + 0xc7, 0x11, 0x2c, 0xd0 }; |
| + |
| + uint8 output3[base::SHA256_LENGTH]; |
| + |
| + scoped_ptr<base::SHA256Context> ctx(base::SHA256Context::Create()); |
| + ctx->Update(input3); |
| + ctx->Update(input3); |
| + |
| + ctx->Finish(output3, sizeof(output3)); |
| + for (size_t i = 0; i < base::SHA256_LENGTH; i++) |
| + EXPECT_EQ(expected3[i], static_cast<int>(output3[i])); |
| +} |