]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mbedtls: replace `memset()` with `psa_hash_operation_init()`
authorViktor Szakats <commit@vsz.me>
Mon, 29 Jun 2026 14:12:10 +0000 (16:12 +0200)
committerViktor Szakats <commit@vsz.me>
Tue, 30 Jun 2026 09:36:55 +0000 (11:36 +0200)
To initialize hash contexts.

Ref: https://arm-software.github.io/psa-api/crypto/1.1/api/ops/hashes.html#c.psa_hash_operation_init
Follow-up to 3a305831d1a9d10b2bfd4fa3939ed41275fee7f7 #19077

Closes #22220

lib/md5.c
lib/sha256.c

index 1f1b4f8ad61088fb7824e8f1ad104f701390d6e8..9f995c7393d0335d40d6a96b9265fb38253f8d69 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -128,8 +128,9 @@ typedef psa_hash_operation_t my_md5_ctx;
 
 static CURLcode my_md5_init(void *ctx)
 {
-  memset(ctx, 0, sizeof(my_md5_ctx));
-  if(psa_hash_setup(ctx, PSA_ALG_MD5) != PSA_SUCCESS)
+  psa_hash_operation_t *pctx = (psa_hash_operation_t *)ctx;
+  *pctx = psa_hash_operation_init();
+  if(psa_hash_setup(pctx, PSA_ALG_MD5) != PSA_SUCCESS)
     return CURLE_OUT_OF_MEMORY;
   return CURLE_OK;
 }
index 38c9b9bc1b3bddb2adc8f4edcb54e8ecf096b759..670532a325586bd3318ac37a45cc56fee4ec5248 100644 (file)
@@ -148,8 +148,9 @@ typedef psa_hash_operation_t my_sha256_ctx;
 
 static CURLcode my_sha256_init(void *ctx)
 {
-  memset(ctx, 0, sizeof(my_sha256_ctx));
-  if(psa_hash_setup(ctx, PSA_ALG_SHA_256) != PSA_SUCCESS)
+  psa_hash_operation_t *pctx = (psa_hash_operation_t *)ctx;
+  *pctx = psa_hash_operation_init();
+  if(psa_hash_setup(pctx, PSA_ALG_SHA_256) != PSA_SUCCESS)
     return CURLE_OUT_OF_MEMORY;
   return CURLE_OK;
 }