| 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 * Utility functions for file and key handling. | 5 * Utility functions for file and key handling. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "file_keys.h" | 8 #include "file_keys.h" |
| 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 "padding.h" | 18 #include "padding.h" |
| 19 #include "rsa_utility.h" | 19 #include "rsa_utility.h" |
| 20 #include "signature_digest.h" |
| 20 #include "utility.h" | 21 #include "utility.h" |
| 21 | 22 |
| 22 uint8_t* BufferFromFile(const char* input_file, uint32_t* len) { | 23 uint8_t* BufferFromFile(const char* input_file, uint32_t* len) { |
| 23 int fd; | 24 int fd; |
| 24 struct stat stat_fd; | 25 struct stat stat_fd; |
| 25 uint8_t* buf = NULL; | 26 uint8_t* buf = NULL; |
| 26 | 27 |
| 27 if ((fd = open(input_file, O_RDONLY)) == -1) { | 28 if ((fd = open(input_file, O_RDONLY)) == -1) { |
| 28 fprintf(stderr, "Couldn't open file.\n"); | 29 fprintf(stderr, "Couldn't open file.\n"); |
| 29 return NULL; | 30 return NULL; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (fread(signature, signature_size, 1, cmd_out) != 1) { | 91 if (fread(signature, signature_size, 1, cmd_out) != 1) { |
| 91 fprintf(stderr, "Couldn't read signature.\n"); | 92 fprintf(stderr, "Couldn't read signature.\n"); |
| 92 pclose(cmd_out); | 93 pclose(cmd_out); |
| 93 Free(signature); | 94 Free(signature); |
| 94 return NULL; | 95 return NULL; |
| 95 } | 96 } |
| 96 | 97 |
| 97 pclose(cmd_out); | 98 pclose(cmd_out); |
| 98 return signature; | 99 return signature; |
| 99 } | 100 } |
| OLD | NEW |