mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] scripts: rkimage: Use non-deprecated functions for sha256/512
Date: Tue,  2 May 2023 14:27:05 +0200	[thread overview]
Message-ID: <20230502122705.2112637-1-s.hauer@pengutronix.de> (raw)

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>
---
 scripts/rkimage.c | 22 +++++++++++++---------
 1 file 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 {
-- 
2.39.2




             reply	other threads:[~2023-05-02 12:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 12:27 Sascha Hauer [this message]
2023-05-02 14:59 ` Ahmad Fatoum
2023-05-02 15:10   ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230502122705.2112637-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox