From 8aedb1c3e7aeb3193b48ba8f6354f31435bc6105 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 10 May 2018 21:31:01 +0100 Subject: [PATCH] rimage: openssl: fix build for openssl 1.1.0 Openssl 1.1.0 is latest stable version with minor API differences. Signed-off-by: Liam Girdwood --- rimage/hash.c | 4 ++-- rimage/pkcs1_5.c | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rimage/hash.c b/rimage/hash.c index d586e07fc..2905d893d 100644 --- a/rimage/hash.c +++ b/rimage/hash.c @@ -35,7 +35,7 @@ void module_sha256_create(struct image *image) { image->md = EVP_sha256(); - image->mdctx = EVP_MD_CTX_create(); + image->mdctx = EVP_MD_CTX_new(); EVP_DigestInit_ex(image->mdctx, image->md, NULL); } @@ -53,7 +53,7 @@ void module_sha256_complete(struct image *image, uint8_t *hash) int i; #endif EVP_DigestFinal_ex(image->mdctx, md_value, &md_len); - EVP_MD_CTX_destroy(image->mdctx); + EVP_MD_CTX_free(image->mdctx); memcpy(hash, md_value, md_len); #if DEBUG_HASH diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c index 64a4b2500..7df531bff 100644 --- a/rimage/pkcs1_5.c +++ b/rimage/pkcs1_5.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,7 @@ int pkcs_sign(struct image *image, struct fw_image_manifest *man, RSA *priv_rsa = NULL; EVP_PKEY *privkey; FILE *fp; + const BIGNUM *n, *e, *d; unsigned char digest[SHA256_DIGEST_LENGTH], mod[MAN_RSA_KEY_MODULUS_LEN]; unsigned int siglen = MAN_RSA_SIGNATURE_LEN; char path[256]; @@ -114,8 +116,9 @@ int pkcs_sign(struct image *image, struct fw_image_manifest *man, fprintf(stderr, "error: failed to sign manifest\n"); /* copy public key modulus and exponent to manifest */ - BN_bn2bin(priv_rsa->n, mod); - BN_bn2bin(priv_rsa->e, (unsigned char *)man->css.exponent); + RSA_get0_key(priv_rsa, &n, &e, &d); + BN_bn2bin(n, mod); + BN_bn2bin(e, (unsigned char *)man->css.exponent); /* modulus is reveresd */ for (i = 0; i < MAN_RSA_KEY_MODULUS_LEN; i++)