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

Side by Side Diff: crypto/sha1_unittest.cc

Issue 2080753002: crypto: Add BoringSSL accelerated version of SHA-1 Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « crypto/sha1.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 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 "crypto/sha1.h"
6
7 #include <stddef.h>
8
9 #include <string>
10
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 TEST(SHA1Test, Test1) {
14 // Example A.1 from FIPS 180-2: one-block message.
15 std::string input = "abc";
16
17 int expected[] = {0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e,
18 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d};
19
20 std::string output = crypto::SHA1HashString(input);
21 for (size_t i = 0; i < crypto::kSHA1Length; i++)
22 EXPECT_EQ(expected[i], output[i] & 0xFF);
23 }
24
25 TEST(SHA1Test, Test2) {
26 // Example A.2 from FIPS 180-2: multi-block message.
27 std::string input =
28 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
29
30 int expected[] = {0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae,
31 0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1};
32
33 std::string output = crypto::SHA1HashString(input);
34 for (size_t i = 0; i < crypto::kSHA1Length; i++)
35 EXPECT_EQ(expected[i], output[i] & 0xFF);
36 }
37
38 TEST(SHA1Test, Test3) {
39 // Example A.3 from FIPS 180-2: long message.
40 std::string input(1000000, 'a');
41
42 int expected[] = {0x34, 0xaa, 0x97, 0x3c, 0xd4, 0xc4, 0xda, 0xa4, 0xf6, 0x1e,
43 0xeb, 0x2b, 0xdb, 0xad, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6f};
44
45 std::string output = crypto::SHA1HashString(input);
46 for (size_t i = 0; i < crypto::kSHA1Length; i++)
47 EXPECT_EQ(expected[i], output[i] & 0xFF);
48 }
OLDNEW
« no previous file with comments | « crypto/sha1.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698