Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(990)

Unified Diff: src/platform/vboot_reference/utils/file_keys.c

Issue 650105: Vboot Reference: Add the "real" reference firmware verification function (VerifyFirmware). (Closed)
Patch Set: Review fixes. Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform/vboot_reference/utils/Makefile ('k') | src/platform/vboot_reference/utils/firmware_image.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/vboot_reference/utils/file_keys.c
diff --git a/src/platform/vboot_reference/utils/file_keys.c b/src/platform/vboot_reference/utils/file_keys.c
index 8a8a2cb2c0f1b605d8236e4ecb98b12f69d147f7..bcba749a4bb92c1d629959db629a3138d5d07453 100644
--- a/src/platform/vboot_reference/utils/file_keys.c
+++ b/src/platform/vboot_reference/utils/file_keys.c
@@ -15,6 +15,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include "padding.h"
#include "rsa_utility.h"
#include "utility.h"
@@ -55,3 +56,41 @@ RSAPublicKey* RSAPublicKeyFromFile(char* input_file) {
Free(buf);
return key;
}
+
+uint8_t* SignatureFile(char* input_file, char* key_file, int algorithm) {
+ char* sign_utility = "./sign_data.sh";
+ char* cmd; /* Command line to invoke. */
+ int cmd_len;
+ FILE* cmd_out; /* File descriptor to command output. */
+ uint8_t* signature = NULL;
+ int signature_size = siglen_map[algorithm] * sizeof(uint32_t);
+
+ /* Build command line:
+ * sign_data.sh <algorithm> <key file> <input file>
+ */
+ cmd_len = (strlen(sign_utility) + 1 + /* +1 for space. */
+ 2 + 1 + /* For [algorithm]. */
+ strlen(key_file) + 1 + /* +1 for space. */
+ strlen(input_file) +
+ 1); /* For the trailing '\0'. */
+ cmd = (char*) Malloc(cmd_len);
+ snprintf(cmd, cmd_len, "%s %d %s %s", sign_utility, algorithm, key_file,
+ input_file);
+ cmd_out = popen(cmd, "r");
+ Free(cmd);
+ if (!cmd_out) {
+ fprintf(stderr, "Couldn't execute: %s\n", cmd);
+ return NULL;
+ }
+
+ signature = (uint8_t*) Malloc(signature_size);
+ if (fread(signature, signature_size, 1, cmd_out) != 1) {
+ fprintf(stderr, "Couldn't read signature.\n");
+ pclose(cmd_out);
+ Free(signature);
+ return NULL;
+ }
+
+ pclose(cmd_out);
+ return signature;
+}
« no previous file with comments | « src/platform/vboot_reference/utils/Makefile ('k') | src/platform/vboot_reference/utils/firmware_image.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698