| 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 /* Routines for verifying a file's signature. Useful in testing the core | 6 /* Routines for verifying a file's signature. Useful in testing the core |
| 7 * RSA verification implementation. | 7 * RSA verification implementation. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <stdlib.h> | 12 #include <stdlib.h> |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 #include <sys/stat.h> | 14 #include <sys/stat.h> |
| 15 #include <sys/types.h> | 15 #include <sys/types.h> |
| 16 #include <unistd.h> | 16 #include <unistd.h> |
| 17 | 17 |
| 18 #include "cryptolib.h" | 18 #include "cryptolib.h" |
| 19 #include "file_keys.h" | 19 #include "file_keys.h" |
| 20 #include "verify_data.h" | 20 #include "verify_data.h" |
| 21 | 21 |
| 22 /* ANSI Color coding sequences. */ | 22 /* ANSI Color coding sequences. */ |
| 23 #define COL_GREEN "\e[1;32m" | 23 #define COL_GREEN "\e[1;32m" |
| 24 #define COL_RED "\e[0;31m]" | 24 #define COL_RED "\e[0;31m" |
| 25 #define COL_STOP "\e[m" | 25 #define COL_STOP "\e[m" |
| 26 | 26 |
| 27 uint8_t* read_signature(char* input_file, int len) { | 27 uint8_t* read_signature(char* input_file, int len) { |
| 28 int i, sigfd; | 28 int i, sigfd; |
| 29 uint8_t* signature = NULL; | 29 uint8_t* signature = NULL; |
| 30 if ((sigfd = open(input_file, O_RDONLY)) == -1) { | 30 if ((sigfd = open(input_file, O_RDONLY)) == -1) { |
| 31 fprintf(stderr, "Couldn't open signature file\n"); | 31 fprintf(stderr, "Couldn't open signature file\n"); |
| 32 return NULL; | 32 return NULL; |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 else | 87 else |
| 88 return_code = -1; | 88 return_code = -1; |
| 89 | 89 |
| 90 free(key); | 90 free(key); |
| 91 free(signature); | 91 free(signature); |
| 92 free(digest); | 92 free(digest); |
| 93 | 93 |
| 94 return return_code; | 94 return return_code; |
| 95 } | 95 } |
| OLD | NEW |