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

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

Issue 1585007: combined patch for: (Closed)
Patch Set: Created 10 years, 9 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
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 84383514d8d7d54ca57a8de7b92c790d6beef7a8..275ca6b7cf25f65db06862136586de9569dfc30d 100644
--- a/src/platform/vboot_reference/utils/file_keys.c
+++ b/src/platform/vboot_reference/utils/file_keys.c
@@ -15,8 +15,7 @@
#include <sys/types.h>
#include <unistd.h>
-#include "padding.h"
-#include "rsa_utility.h"
+#include "cryptolib.h"
#include "signature_digest.h"
#include "utility.h"
@@ -60,6 +59,27 @@ RSAPublicKey* RSAPublicKeyFromFile(const char* input_file) {
return key;
}
+uint8_t* DigestFile(char* input_file, int sig_algorithm) {
+ int input_fd, len;
+ uint8_t data[SHA1_BLOCK_SIZE];
+ uint8_t* digest = NULL;
+ DigestContext ctx;
+
+ if( (input_fd = open(input_file, O_RDONLY)) == -1 ) {
+ debug("Couldn't open input file.\n");
+ return NULL;
+ }
+ DigestInit(&ctx, sig_algorithm);
+ while ( (len = read(input_fd, data, SHA1_BLOCK_SIZE)) ==
+ SHA1_BLOCK_SIZE)
+ DigestUpdate(&ctx, data, len);
+ if (len != -1)
+ DigestUpdate(&ctx, data, len);
+ digest = DigestFinal(&ctx);
+ close(input_fd);
+ return digest;
+}
+
uint8_t* SignatureFile(const char* input_file, const char* key_file,
int algorithm) {
char* sign_utility = "./sign_data.sh";
« no previous file with comments | « src/platform/vboot_reference/tests/test_common.c ('k') | src/platform/vboot_reference/utils/firmware_image.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698