OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS 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 | 5 |
6 /* FIPS 180-2 Tests for message digest functions. */ | 6 /* FIPS 180-2 Tests for message digest functions. */ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
11 | 11 |
12 #include "cryptolib.h" | 12 #include "sha.h" |
| 13 |
13 #include "sha_test_vectors.h" | 14 #include "sha_test_vectors.h" |
14 | 15 |
15 int SHA1_tests(void) { | 16 int SHA1_tests(void) { |
16 int i, success = 1; | 17 int i, success = 1; |
17 uint8_t sha1_digest[SHA1_DIGEST_SIZE]; | 18 uint8_t sha1_digest[SHA1_DIGEST_SIZE]; |
18 uint8_t* test_inputs[3]; | 19 uint8_t* test_inputs[3]; |
19 test_inputs[0] = (uint8_t *) oneblock_msg; | 20 test_inputs[0] = (uint8_t *) oneblock_msg; |
20 test_inputs[1] = (uint8_t *) multiblock_msg1; | 21 test_inputs[1] = (uint8_t *) multiblock_msg1; |
21 test_inputs[2] = (uint8_t *) long_msg; | 22 test_inputs[2] = (uint8_t *) long_msg; |
22 | 23 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 success = 0; | 90 success = 0; |
90 if (!SHA256_tests()) | 91 if (!SHA256_tests()) |
91 success = 0; | 92 success = 0; |
92 if (!SHA512_tests()) | 93 if (!SHA512_tests()) |
93 success = 0; | 94 success = 0; |
94 | 95 |
95 free(long_msg); | 96 free(long_msg); |
96 | 97 |
97 return !success; | 98 return !success; |
98 } | 99 } |
OLD | NEW |