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 "sha.h" | 12 #include "cryptolib.h" |
13 | |
14 #include "sha_test_vectors.h" | 13 #include "sha_test_vectors.h" |
15 | 14 |
16 int SHA1_tests(void) { | 15 int SHA1_tests(void) { |
17 int i, success = 1; | 16 int i, success = 1; |
18 uint8_t sha1_digest[SHA1_DIGEST_SIZE]; | 17 uint8_t sha1_digest[SHA1_DIGEST_SIZE]; |
19 uint8_t* test_inputs[3]; | 18 uint8_t* test_inputs[3]; |
20 test_inputs[0] = (uint8_t *) oneblock_msg; | 19 test_inputs[0] = (uint8_t *) oneblock_msg; |
21 test_inputs[1] = (uint8_t *) multiblock_msg1; | 20 test_inputs[1] = (uint8_t *) multiblock_msg1; |
22 test_inputs[2] = (uint8_t *) long_msg; | 21 test_inputs[2] = (uint8_t *) long_msg; |
23 | 22 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 success = 0; | 89 success = 0; |
91 if (!SHA256_tests()) | 90 if (!SHA256_tests()) |
92 success = 0; | 91 success = 0; |
93 if (!SHA512_tests()) | 92 if (!SHA512_tests()) |
94 success = 0; | 93 success = 0; |
95 | 94 |
96 free(long_msg); | 95 free(long_msg); |
97 | 96 |
98 return !success; | 97 return !success; |
99 } | 98 } |
OLD | NEW |