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

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

Issue 669040: Fix RSA verification test. (Closed)
Patch Set: "" 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/vboot_reference/utils/signature_digest_utility.c
diff --git a/src/platform/vboot_reference/utils/signature_digest_utility.c b/src/platform/vboot_reference/utils/signature_digest_utility.c
new file mode 100644
index 0000000000000000000000000000000000000000..b1f6dde9ddecc609cb3abfaec31761b1bbb97a34
--- /dev/null
+++ b/src/platform/vboot_reference/utils/signature_digest_utility.c
@@ -0,0 +1,54 @@
+/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Utility that outputs the cryptographic digest of a contents of a
+ * file in a format that can be directly used to generate PKCS#1 v1.5
+ * signatures via the "openssl" command line utility.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "file_keys.h"
+#include "padding.h"
+#include "signature_digest.h"
+#include "utility.h"
+
+int main(int argc, char* argv[]) {
+ int algorithm = -1;
+ int error_code = 0;
+ uint8_t* buf = NULL;
+ uint8_t* signature_digest = NULL;
+ uint32_t len;
+ uint32_t signature_digest_len;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: %s <algoid> <file>", argv[0]);
+ return -1;
+ }
+ algorithm = atoi(argv[1]);
+ if (algorithm < 0 || algorithm >= kNumAlgorithms) {
+ fprintf(stderr, "Invalid Algorithm!\n");
+ return -1;
+ }
+
+ buf = BufferFromFile(argv[2], &len);
+ if (!buf) {
+ fprintf(stderr, "Could read file: %s\n", argv[2]);
+ return -1;
+ }
+
+ signature_digest = SignatureDigest(buf, len, algorithm);
+ signature_digest_len = (hash_size_map[algorithm] +
+ digestinfo_size_map[algorithm]);
+ if (!signature_digest)
+ error_code = -1;
+ if(signature_digest &&
+ 1 != fwrite(signature_digest, signature_digest_len, 1, stdout))
+ error_code = -1;
+ Free(signature_digest);
+ Free(buf);
+ return error_code;
+}
« no previous file with comments | « src/platform/vboot_reference/utils/Makefile ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698