summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2023-05-02 14:26:04 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-05-02 14:26:06 +0200
commit6b4cc1c00883d160173357d14d422d1d63581279 (patch)
treef2348963d0fae31d199a95859283edd9f3e43c03
parent845be5523893e02d8b03f7aa6c4346005c13d377 (diff)
downloadbarebox-6b4cc1c00883d160173357d14d422d1d63581279.tar.gz
scripts: rkimage: Use non-deprecated functions for sha256/512
SHA256_Init() and SHA512_Init() are deprecated since OpensSSL 3.0. Use EVP functions instead to calculate hashes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--scripts/rkimage.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/scripts/rkimage.c b/scripts/rkimage.c
index 6e68d508ac..551114ed82 100644
--- a/scripts/rkimage.c
+++ b/scripts/rkimage.c
@@ -9,7 +9,7 @@
#include <stdint.h>
#include <string.h>
#include <time.h>
-#include <openssl/sha.h>
+#include <openssl/evp.h>
#include <errno.h>
#include <stdbool.h>
@@ -22,20 +22,24 @@
static void sha256(const void *buf, int len, void *out)
{
- SHA256_CTX sha256;
+ EVP_MD_CTX *md_ctx;
- SHA256_Init(&sha256);
- SHA256_Update(&sha256, buf, len);
- SHA256_Final(out, &sha256);
+ md_ctx = EVP_MD_CTX_new();
+ EVP_DigestInit(md_ctx, EVP_sha256());
+ EVP_DigestUpdate(md_ctx, buf, len);
+ EVP_DigestFinal(md_ctx, out, NULL);
+ EVP_MD_CTX_free(md_ctx);
}
static void sha512(const void *buf, int len, void *out)
{
- SHA512_CTX sha512;
+ EVP_MD_CTX *md_ctx;
- SHA512_Init(&sha512);
- SHA512_Update(&sha512, buf, len);
- SHA512_Final(out, &sha512);
+ md_ctx = EVP_MD_CTX_new();
+ EVP_DigestInit(md_ctx, EVP_sha512());
+ EVP_DigestUpdate(md_ctx, buf, len);
+ EVP_DigestFinal(md_ctx, out, NULL);
+ EVP_MD_CTX_free(md_ctx);
}
typedef enum {