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 <liam.r.girdwood@linux.intel.com>
This commit is contained in:
Liam Girdwood 2018-05-10 21:31:01 +01:00
parent 28bddadbd3
commit 6c96fd34fa
2 changed files with 7 additions and 4 deletions

View File

@ -35,7 +35,7 @@
void module_sha256_create(struct image *image) void module_sha256_create(struct image *image)
{ {
image->md = EVP_sha256(); image->md = EVP_sha256();
image->mdctx = EVP_MD_CTX_create(); image->mdctx = EVP_MD_CTX_new();
EVP_DigestInit_ex(image->mdctx, image->md, NULL); EVP_DigestInit_ex(image->mdctx, image->md, NULL);
} }
@ -53,7 +53,7 @@ void module_sha256_complete(struct image *image, uint8_t *hash)
int i; int i;
#endif #endif
EVP_DigestFinal_ex(image->mdctx, md_value, &md_len); 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); memcpy(hash, md_value, md_len);
#if DEBUG_HASH #if DEBUG_HASH

View File

@ -21,6 +21,7 @@
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/bn.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
@ -56,6 +57,7 @@ int pkcs_sign(struct image *image, struct fw_image_manifest *man,
RSA *priv_rsa = NULL; RSA *priv_rsa = NULL;
EVP_PKEY *privkey; EVP_PKEY *privkey;
FILE *fp; FILE *fp;
const BIGNUM *n, *e, *d;
unsigned char digest[SHA256_DIGEST_LENGTH], mod[MAN_RSA_KEY_MODULUS_LEN]; unsigned char digest[SHA256_DIGEST_LENGTH], mod[MAN_RSA_KEY_MODULUS_LEN];
unsigned int siglen = MAN_RSA_SIGNATURE_LEN; unsigned int siglen = MAN_RSA_SIGNATURE_LEN;
char path[256]; 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"); fprintf(stderr, "error: failed to sign manifest\n");
/* copy public key modulus and exponent to manifest */ /* copy public key modulus and exponent to manifest */
BN_bn2bin(priv_rsa->n, mod); RSA_get0_key(priv_rsa, &n, &e, &d);
BN_bn2bin(priv_rsa->e, (unsigned char *)man->css.exponent); BN_bn2bin(n, mod);
BN_bn2bin(e, (unsigned char *)man->css.exponent);
/* modulus is reveresd */ /* modulus is reveresd */
for (i = 0; i < MAN_RSA_KEY_MODULUS_LEN; i++) for (i = 0; i < MAN_RSA_KEY_MODULUS_LEN; i++)