|
|
|
@ -82,7 +82,7 @@ static X509 *X509_find_cert_by_common_name(const char *path, const char *name) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int verify(const char *image, const char *digest_name, EVP_PKEY *key, |
|
|
|
|
unsigned char *sig, size_t sig_len) |
|
|
|
|
struct rots_sig_hdr *sig_hdr, unsigned char *sig, size_t sig_len) |
|
|
|
|
{ |
|
|
|
|
char data[512]; |
|
|
|
|
struct rots_hdr hdr; |
|
|
|
@ -101,7 +101,8 @@ static int verify(const char *image, const char *digest_name, EVP_PKEY *key, |
|
|
|
|
if (rots_read_hdr(fp, &hdr) < 0) |
|
|
|
|
goto err_close_image; |
|
|
|
|
|
|
|
|
|
size = hdr.size; |
|
|
|
|
size = hdr.size + ftell(fp); |
|
|
|
|
fseek(fp, 0, SEEK_SET); |
|
|
|
|
|
|
|
|
|
if (!(ctx = EVP_MD_CTX_create())) |
|
|
|
|
goto err_close_image; |
|
|
|
@ -124,6 +125,10 @@ static int verify(const char *image, const char *digest_name, EVP_PKEY *key, |
|
|
|
|
size -= nbytes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(EVP_DigestVerifyUpdate(ctx, &sig_hdr->timestamp, |
|
|
|
|
sizeof sig_hdr->timestamp))) |
|
|
|
|
goto err_destroy_ctx; |
|
|
|
|
|
|
|
|
|
if (EVP_DigestVerifyFinal(ctx, sig, sig_len) == 1) { |
|
|
|
|
ret = 0; |
|
|
|
|
} else { |
|
|
|
@ -195,7 +200,7 @@ static int verify_all(size_t *count, size_t *total, const char *ca_path, const c |
|
|
|
|
goto err_close_image; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ret = verify(image, sig_hdr.digest, key, sig, sig_hdr.size); |
|
|
|
|
ret = verify(image, sig_hdr.digest, key, &sig_hdr, sig, sig_hdr.size); |
|
|
|
|
free(sig); |
|
|
|
|
|
|
|
|
|
if (ret == 0) |
|
|
|
|