Assignment-7-sgximpl #13
1 changed files with 4 additions and 5 deletions
|
@ -21,9 +21,9 @@ typedef struct {
|
||||||
uint8_t *public_key_path;
|
uint8_t *public_key_path;
|
||||||
} embedded_device_args;
|
} embedded_device_args;
|
||||||
|
|
||||||
static EVP_PKEY *read_public_key(uint8_t *public_key_file, EVP_PKEY **key) {
|
static EVP_PKEY *read_public_key(uint8_t *public_key_file_path, EVP_PKEY **key) {
|
||||||
if(public_key_file == NULL) {
|
if(public_key_file == NULL) {
|
||||||
fprintf(stderr, "public_key_file is a null pointer!\n");
|
fprintf(stderr, "public_key_file_path is a null pointer!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,14 +100,13 @@ int main(int argc, char **argv) {
|
||||||
uint8_t signature[BUFSIZE] = {0};
|
uint8_t signature[BUFSIZE] = {0};
|
||||||
size_t signature_size = read(0, signature, BUFSIZE);
|
size_t signature_size = read(0, signature, BUFSIZE);
|
||||||
if(signature_size < 70) {
|
if(signature_size < 70) {
|
||||||
printf("failed to read firmware signature\n");
|
fprintf(stderr, "failed to read firmware signature\n");
|
||||||
goto clean;
|
goto clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_firmware(args.firmware_path, &ctx);
|
hash_firmware(args.firmware_path, &ctx);
|
||||||
if (EVP_DigestVerifyFinal(ctx, signature, signature_size) != 1) {
|
if (EVP_DigestVerifyFinal(ctx, signature, signature_size) != 1) {
|
||||||
printf("failed to verify firmware signature\n");
|
fprintf(stderr, "failed to verify firmware signature\n");
|
||||||
goto clean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clean: ;
|
clean: ;
|
||||||
|
|
Loading…
Reference in a new issue