Assignment 7 #4

Merged
saschato merged 75 commits from Assignment-7 into master 2024-07-08 11:19:51 +02:00
Showing only changes of commit 3d6c886561 - Show all commits

View file

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