diff options
Diffstat (limited to 'src/microhttpd/test_sha256.c')
-rw-r--r-- | src/microhttpd/test_sha256.c | 495 |
1 files changed, 296 insertions, 199 deletions
diff --git a/src/microhttpd/test_sha256.c b/src/microhttpd/test_sha256.c index 4eb0cf69..da6f6e1f 100644 --- a/src/microhttpd/test_sha256.c +++ b/src/microhttpd/test_sha256.c | |||
@@ -33,7 +33,7 @@ static int verbose = 0; /* verbose level (0-1)*/ | |||
33 | 33 | ||
34 | struct str_with_len | 34 | struct str_with_len |
35 | { | 35 | { |
36 | const char * const str; | 36 | const char *const str; |
37 | const size_t len; | 37 | const size_t len; |
38 | }; | 38 | }; |
39 | 39 | ||
@@ -46,31 +46,47 @@ struct data_unit1 | |||
46 | }; | 46 | }; |
47 | 47 | ||
48 | static const struct data_unit1 data_units1[] = { | 48 | static const struct data_unit1 data_units1[] = { |
49 | {D_STR_W_LEN("abc"), | 49 | {D_STR_W_LEN ("abc"), |
50 | {0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, | 50 | {0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, |
51 | 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}}, | 51 | 0x5d, 0xae, 0x22, 0x23, |
52 | {D_STR_W_LEN("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"), | 52 | 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, |
53 | {0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, | 53 | 0xf2, 0x00, 0x15, 0xad}}, |
54 | 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1}}, | 54 | {D_STR_W_LEN ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"), |
55 | {D_STR_W_LEN(""), | 55 | {0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, |
56 | {0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, | 56 | 0x0c, 0x3e, 0x60, 0x39, |
57 | 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}}, | 57 | 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, |
58 | {D_STR_W_LEN("1234567890!@~%&$@#{}[]\\/!?`."), | 58 | 0x19, 0xdb, 0x06, 0xc1}}, |
59 | {0x2f, 0xad, 0x7a, 0xff, 0x7d, 0xfe, 0xcd, 0x78, 0xe4, 0xa6, 0xf3, 0x85, 0x97, 0x9d, 0xdc, 0x39, | 59 | {D_STR_W_LEN (""), |
60 | 0x55, 0x24, 0x35, 0x4a, 0x00, 0x6f, 0x42, 0x72, 0x41, 0xc1, 0x52, 0xa7, 0x01, 0x0b, 0x2c, 0x41}}, | 60 | {0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, |
61 | {D_STR_W_LEN("Simple string."), | 61 | 0x99, 0x6f, 0xb9, 0x24, |
62 | {0x01, 0x73, 0x17, 0xc4, 0x0a, 0x9a, 0x0e, 0x81, 0xb3, 0xa4, 0xb1, 0x8e, 0xe9, 0xd6, 0xc2, 0xdf, | 62 | 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, |
63 | 0xfa, 0x7d, 0x53, 0x4e, 0xa1, 0xda, 0xb2, 0x5a, 0x75, 0xbb, 0x2c, 0x30, 0x2f, 0x5f, 0x7a, 0xf4}}, | 63 | 0x78, 0x52, 0xb8, 0x55}}, |
64 | {D_STR_W_LEN("abcdefghijklmnopqrstuvwxyz"), | 64 | {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), |
65 | {0x71, 0xc4, 0x80, 0xdf, 0x93, 0xd6, 0xae, 0x2f, 0x1e, 0xfa, 0xd1, 0x44, 0x7c, 0x66, 0xc9, 0x52, | 65 | {0x2f, 0xad, 0x7a, 0xff, 0x7d, 0xfe, 0xcd, 0x78, 0xe4, 0xa6, 0xf3, 0x85, |
66 | 0x5e, 0x31, 0x62, 0x18, 0xcf, 0x51, 0xfc, 0x8d, 0x9e, 0xd8, 0x32, 0xf2, 0xda, 0xf1, 0x8b, 0x73}}, | 66 | 0x97, 0x9d, 0xdc, 0x39, |
67 | {D_STR_W_LEN("zyxwvutsrqponMLKJIHGFEDCBA"), | 67 | 0x55, 0x24, 0x35, 0x4a, 0x00, 0x6f, 0x42, 0x72, 0x41, 0xc1, 0x52, 0xa7, |
68 | {0xce, 0x7d, 0xde, 0xb6, 0x1f, 0x7c, 0x1d, 0x83, 0x7c, 0x60, 0xd8, 0x36, 0x73, 0x82, 0xac, 0x92, | 68 | 0x01, 0x0b, 0x2c, 0x41}}, |
69 | 0xca, 0x37, 0xfd, 0x72, 0x8b, 0x0c, 0xd1, 0x6c, 0x55, 0xd5, 0x88, 0x98, 0x24, 0xfa, 0x16, 0xf2}}, | 69 | {D_STR_W_LEN ("Simple string."), |
70 | {D_STR_W_LEN("abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA" | 70 | {0x01, 0x73, 0x17, 0xc4, 0x0a, 0x9a, 0x0e, 0x81, 0xb3, 0xa4, 0xb1, 0x8e, |
71 | "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"), | 71 | 0xe9, 0xd6, 0xc2, 0xdf, |
72 | {0x27, 0xd1, 0xe8, 0xbc, 0x6a, 0x79, 0x16, 0x83, 0x61, 0x73, 0xa9, 0xa8, 0x9b, 0xaf, 0xaf, 0xcf, | 72 | 0xfa, 0x7d, 0x53, 0x4e, 0xa1, 0xda, 0xb2, 0x5a, 0x75, 0xbb, 0x2c, 0x30, |
73 | 0x47, 0x4d, 0x09, 0xef, 0x6d, 0x50, 0x35, 0x12, 0x25, 0x72, 0xd8, 0x68, 0xdc, 0x1f, 0xd2, 0xf4}}, | 73 | 0x2f, 0x5f, 0x7a, 0xf4}}, |
74 | {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), | ||
75 | {0x71, 0xc4, 0x80, 0xdf, 0x93, 0xd6, 0xae, 0x2f, 0x1e, 0xfa, 0xd1, 0x44, | ||
76 | 0x7c, 0x66, 0xc9, 0x52, | ||
77 | 0x5e, 0x31, 0x62, 0x18, 0xcf, 0x51, 0xfc, 0x8d, 0x9e, 0xd8, 0x32, 0xf2, | ||
78 | 0xda, 0xf1, 0x8b, 0x73}}, | ||
79 | {D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"), | ||
80 | {0xce, 0x7d, 0xde, 0xb6, 0x1f, 0x7c, 0x1d, 0x83, 0x7c, 0x60, 0xd8, 0x36, | ||
81 | 0x73, 0x82, 0xac, 0x92, | ||
82 | 0xca, 0x37, 0xfd, 0x72, 0x8b, 0x0c, 0xd1, 0x6c, 0x55, 0xd5, 0x88, 0x98, | ||
83 | 0x24, 0xfa, 0x16, 0xf2}}, | ||
84 | {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA" | ||
85 | "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"), | ||
86 | {0x27, 0xd1, 0xe8, 0xbc, 0x6a, 0x79, 0x16, 0x83, 0x61, 0x73, 0xa9, 0xa8, | ||
87 | 0x9b, 0xaf, 0xaf, 0xcf, | ||
88 | 0x47, 0x4d, 0x09, 0xef, 0x6d, 0x50, 0x35, 0x12, 0x25, 0x72, 0xd8, 0x68, | ||
89 | 0xdc, 0x1f, 0xd2, 0xf4}}, | ||
74 | }; | 90 | }; |
75 | 91 | ||
76 | static const size_t units1_num = sizeof(data_units1) / sizeof(data_units1[0]); | 92 | static const size_t units1_num = sizeof(data_units1) / sizeof(data_units1[0]); |
@@ -89,95 +105,154 @@ struct data_unit2 | |||
89 | 105 | ||
90 | /* Size must be less than 512 bytes! */ | 106 | /* Size must be less than 512 bytes! */ |
91 | static const struct data_unit2 data_units2[] = { | 107 | static const struct data_unit2 data_units2[] = { |
92 | { { {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, | 108 | { { {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
93 | 117, 118, 119, 120, 121, 122}, 26},/* a..z ASCII sequence */ | 109 | 112, 113, 114, 115, 116, |
94 | {0x71, 0xc4, 0x80, 0xdf, 0x93, 0xd6, 0xae, 0x2f, 0x1e, 0xfa, 0xd1, 0x44, 0x7c, 0x66, 0xc9, 0x52, | 110 | 117, 118, 119, 120, 121, 122}, 26}, /* a..z ASCII sequence */ |
95 | 0x5e, 0x31, 0x62, 0x18, 0xcf, 0x51, 0xfc, 0x8d, 0x9e, 0xd8, 0x32, 0xf2, 0xda, 0xf1, 0x8b, 0x73} | 111 | {0x71, 0xc4, 0x80, 0xdf, 0x93, 0xd6, 0xae, 0x2f, 0x1e, 0xfa, 0xd1, 0x44, |
96 | }, | 112 | 0x7c, 0x66, 0xc9, 0x52, |
97 | { { {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 113 | 0x5e, 0x31, 0x62, 0x18, 0xcf, 0x51, 0xfc, 0x8d, 0x9e, 0xd8, 0x32, 0xf2, |
98 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 114 | 0xda, 0xf1, 0x8b, 0x73}}, |
99 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 | 115 | { { {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, |
100 | }, 72 },/* 'A' x 72 times */ | 116 | 65, 65, 65, 65, 65, 65, |
101 | {0x6a, 0x6d, 0x69, 0x1a, 0xc9, 0xba, 0x70, 0x95, 0x50, 0x46, 0x75, 0x7c, 0xd6, 0x85, 0xb6, 0x25, | 117 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, |
102 | 0x77, 0x73, 0xff, 0x3a, 0xd9, 0x3f, 0x43, 0xd4, 0xd4, 0x81, 0x2c, 0x5b, 0x10, 0x6f, 0x4b, 0x5b} | 118 | 65, 65, 65, 65, 65, 65, |
103 | }, | 119 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, |
104 | { { {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, | 120 | 65, 65, 65, 65, 65, 65}, 72 },/* 'A' x 72 times */ |
105 | 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, | 121 | {0x6a, 0x6d, 0x69, 0x1a, 0xc9, 0xba, 0x70, 0x95, 0x50, 0x46, 0x75, 0x7c, |
106 | 68, 69, 70, 71, 72, 73}, 55},/* 19..73 sequence */ | 122 | 0xd6, 0x85, 0xb6, 0x25, |
107 | {0x06, 0xe4, 0xb3, 0x9e, 0xf1, 0xfb, 0x6c, 0xcf, 0xd7, 0x3f, 0x50, 0x9e, 0xf4, 0x16, 0x17, 0xd4, | 123 | 0x77, 0x73, 0xff, 0x3a, 0xd9, 0x3f, 0x43, 0xd4, 0xd4, 0x81, 0x2c, 0x5b, |
108 | 0x63, 0x7c, 0x39, 0x1e, 0xa8, 0x0f, 0xa9, 0x88, 0x03, 0x44, 0x98, 0x0e, 0x95, 0x81, 0xf0, 0x2a} | 124 | 0x10, 0x6f, 0x4b, 0x5b}}, |
109 | }, | 125 | { { {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
110 | { { {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | 126 | 37, 38, 39, 40, 41, 42, |
111 | 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 127 | 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, |
112 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, 63},/* 7..69 sequence */ | 128 | 61, 62, 63, 64, 65, 66, 67, |
113 | {0x4a, 0xd3, 0xc6, 0x87, 0x1f, 0xd1, 0xc5, 0xe2, 0x3e, 0x52, 0xdc, 0x22, 0xd1, 0x10, 0xd2, 0x05, | 129 | 68, 69, 70, 71, 72, 73}, 55}, /* 19..73 sequence */ |
114 | 0x15, 0x23, 0xcd, 0x15, 0xac, 0x24, 0x88, 0x26, 0x02, 0x00, 0x70, 0x78, 0x9f, 0x17, 0xf8, 0xd9} | 130 | {0x06, 0xe4, 0xb3, 0x9e, 0xf1, 0xfb, 0x6c, 0xcf, 0xd7, 0x3f, 0x50, 0x9e, |
115 | }, | 131 | 0xf4, 0x16, 0x17, 0xd4, |
116 | { { {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, | 132 | 0x63, 0x7c, 0x39, 0x1e, 0xa8, 0x0f, 0xa9, 0x88, 0x03, 0x44, 0x98, 0x0e, |
117 | 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, | 133 | 0x95, 0x81, 0xf0, 0x2a}}, |
118 | 87, 88, 89, 90, 91, 92}, 55},/* 38..92 sequence */ | 134 | { { {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, |
119 | {0xe6, 0x03, 0x0f, 0xc9, 0x0d, 0xca, 0x0c, 0x26, 0x41, 0xcf, 0x43, 0x27, 0xec, 0xd6, 0x28, 0x2a, | 135 | 26, 27, 28, 29, 30, 31, |
120 | 0x98, 0x24, 0x55, 0xd3, 0x5a, 0xed, 0x8b, 0x32, 0x19, 0x78, 0xeb, 0x83, 0x1d, 0x19, 0x92, 0x79} | 136 | 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, |
121 | }, | 137 | 50, 51, 52, 53, 54, 55, 56, |
122 | { { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, | 138 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, 63}, /* 7..69 sequence */ |
123 | 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 139 | {0x4a, 0xd3, 0xc6, 0x87, 0x1f, 0xd1, 0xc5, 0xe2, 0x3e, 0x52, 0xdc, 0x22, |
124 | 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72}, | 140 | 0xd1, 0x10, 0xd2, 0x05, |
141 | 0x15, 0x23, 0xcd, 0x15, 0xac, 0x24, 0x88, 0x26, 0x02, 0x00, 0x70, 0x78, | ||
142 | 0x9f, 0x17, 0xf8, 0xd9}}, | ||
143 | { { {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, | ||
144 | 56, 57, 58, 59, 60, 61, | ||
145 | 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, | ||
146 | 80, 81, 82, 83, 84, 85, 86, | ||
147 | 87, 88, 89, 90, 91, 92}, 55}, /* 38..92 sequence */ | ||
148 | {0xe6, 0x03, 0x0f, 0xc9, 0x0d, 0xca, 0x0c, 0x26, 0x41, 0xcf, 0x43, 0x27, | ||
149 | 0xec, 0xd6, 0x28, 0x2a, | ||
150 | 0x98, 0x24, 0x55, 0xd3, 0x5a, 0xed, 0x8b, 0x32, 0x19, 0x78, 0xeb, 0x83, | ||
151 | 0x1d, 0x19, 0x92, 0x79}}, | ||
152 | { { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, | ||
153 | 21, 22, 23, 24, 25, 26, 27, | ||
154 | 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, | ||
155 | 46, 47, 48, 49, 50, 51, 52, | ||
156 | 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, | ||
157 | 71, 72}, | ||
125 | 72},/* 1..72 sequence */ | 158 | 72},/* 1..72 sequence */ |
126 | {0x87, 0xa2, 0xfa, 0x2e, 0xec, 0x53, 0x05, 0x3c, 0xb1, 0xee, 0x07, 0xd7, 0x59, 0x70, 0xf6, 0x50, | 159 | {0x87, 0xa2, 0xfa, 0x2e, 0xec, 0x53, 0x05, 0x3c, 0xb1, 0xee, 0x07, 0xd7, |
127 | 0xcd, 0x9d, 0xc5, 0x8b, 0xdc, 0xb8, 0x65, 0x30, 0x4f, 0x70, 0x82, 0x9e, 0xbd, 0xe2, 0x7d, 0xac} | 160 | 0x59, 0x70, 0xf6, 0x50, |
128 | }, | 161 | 0xcd, 0x9d, 0xc5, 0x8b, 0xdc, 0xb8, 0x65, 0x30, 0x4f, 0x70, 0x82, 0x9e, |
129 | { { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, | 162 | 0xbd, 0xe2, 0x7d, 0xac}}, |
130 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, | 163 | { { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
131 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, | 164 | 21, 22, 23, 24, 25, 26, |
132 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, | 165 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
133 | 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, | 166 | 45, 46, 47, 48, 49, 50, 51, |
134 | 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, | 167 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, |
135 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, | 168 | 70, 71, 72, 73, 74, 75, 76, |
136 | 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, | 169 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
137 | 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, | 170 | 95, 96, 97, 98, 99, 100, |
138 | 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, | 171 | 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
139 | 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, | 172 | 115, 116, 117, 118, 119, 120, |
140 | 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}, 256}, /* 0..255 sequence */ | 173 | 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
141 | {0x40, 0xaf, 0xf2, 0xe9, 0xd2, 0xd8, 0x92, 0x2e, 0x47, 0xaf, 0xd4, 0x64, 0x8e, 0x69, 0x67, 0x49, | 174 | 135, 136, 137, 138, 139, 140, |
142 | 0x71, 0x58, 0x78, 0x5f, 0xbd, 0x1d, 0xa8, 0x70, 0xe7, 0x11, 0x02, 0x66, 0xbf, 0x94, 0x48, 0x80} | 175 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, |
143 | }, | 176 | 155, 156, 157, 158, 159, 160, |
144 | { { {199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, | 177 | 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
145 | 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, | 178 | 175, 176, 177, 178, 179, 180, |
146 | 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, | 179 | 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, |
147 | 139}, 61}, /* 199..139 sequence */ | 180 | 195, 196, 197, 198, 199, 200, |
148 | {0x85, 0xf8, 0xa2, 0x83, 0xd6, 0x3c, 0x76, 0x8e, 0xea, 0x8f, 0x1c, 0x57, 0x2d, 0x85, 0xb6, 0xff, | 181 | 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, |
149 | 0xd8, 0x33, 0x57, 0x62, 0x1d, 0x37, 0xae, 0x0e, 0xfc, 0x22, 0xd3, 0xd5, 0x8f, 0x53, 0x21, 0xb7} | 182 | 215, 216, 217, 218, 219, 220, |
150 | }, | 183 | 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, |
151 | { { {255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, | 184 | 235, 236, 237, 238, 239, 240, |
152 | 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, | 185 | 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, |
153 | 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, | 186 | 255}, 256}, /* 0..255 sequence */ |
154 | 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, | 187 | {0x40, 0xaf, 0xf2, 0xe9, 0xd2, 0xd8, 0x92, 0x2e, 0x47, 0xaf, 0xd4, 0x64, |
155 | 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, | 188 | 0x8e, 0x69, 0x67, 0x49, |
156 | 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, | 189 | 0x71, 0x58, 0x78, 0x5f, 0xbd, 0x1d, 0xa8, 0x70, 0xe7, 0x11, 0x02, 0x66, |
157 | 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, | 190 | 0xbf, 0x94, 0x48, 0x80}}, |
158 | 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, | 191 | { { {199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, |
159 | 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, | 192 | 185, 184, 183, 182, 181, 180, |
160 | 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, | 193 | 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, |
161 | 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, | 194 | 165, 164, 163, 162, 161, 160, |
162 | 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, 255}, /* 255..1 sequence */ | 195 | 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, |
163 | {0x61, 0x86, 0x96, 0xab, 0x3e, 0xaa, 0x0e, 0x64, 0xb2, 0xf7, 0x2d, 0x75, 0x47, 0x5a, 0x14, 0x97, | 196 | 145, 144, 143, 142, 141, 140, |
164 | 0xa3, 0x3d, 0x59, 0xa4, 0x08, 0xd9, 0x9e, 0x73, 0xf2, 0x78, 0x00, 0x5b, 0x4b, 0x55, 0xca, 0x43} | 197 | 139}, 61}, /* 199..139 sequence */ |
165 | }, | 198 | {0x85, 0xf8, 0xa2, 0x83, 0xd6, 0x3c, 0x76, 0x8e, 0xea, 0x8f, 0x1c, 0x57, |
166 | { { {41, 35, 190, 132, 225, 108, 214, 174, 82, 144, 73, 241, 241, 187, 233, 235, 179, 166, 219, 60, 135, | 199 | 0x2d, 0x85, 0xb6, 0xff, |
167 | 12, 62, 153, 36, 94, 13, 28, 6, 183, 71, 222, 179, 18, 77, 200, 67, 187, 139, 166, 31, 3, 90, 125, 9, | 200 | 0xd8, 0x33, 0x57, 0x62, 0x1d, 0x37, 0xae, 0x0e, 0xfc, 0x22, 0xd3, 0xd5, |
168 | 56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 19, 13, 137, 10, 28, 219, 174, 50, 32, 154, 80, 238, | 201 | 0x8f, 0x53, 0x21, 0xb7}}, |
169 | 64, 120, 54, 253, 18, 73, 50, 246, 158, 125, 73, 220, 173, 79, 20, 242, 68, 64, 102, 208, 107, 196, | 202 | { { {255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, |
170 | 48, 183, 50, 59, 161, 34, 246, 34, 145, 157, 225, 139, 31, 218, 176, 202, 153, 2, 185, 114, 157, 73, | 203 | 241, 240, 239, 238, 237, 236, |
171 | 44, 128, 126, 197, 153, 213, 233, 128, 178, 234, 201, 204, 83, 191, 103, 214, 191, 20, 214, 126, 45, | 204 | 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, |
172 | 220, 142, 102, 131, 239, 87, 73, 97, 255, 105, 143, 97, 205, 209, 30, 157, 156, 22, 114, 114, 230, | 205 | 221, 220, 219, 218, 217, 216, |
173 | 29, 240, 132, 79, 74, 119, 2, 215, 232, 57, 44, 83, 203, 201, 18, 30, 51, 116, 158, 12, 244, 213, | 206 | 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, |
174 | 212, 159, 212, 164, 89, 126, 53, 207, 50, 34, 244, 204, 207, 211, 144, 45, 72, 211, 143, 117, 230, | 207 | 201, 200, 199, 198, 197, 196, |
175 | 217, 29, 42, 229, 192, 247, 43, 120, 129, 135, 68, 14, 95, 80, 0, 212, 97, 141, 190, 123, 5, 21, 7, | 208 | 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, |
176 | 59, 51, 130, 31, 24, 112, 146, 218, 100, 84, 206, 177, 133, 62, 105, 21, 248, 70, 106, 4, 150, 115, | 209 | 181, 180, 179, 178, 177, 176, |
177 | 14, 217, 22, 47, 103, 104, 212, 247, 74, 74, 208, 87, 104}, 255}, /* pseudo-random data */ | 210 | 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, |
178 | {0x08, 0x7f, 0x86, 0xac, 0xe2, 0x2e, 0x28, 0x56, 0x74, 0x53, 0x4f, 0xc0, 0xfb, 0xb8, 0x79, 0x57, | 211 | 161, 160, 159, 158, 157, 156, |
179 | 0xc5, 0xc8, 0xd1, 0xb7, 0x47, 0xb7, 0xd9, 0xea, 0x97, 0xa8, 0x67, 0xe9, 0x26, 0x93, 0xee, 0xa3} | 212 | 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, |
180 | } | 213 | 141, 140, 139, 138, 137, 136, |
214 | 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, | ||
215 | 121, 120, 119, 118, 117, 116, | ||
216 | 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, | ||
217 | 101, 100, 99, 98, 97, 96, 95, | ||
218 | 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, | ||
219 | 76, 75, 74, 73, 72, 71, 70, | ||
220 | 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, | ||
221 | 51, 50, 49, 48, 47, 46, 45, | ||
222 | 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, | ||
223 | 26, 25, 24, 23, 22, 21, 20, | ||
224 | 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, 255}, /* 255..1 sequence */ | ||
225 | {0x61, 0x86, 0x96, 0xab, 0x3e, 0xaa, 0x0e, 0x64, 0xb2, 0xf7, 0x2d, 0x75, | ||
226 | 0x47, 0x5a, 0x14, 0x97, | ||
227 | 0xa3, 0x3d, 0x59, 0xa4, 0x08, 0xd9, 0x9e, 0x73, 0xf2, 0x78, 0x00, 0x5b, | ||
228 | 0x4b, 0x55, 0xca, 0x43}}, | ||
229 | { { {41, 35, 190, 132, 225, 108, 214, 174, 82, 144, 73, 241, 241, 187, 233, | ||
230 | 235, 179, 166, 219, 60, 135, | ||
231 | 12, 62, 153, 36, 94, 13, 28, 6, 183, 71, 222, 179, 18, 77, 200, 67, 187, | ||
232 | 139, 166, 31, 3, 90, 125, 9, | ||
233 | 56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 19, 13, 137, 10, 28, | ||
234 | 219, 174, 50, 32, 154, 80, 238, | ||
235 | 64, 120, 54, 253, 18, 73, 50, 246, 158, 125, 73, 220, 173, 79, 20, 242, | ||
236 | 68, 64, 102, 208, 107, 196, | ||
237 | 48, 183, 50, 59, 161, 34, 246, 34, 145, 157, 225, 139, 31, 218, 176, 202, | ||
238 | 153, 2, 185, 114, 157, 73, | ||
239 | 44, 128, 126, 197, 153, 213, 233, 128, 178, 234, 201, 204, 83, 191, 103, | ||
240 | 214, 191, 20, 214, 126, 45, | ||
241 | 220, 142, 102, 131, 239, 87, 73, 97, 255, 105, 143, 97, 205, 209, 30, | ||
242 | 157, 156, 22, 114, 114, 230, | ||
243 | 29, 240, 132, 79, 74, 119, 2, 215, 232, 57, 44, 83, 203, 201, 18, 30, 51, | ||
244 | 116, 158, 12, 244, 213, | ||
245 | 212, 159, 212, 164, 89, 126, 53, 207, 50, 34, 244, 204, 207, 211, 144, | ||
246 | 45, 72, 211, 143, 117, 230, | ||
247 | 217, 29, 42, 229, 192, 247, 43, 120, 129, 135, 68, 14, 95, 80, 0, 212, | ||
248 | 97, 141, 190, 123, 5, 21, 7, | ||
249 | 59, 51, 130, 31, 24, 112, 146, 218, 100, 84, 206, 177, 133, 62, 105, 21, | ||
250 | 248, 70, 106, 4, 150, 115, | ||
251 | 14, 217, 22, 47, 103, 104, 212, 247, 74, 74, 208, 87, 104}, 255}, /* pseudo-random data */ | ||
252 | {0x08, 0x7f, 0x86, 0xac, 0xe2, 0x2e, 0x28, 0x56, 0x74, 0x53, 0x4f, 0xc0, | ||
253 | 0xfb, 0xb8, 0x79, 0x57, | ||
254 | 0xc5, 0xc8, 0xd1, 0xb7, 0x47, 0xb7, 0xd9, 0xea, 0x97, 0xa8, 0x67, 0xe9, | ||
255 | 0x26, 0x93, 0xee, 0xa3}} | ||
181 | }; | 256 | }; |
182 | 257 | ||
183 | static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]); | 258 | static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]); |
@@ -196,17 +271,17 @@ static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]); | |||
196 | */ | 271 | */ |
197 | static void | 272 | static void |
198 | bin2hex (const uint8_t *bin, | 273 | bin2hex (const uint8_t *bin, |
199 | size_t len, | 274 | size_t len, |
200 | char *hex) | 275 | char *hex) |
201 | { | 276 | { |
202 | while (len-- > 0) | 277 | while (len-- > 0) |
203 | { | 278 | { |
204 | unsigned int b1, b2; | 279 | unsigned int b1, b2; |
205 | b1 = (*bin >> 4) & 0xf; | 280 | b1 = (*bin >> 4) & 0xf; |
206 | *hex++ = (char)((b1 > 9) ? (b1 + 'A' - 10) : (b1 + '0')); | 281 | *hex++ = (char) ((b1 > 9) ? (b1 + 'A' - 10) : (b1 + '0')); |
207 | b2 = *bin++ & 0xf; | 282 | b2 = *bin++ & 0xf; |
208 | *hex++ = (char)((b2 > 9) ? (b2 + 'A' - 10) : (b2 + '0')); | 283 | *hex++ = (char) ((b2 > 9) ? (b2 + 'A' - 10) : (b2 + '0')); |
209 | } | 284 | } |
210 | *hex = 0; | 285 | *hex = 0; |
211 | } | 286 | } |
212 | 287 | ||
@@ -216,26 +291,28 @@ check_result (const char *test_name, | |||
216 | const uint8_t calcualted[SHA256_DIGEST_SIZE], | 291 | const uint8_t calcualted[SHA256_DIGEST_SIZE], |
217 | const uint8_t expected[SHA256_DIGEST_SIZE]) | 292 | const uint8_t expected[SHA256_DIGEST_SIZE]) |
218 | { | 293 | { |
219 | int failed = memcmp(calcualted, expected, SHA256_DIGEST_SIZE); | 294 | int failed = memcmp (calcualted, expected, SHA256_DIGEST_SIZE); |
220 | check_num++; /* Print 1-based numbers */ | 295 | check_num++; /* Print 1-based numbers */ |
221 | if (failed) | 296 | if (failed) |
222 | { | 297 | { |
223 | char calc_str[SHA256_DIGEST_STRING_SIZE]; | 298 | char calc_str[SHA256_DIGEST_STRING_SIZE]; |
224 | char expc_str[SHA256_DIGEST_STRING_SIZE]; | 299 | char expc_str[SHA256_DIGEST_STRING_SIZE]; |
225 | bin2hex(calcualted, SHA256_DIGEST_SIZE, calc_str); | 300 | bin2hex (calcualted, SHA256_DIGEST_SIZE, calc_str); |
226 | bin2hex(expected, SHA256_DIGEST_SIZE, expc_str); | 301 | bin2hex (expected, SHA256_DIGEST_SIZE, expc_str); |
227 | fprintf (stderr, "FAILED: %s check %u: calculated digest %s, expected digest %s.\n", | 302 | fprintf (stderr, |
228 | test_name, check_num, calc_str, expc_str); | 303 | "FAILED: %s check %u: calculated digest %s, expected digest %s.\n", |
229 | fflush (stderr); | 304 | test_name, check_num, calc_str, expc_str); |
230 | } | 305 | fflush (stderr); |
306 | } | ||
231 | else if (verbose) | 307 | else if (verbose) |
232 | { | 308 | { |
233 | char calc_str[SHA256_DIGEST_STRING_SIZE]; | 309 | char calc_str[SHA256_DIGEST_STRING_SIZE]; |
234 | bin2hex(calcualted, SHA256_DIGEST_SIZE, calc_str); | 310 | bin2hex (calcualted, SHA256_DIGEST_SIZE, calc_str); |
235 | printf ("PASSED: %s check %u: calculated digest %s match expected digest.\n", | 311 | printf ( |
236 | test_name, check_num, calc_str); | 312 | "PASSED: %s check %u: calculated digest %s match expected digest.\n", |
237 | fflush (stdout); | 313 | test_name, check_num, calc_str); |
238 | } | 314 | fflush (stdout); |
315 | } | ||
239 | return failed ? 1 : 0; | 316 | return failed ? 1 : 0; |
240 | } | 317 | } |
241 | 318 | ||
@@ -245,91 +322,111 @@ check_result (const char *test_name, | |||
245 | */ | 322 | */ |
246 | 323 | ||
247 | /* Calculated SHA-256 as one pass for whole data */ | 324 | /* Calculated SHA-256 as one pass for whole data */ |
248 | int test1_str(void) | 325 | static int |
326 | test1_str (void) | ||
249 | { | 327 | { |
250 | int num_failed = 0; | 328 | int num_failed = 0; |
251 | for (unsigned int i = 0; i < units1_num; i++) | 329 | unsigned int i; |
252 | { | 330 | |
253 | struct sha256_ctx ctx; | 331 | for (i = 0; i < units1_num; i++) |
254 | uint8_t digest[SHA256_DIGEST_SIZE]; | 332 | { |
255 | 333 | struct sha256_ctx ctx; | |
256 | MHD_SHA256_init (&ctx); | 334 | uint8_t digest[SHA256_DIGEST_SIZE]; |
257 | MHD_SHA256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str, data_units1[i].str_l.len); | 335 | |
258 | sha256_finish (&ctx, digest); | 336 | MHD_SHA256_init (&ctx); |
259 | num_failed += check_result (__FUNCTION__, i, digest, | 337 | MHD_SHA256_update (&ctx, (const uint8_t*) data_units1[i].str_l.str, |
260 | data_units1[i].digest); | 338 | data_units1[i].str_l.len); |
261 | } | 339 | sha256_finish (&ctx, digest); |
340 | num_failed += check_result (__FUNCTION__, i, digest, | ||
341 | data_units1[i].digest); | ||
342 | } | ||
262 | return num_failed; | 343 | return num_failed; |
263 | } | 344 | } |
264 | 345 | ||
265 | int test1_bin(void) | 346 | |
347 | static int | ||
348 | test1_bin (void) | ||
266 | { | 349 | { |
267 | int num_failed = 0; | 350 | int num_failed = 0; |
268 | for (unsigned int i = 0; i < units2_num; i++) | 351 | unsigned int i; |
269 | { | 352 | |
270 | struct sha256_ctx ctx; | 353 | for (i = 0; i < units2_num; i++) |
271 | uint8_t digest[SHA256_DIGEST_SIZE]; | 354 | { |
272 | 355 | struct sha256_ctx ctx; | |
273 | MHD_SHA256_init (&ctx); | 356 | uint8_t digest[SHA256_DIGEST_SIZE]; |
274 | MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); | 357 | |
275 | sha256_finish (&ctx, digest); | 358 | MHD_SHA256_init (&ctx); |
276 | num_failed += check_result (__FUNCTION__, i, digest, | 359 | MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin, |
277 | data_units2[i].digest); | 360 | data_units2[i].bin_l.len); |
278 | } | 361 | sha256_finish (&ctx, digest); |
362 | num_failed += check_result (__FUNCTION__, i, digest, | ||
363 | data_units2[i].digest); | ||
364 | } | ||
279 | return num_failed; | 365 | return num_failed; |
280 | } | 366 | } |
281 | 367 | ||
282 | /* Calculated SHA-256 as two iterations for whole data */ | 368 | /* Calculated SHA-256 as two iterations for whole data */ |
283 | int test2_str(void) | 369 | static int |
370 | test2_str (void) | ||
284 | { | 371 | { |
285 | int num_failed = 0; | 372 | int num_failed = 0; |
286 | for (unsigned int i = 0; i < units1_num; i++) | 373 | unsigned int i; |
287 | { | 374 | |
288 | struct sha256_ctx ctx; | 375 | for (i = 0; i < units1_num; i++) |
289 | uint8_t digest[SHA256_DIGEST_SIZE]; | 376 | { |
290 | size_t part_s = data_units1[i].str_l.len / 4; | 377 | struct sha256_ctx ctx; |
291 | 378 | uint8_t digest[SHA256_DIGEST_SIZE]; | |
292 | MHD_SHA256_init (&ctx); | 379 | size_t part_s = data_units1[i].str_l.len / 4; |
293 | MHD_SHA256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str, part_s); | 380 | |
294 | MHD_SHA256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); | 381 | MHD_SHA256_init (&ctx); |
295 | sha256_finish (&ctx, digest); | 382 | MHD_SHA256_update (&ctx, (const uint8_t*) data_units1[i].str_l.str, part_s); |
296 | num_failed += check_result (__FUNCTION__, i, digest, | 383 | MHD_SHA256_update (&ctx, (const uint8_t*) data_units1[i].str_l.str + part_s, |
297 | data_units1[i].digest); | 384 | data_units1[i].str_l.len - part_s); |
298 | } | 385 | sha256_finish (&ctx, digest); |
386 | num_failed += check_result (__FUNCTION__, i, digest, | ||
387 | data_units1[i].digest); | ||
388 | } | ||
299 | return num_failed; | 389 | return num_failed; |
300 | } | 390 | } |
301 | 391 | ||
302 | int test2_bin(void) | 392 | |
393 | static int | ||
394 | test2_bin (void) | ||
303 | { | 395 | { |
304 | int num_failed = 0; | 396 | int num_failed = 0; |
305 | for (unsigned int i = 0; i < units2_num; i++) | 397 | unsigned int i; |
306 | { | 398 | |
307 | struct sha256_ctx ctx; | 399 | for (i = 0; i < units2_num; i++) |
308 | uint8_t digest[SHA256_DIGEST_SIZE]; | 400 | { |
309 | size_t part_s = data_units2[i].bin_l.len * 2 / 3; | 401 | struct sha256_ctx ctx; |
310 | 402 | uint8_t digest[SHA256_DIGEST_SIZE]; | |
311 | MHD_SHA256_init (&ctx); | 403 | size_t part_s = data_units2[i].bin_l.len * 2 / 3; |
312 | MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin, part_s); | 404 | |
313 | MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); | 405 | MHD_SHA256_init (&ctx); |
314 | sha256_finish (&ctx, digest); | 406 | MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin, part_s); |
315 | num_failed += check_result (__FUNCTION__, i, digest, | 407 | MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin + part_s, |
316 | data_units2[i].digest); | 408 | data_units2[i].bin_l.len - part_s); |
317 | } | 409 | sha256_finish (&ctx, digest); |
410 | num_failed += check_result (__FUNCTION__, i, digest, | ||
411 | data_units2[i].digest); | ||
412 | } | ||
318 | return num_failed; | 413 | return num_failed; |
319 | } | 414 | } |
320 | 415 | ||
321 | int main(int argc, char * argv[]) | 416 | |
417 | int | ||
418 | main (int argc, char *argv[]) | ||
322 | { | 419 | { |
323 | int num_failed = 0; | 420 | int num_failed = 0; |
324 | (void)has_in_name; /* Mute compiler warning. */ | 421 | (void) has_in_name; /* Mute compiler warning. */ |
325 | if (has_param(argc, argv, "-v") || has_param(argc, argv, "--verbose")) | 422 | if (has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose")) |
326 | verbose = 1; | 423 | verbose = 1; |
327 | 424 | ||
328 | num_failed += test1_str(); | 425 | num_failed += test1_str (); |
329 | num_failed += test1_bin(); | 426 | num_failed += test1_bin (); |
330 | 427 | ||
331 | num_failed += test2_str(); | 428 | num_failed += test2_str (); |
332 | num_failed += test2_bin(); | 429 | num_failed += test2_bin (); |
333 | 430 | ||
334 | return num_failed ? 1 : 0; | 431 | return num_failed ? 1 : 0; |
335 | } | 432 | } |