22 #include <gtest/gtest.h>
35 #include "../internal.h"
36 #include "../test/test_util.h"
74 {
md4,
"", 1,
"31d6cfe0d16ae931b73c59d7e0c089c0"},
75 {
md4,
"a", 1,
"bde52cb31de33e46245e05fbdbd6fb24"},
76 {
md4,
"abc", 1,
"a448017aaf21d8525fc10ae87aa6729d"},
77 {
md4,
"message digest", 1,
"d9130a8164549fe818874806e1c7014b"},
78 {
md4,
"abcdefghijklmnopqrstuvwxyz", 1,
"d79e1c308aa5bbcdeea8ed63df412da9"},
79 {
md4,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 1,
80 "043f8582f241db351ce627e153e7f0e4"},
81 {
md4,
"1234567890", 8,
"e33b4ddc9c38f2199c3e7b164fcc0536"},
84 {
md5,
"", 1,
"d41d8cd98f00b204e9800998ecf8427e"},
85 {
md5,
"a", 1,
"0cc175b9c0f1b6a831c399e269772661"},
86 {
md5,
"abc", 1,
"900150983cd24fb0d6963f7d28e17f72"},
87 {
md5,
"message digest", 1,
"f96b697d7cb7938d525a2f31aaf161d0"},
88 {
md5,
"abcdefghijklmnopqrstuvwxyz", 1,
"c3fcd3d76192e4007dfb496cca67e13b"},
89 {
md5,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 1,
90 "d174ab98d277d9f5a5611c2c9f419d9f"},
91 {
md5,
"1234567890", 8,
"57edf4a22be3c955ac49da2e2107b67a"},
94 {
sha1,
"abc", 1,
"a9993e364706816aba3e25717850c26c9cd0d89d"},
95 {
sha1,
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 1,
96 "84983e441c3bd26ebaae4aa1f95129e5e54670f1"},
97 {
sha1,
"a", 1000000,
"34aa973cd4c4daa4f61eeb2bdbad27316534016f"},
98 {
sha1,
"0123456701234567012345670123456701234567012345670123456701234567",
99 10,
"dea356a2cddd90c7a7ecedc5ebb563934f460452"},
103 "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7"},
104 {
sha224,
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 1,
105 "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525"},
107 "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67"},
111 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"},
112 {
sha256,
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 1,
113 "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"},
117 "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed"
118 "8086072ba1e7cc2358baeca134c825a7"},
120 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
121 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
123 "09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712"
124 "fcc7c71a557e2db966c3e9fa91746039"},
128 "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"
129 "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"},
131 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
132 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
134 "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018"
135 "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"},
140 "53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23"},
142 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopj"
143 "klmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
144 1,
"3928e184fb8690f840da3988121d31be65cb9d3ef83ee6146feac861e19b563a"},
148 "900150983cd24fb0d6963f7d28e17f72a9993e364706816aba3e25717850c26c9cd0d89d"},
152 "bddd813c634239723171ef3fee98579b94964e3bb1cb3e427262c8c068d52319"},
163 bssl::ScopedEVP_MD_CTX
ctx;
167 for (
size_t i = 0;
i <
test->repeat;
i++) {
178 for (
size_t i = 0;
i <
test->repeat;
i++) {
179 for (
const char *
p =
test->input; *
p;
p++) {
189 std::vector<char> unaligned(strlen(
test->input) + 1);
190 char *
ptr = unaligned.data();
195 for (
size_t i = 0;
i <
test->repeat;
i++) {
203 bssl::ScopedEVP_MD_CTX
copy;
205 for (
size_t i = 0;
i <
test->repeat;
i++) {
212 size_t half = strlen(
test->input) / 2;
217 for (
size_t i = 1;
i <
test->repeat;
i++) {
226 for (
size_t i = 0;
i <
test->repeat;
i++) {
238 for (
size_t i = 1;
i <
test->repeat;
i++) {
245 if (
test->md.one_shot_func &&
test->repeat == 1) {
247 strlen(
test->input), digest.get());
254 TEST(DigestTest, TestVectors) {
272 bssl::UniquePtr<ASN1_OBJECT>
obj(
OBJ_txt2obj(
"1.3.14.3.2.26", 0));
284 static const uint8_t kSHA256[] = {0x30, 0x0d, 0x06, 0x09, 0x60,
285 0x86, 0x48, 0x01, 0x65, 0x03,
286 0x04, 0x02, 0x01, 0x05, 0x00};
287 static const uint8_t kSHA256NoParam[] = {0x30, 0x0b, 0x06, 0x09, 0x60,
288 0x86, 0x48, 0x01, 0x65, 0x03,
290 static const uint8_t kSHA256GarbageParam[] = {
291 0x30, 0x0e, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
292 0x65, 0x03, 0x04, 0x02, 0x01, 0x02, 0x01, 0x2a};
301 bssl::UniquePtr<uint8_t> free_der(der);
311 CBS_init(&
cbs, kSHA256NoParam,
sizeof(kSHA256NoParam));
316 CBS_init(&
cbs, kSHA256GarbageParam,
sizeof(kSHA256GarbageParam));
320 TEST(DigestTest, TransformBlocks) {
322 for (
size_t i = 0;
i <
sizeof(blocks);
i++) {