| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "crypto/secure_hash.h" | 5 #include "crypto/secure_hash.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 7 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/pickle.h" | 11 #include "base/pickle.h" |
| 10 #include "crypto/sha2.h" | 12 #include "crypto/sha2.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 TEST(SecureHashTest, TestUpdate) { | 15 TEST(SecureHashTest, TestUpdate) { |
| 14 // Example B.3 from FIPS 180-2: long message. | 16 // Example B.3 from FIPS 180-2: long message. |
| 15 std::string input3(500000, 'a'); // 'a' repeated half a million times | 17 std::string input3(500000, 'a'); // 'a' repeated half a million times |
| 16 int expected3[] = { 0xcd, 0xc7, 0x6e, 0x5c, | 18 int expected3[] = { 0xcd, 0xc7, 0x6e, 0x5c, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 66 |
| 65 PickleIterator data_iterator(pickle); | 67 PickleIterator data_iterator(pickle); |
| 66 EXPECT_TRUE(ctx2->Deserialize(&data_iterator)); | 68 EXPECT_TRUE(ctx2->Deserialize(&data_iterator)); |
| 67 ctx2->Update(input4.data(), input4.size()); | 69 ctx2->Update(input4.data(), input4.size()); |
| 68 ctx2->Update(input5.data(), input5.size()); | 70 ctx2->Update(input5.data(), input5.size()); |
| 69 | 71 |
| 70 ctx2->Finish(output2, sizeof(output2)); | 72 ctx2->Finish(output2, sizeof(output2)); |
| 71 | 73 |
| 72 EXPECT_EQ(0, memcmp(output1, output2, crypto::kSHA256Length)); | 74 EXPECT_EQ(0, memcmp(output1, output2, crypto::kSHA256Length)); |
| 73 } | 75 } |
| OLD | NEW |