VBoot Reference: Refactor Part 2 - Crypto Libraries

Removing multiple top level includes - now padding.h, rsa.h and sha.h are used internally and cryptolib.h must be used instead for all modules that wish to use crypto functions.

I am trying to separate refactors involving code movement from one file to another, and the movement of files themselves into separate CLs so that it's clear what changed.

Review URL: http://codereview.chromium.org/1574005
This commit is contained in:
Gaurav Shah
2010-03-30 23:08:10 -07:00
parent ed9c96a7aa
commit d46c347018
42 changed files with 234 additions and 255 deletions

View File

@@ -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";