From: "Wenxing Hou" <wenxing.hou@intel.com>
To: devel@edk2.groups.io
Cc: Jiewen Yao <jiewen.yao@intel.com>, Yi Li <yi1.li@intel.com>
Subject: [edk2-devel] [PATCH 2/3] CryptoPkg: Update Md5/Sha1/Sha2 by using new mbedtls api
Date: Fri, 29 Mar 2024 10:32:41 +0800 [thread overview]
Message-ID: <20240329023242.2443-3-wenxing.hou@intel.com> (raw)
In-Reply-To: <20240329023242.2443-1-wenxing.hou@intel.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4741
Update Md5/Sha1/Sha2 by using mbedtls 3.0 api in BaseCryptLibMbedTls,
because the old API may be deprecated when open some MACRO.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Yi Li <yi1.li@intel.com>
Signed-off-by: Wenxing Hou <wenxing.hou@intel.com>
---
.../Library/BaseCryptLibMbedTls/Hash/CryptMd5.c | 9 ++++-----
.../BaseCryptLibMbedTls/Hash/CryptSha1.c | 9 ++++-----
.../BaseCryptLibMbedTls/Hash/CryptSha256.c | 9 ++++-----
.../BaseCryptLibMbedTls/Hash/CryptSha512.c | 17 ++++++++---------
4 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptMd5.c b/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptMd5.c
index 35978291ca..f9590f59a0 100644
--- a/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptMd5.c
+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptMd5.c
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "InternalCryptLib.h"
#include <mbedtls/md5.h>
-#include <mbedtls/compat-2.x.h>
#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
@@ -56,7 +55,7 @@ Md5Init (
mbedtls_md5_init (Md5Context);
- Ret = mbedtls_md5_starts_ret (Md5Context);
+ Ret = mbedtls_md5_starts (Md5Context);
if (Ret != 0) {
return FALSE;
}
@@ -129,7 +128,7 @@ Md5Update (
return FALSE;
}
- Ret = mbedtls_md5_update_ret (Md5Context, Data, DataSize);
+ Ret = mbedtls_md5_update (Md5Context, Data, DataSize);
if (Ret != 0) {
return FALSE;
}
@@ -170,7 +169,7 @@ Md5Final (
return FALSE;
}
- Ret = mbedtls_md5_finish_ret (Md5Context, HashValue);
+ Ret = mbedtls_md5_finish (Md5Context, HashValue);
mbedtls_md5_free (Md5Context);
if (Ret != 0) {
return FALSE;
@@ -215,7 +214,7 @@ Md5HashAll (
return FALSE;
}
- Ret = mbedtls_md5_ret (Data, DataSize, HashValue);
+ Ret = mbedtls_md5 (Data, DataSize, HashValue);
if (Ret != 0) {
return FALSE;
}
diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha1.c b/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha1.c
index 68b107bd7b..718608faec 100644
--- a/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha1.c
+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha1.c
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "InternalCryptLib.h"
#include <mbedtls/sha1.h>
-#include <mbedtls/compat-2.x.h>
#ifndef DISABLE_SHA1_DEPRECATED_INTERFACES
@@ -56,7 +55,7 @@ Sha1Init (
mbedtls_sha1_init (Sha1Context);
- Ret = mbedtls_sha1_starts_ret (Sha1Context);
+ Ret = mbedtls_sha1_starts (Sha1Context);
if (Ret != 0) {
return FALSE;
}
@@ -129,7 +128,7 @@ Sha1Update (
return FALSE;
}
- Ret = mbedtls_sha1_update_ret (Sha1Context, Data, DataSize);
+ Ret = mbedtls_sha1_update (Sha1Context, Data, DataSize);
if (Ret != 0) {
return FALSE;
}
@@ -170,7 +169,7 @@ Sha1Final (
return FALSE;
}
- Ret = mbedtls_sha1_finish_ret (Sha1Context, HashValue);
+ Ret = mbedtls_sha1_finish (Sha1Context, HashValue);
mbedtls_sha1_free (Sha1Context);
if (Ret != 0) {
return FALSE;
@@ -215,7 +214,7 @@ Sha1HashAll (
return FALSE;
}
- Ret = mbedtls_sha1_ret (Data, DataSize, HashValue);
+ Ret = mbedtls_sha1 (Data, DataSize, HashValue);
if (Ret != 0) {
return FALSE;
}
diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha256.c b/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha256.c
index 007f5c12aa..b0356732cf 100644
--- a/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha256.c
+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha256.c
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "InternalCryptLib.h"
#include <mbedtls/sha256.h>
-#include <mbedtls/compat-2.x.h>
/**
Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.
@@ -51,7 +50,7 @@ Sha256Init (
mbedtls_sha256_init (Sha256Context);
- Ret = mbedtls_sha256_starts_ret (Sha256Context, FALSE);
+ Ret = mbedtls_sha256_starts (Sha256Context, FALSE);
if (Ret != 0) {
return FALSE;
}
@@ -124,7 +123,7 @@ Sha256Update (
return FALSE;
}
- Ret = mbedtls_sha256_update_ret (Sha256Context, Data, DataSize);
+ Ret = mbedtls_sha256_update (Sha256Context, Data, DataSize);
if (Ret != 0) {
return FALSE;
}
@@ -165,7 +164,7 @@ Sha256Final (
return FALSE;
}
- Ret = mbedtls_sha256_finish_ret (Sha256Context, HashValue);
+ Ret = mbedtls_sha256_finish (Sha256Context, HashValue);
mbedtls_sha256_free (Sha256Context);
if (Ret != 0) {
return FALSE;
@@ -210,7 +209,7 @@ Sha256HashAll (
return FALSE;
}
- Ret = mbedtls_sha256_ret (Data, DataSize, HashValue, FALSE);
+ Ret = mbedtls_sha256 (Data, DataSize, HashValue, FALSE);
if (Ret != 0) {
return FALSE;
}
diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha512.c b/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha512.c
index 3c6fc951d3..3342a1f8fe 100644
--- a/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha512.c
+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha512.c
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "InternalCryptLib.h"
#include <mbedtls/sha512.h>
-#include <mbedtls/compat-2.x.h>
/**
Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.
@@ -51,7 +50,7 @@ Sha384Init (
mbedtls_sha512_init (Sha384Context);
- Ret = mbedtls_sha512_starts_ret (Sha384Context, TRUE);
+ Ret = mbedtls_sha512_starts (Sha384Context, TRUE);
if (Ret != 0) {
return FALSE;
}
@@ -126,7 +125,7 @@ Sha384Update (
return FALSE;
}
- Ret = mbedtls_sha512_update_ret (Sha384Context, Data, DataSize);
+ Ret = mbedtls_sha512_update (Sha384Context, Data, DataSize);
if (Ret != 0) {
return FALSE;
}
@@ -167,7 +166,7 @@ Sha384Final (
return FALSE;
}
- Ret = mbedtls_sha512_finish_ret (Sha384Context, HashValue);
+ Ret = mbedtls_sha512_finish (Sha384Context, HashValue);
mbedtls_sha512_free (Sha384Context);
if (Ret != 0) {
return FALSE;
@@ -212,7 +211,7 @@ Sha384HashAll (
return FALSE;
}
- Ret = mbedtls_sha512_ret (Data, DataSize, HashValue, TRUE);
+ Ret = mbedtls_sha512 (Data, DataSize, HashValue, TRUE);
if (Ret != 0) {
return FALSE;
}
@@ -261,7 +260,7 @@ Sha512Init (
mbedtls_sha512_init (Sha512Context);
- Ret = mbedtls_sha512_starts_ret (Sha512Context, FALSE);
+ Ret = mbedtls_sha512_starts (Sha512Context, FALSE);
if (Ret != 0) {
return FALSE;
}
@@ -336,7 +335,7 @@ Sha512Update (
return FALSE;
}
- Ret = mbedtls_sha512_update_ret (Sha512Context, Data, DataSize);
+ Ret = mbedtls_sha512_update (Sha512Context, Data, DataSize);
if (Ret != 0) {
return FALSE;
}
@@ -377,7 +376,7 @@ Sha512Final (
return FALSE;
}
- Ret = mbedtls_sha512_finish_ret (Sha512Context, HashValue);
+ Ret = mbedtls_sha512_finish (Sha512Context, HashValue);
mbedtls_sha512_free (Sha512Context);
if (Ret != 0) {
return FALSE;
@@ -422,7 +421,7 @@ Sha512HashAll (
return FALSE;
}
- Ret = mbedtls_sha512_ret (Data, DataSize, HashValue, FALSE);
+ Ret = mbedtls_sha512 (Data, DataSize, HashValue, FALSE);
if (Ret != 0) {
return FALSE;
}
--
2.26.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117222): https://edk2.groups.io/g/devel/message/117222
Mute This Topic: https://groups.io/mt/105210161/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-03-29 2:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-29 2:32 [edk2-devel] [PATCH 0/3] CryptoPkg: Optimize APIs in BaseCryptLibMbedTls Wenxing Hou
2024-03-29 2:32 ` [edk2-devel] [PATCH 1/3] CryptoPkg: Update OPTIONAL location for BaseCryptLibMbedTls Wenxing Hou
2024-03-29 2:32 ` Wenxing Hou [this message]
2024-03-29 2:32 ` [edk2-devel] [PATCH 3/3] CryptoPkg: Remove interdependence for RsaPssVerify Wenxing Hou
2024-03-29 3:32 ` [edk2-devel] [PATCH 0/3] CryptoPkg: Optimize APIs in BaseCryptLibMbedTls Li, Yi
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-list 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=20240329023242.2443-3-wenxing.hou@intel.com \
--to=devel@edk2.groups.io \
/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