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> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 fprintf(stderr, "Couldn't read key into a buffer.\n"); | 44 fprintf(stderr, "Couldn't read key into a buffer.\n"); |
45 return NULL; | 45 return NULL; |
46 } | 46 } |
47 | 47 |
48 close(fd); | 48 close(fd); |
49 return buf; | 49 return buf; |
50 } | 50 } |
51 | 51 |
52 RSAPublicKey* RSAPublicKeyFromFile(const char* input_file) { | 52 RSAPublicKey* RSAPublicKeyFromFile(const char* input_file) { |
53 uint32_t len; | 53 uint32_t len; |
54 RSAPublicKey* key; | 54 RSAPublicKey* key = NULL; |
55 uint8_t* buf = BufferFromFile(input_file, &len); | 55 uint8_t* buf = BufferFromFile(input_file, &len); |
56 if (buf) | 56 if (buf) |
57 key = RSAPublicKeyFromBuf(buf, len); | 57 key = RSAPublicKeyFromBuf(buf, len); |
58 Free(buf); | 58 Free(buf); |
59 return key; | 59 return key; |
60 } | 60 } |
61 | 61 |
62 uint8_t* SignatureFile(const char* input_file, const char* key_file, | 62 uint8_t* SignatureFile(const char* input_file, const char* key_file, |
63 int algorithm) { | 63 int algorithm) { |
64 char* sign_utility = "./sign_data.sh"; | 64 char* sign_utility = "./sign_data.sh"; |
(...skipping 25 matching lines...) Expand all Loading... |
90 if (fread(signature, signature_size, 1, cmd_out) != 1) { | 90 if (fread(signature, signature_size, 1, cmd_out) != 1) { |
91 fprintf(stderr, "Couldn't read signature.\n"); | 91 fprintf(stderr, "Couldn't read signature.\n"); |
92 pclose(cmd_out); | 92 pclose(cmd_out); |
93 Free(signature); | 93 Free(signature); |
94 return NULL; | 94 return NULL; |
95 } | 95 } |
96 | 96 |
97 pclose(cmd_out); | 97 pclose(cmd_out); |
98 return signature; | 98 return signature; |
99 } | 99 } |
OLD | NEW |