From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: Sami Mujawar <sami.mujawar@arm.com>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Rebecca Cran <rebecca@bsdio.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Edward Pickup <Edward.Pickup@arm.com>
Subject: [PATCH v1 6/7] MdePkg/AesLib: Add NULL instance of AesLib
Date: Wed, 29 Jun 2022 17:07:12 +0200 [thread overview]
Message-ID: <20220629150713.2600465-7-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20220629150713.2600465-1-Pierre.Gondois@arm.com>
From: Pierre Gondois <Pierre.Gondois@arm.com>
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3970
The FIPS PUB 197: "Advanced Encryption Standard (AES)"
details the AES algorithm.
Add an AesLibNull implementation.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
MdePkg/Library/AesLibNull/AesLibNull.c | 87 ++++++++++++++++++++++++
MdePkg/Library/AesLibNull/AesLibNull.inf | 24 +++++++
MdePkg/MdePkg.dsc | 1 +
3 files changed, 112 insertions(+)
create mode 100644 MdePkg/Library/AesLibNull/AesLibNull.c
create mode 100644 MdePkg/Library/AesLibNull/AesLibNull.inf
diff --git a/MdePkg/Library/AesLibNull/AesLibNull.c b/MdePkg/Library/AesLibNull/AesLibNull.c
new file mode 100644
index 000000000000..3dd680fe37e4
--- /dev/null
+++ b/MdePkg/Library/AesLibNull/AesLibNull.c
@@ -0,0 +1,87 @@
+/** @file
+ Null AES Library
+
+ Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Reference(s):
+ - FIPS 197 November 26, 2001:
+ Specification for the ADVANCED ENCRYPTION STANDARD (AES)
+**/
+
+#include <Library/AesLib.h>
+#include <Library/DebugLib.h>
+
+/** Encrypt an AES block.
+
+ Buffers are little-endian. Overlapping is not checked.
+
+ @param [in] AesCtx AES context.
+ AesCtx is initialized with AesInitCtx ().
+ @param [in] InBlock Input Block. The block to cipher.
+ @param [out] OutBlock Output Block. The ciphered block.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Invalid parameter.
+ @retval EFI_UNSUPPORTED Unsupported.
+**/
+EFI_STATUS
+EFIAPI
+AesEncrypt (
+ IN AES_CTX *AesCtx,
+ IN UINT8 CONST *InBlock,
+ OUT UINT8 *OutBlock
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
+
+/** Decrypt an AES block.
+
+ Buffers are little-endian. Overlapping is not checked.
+
+ @param [in] AesCtx AES context.
+ AesCtx is initialized with AesInitCtx ().
+ @param [in] InBlock Input Block. The block to de-cipher.
+ @param [out] OutBlock Output Block. The de-ciphered block.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Invalid parameter.
+ @retval EFI_UNSUPPORTED Unsupported.
+**/
+EFI_STATUS
+EFIAPI
+AesDecrypt (
+ IN AES_CTX *AesCtx,
+ IN UINT8 CONST *InBlock,
+ OUT UINT8 *OutBlock
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
+
+/** Initialize an AES_CTX structure.
+
+ @param [in] Key AES key. Buffer of KeySize bytes.
+ The buffer is little endian.
+ @param [in] KeySize Size of the key. Must be one of 128|192|256.
+ @param [in, out] AesCtx AES context to initialize.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Invalid parameter.
+ @retval EFI_UNSUPPORTED Unsupported.
+**/
+EFI_STATUS
+EFIAPI
+AesInitCtx (
+ IN UINT8 *Key,
+ IN UINT32 KeySize,
+ IN OUT AES_CTX *AesCtx
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
diff --git a/MdePkg/Library/AesLibNull/AesLibNull.inf b/MdePkg/Library/AesLibNull/AesLibNull.inf
new file mode 100644
index 000000000000..3020e7b68571
--- /dev/null
+++ b/MdePkg/Library/AesLibNull/AesLibNull.inf
@@ -0,0 +1,24 @@
+## @file
+# Null AES Library
+#
+# Copyright (c) 2022, Arm Limited. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 0x0001001B
+ BASE_NAME = AesLibNull
+ FILE_GUID = F6DED279-FC26-40F6-88B2-05FF5E6E538F
+ VERSION_STRING = 1.0
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = AesLib
+
+[Sources]
+ AesLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ DebugLib
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 80e7233363d3..726350c215e5 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -68,6 +68,7 @@ [Components]
MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf
MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf
+ MdePkg/Library/AesLibNull/AesLibNull.inf
MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
--
2.25.1
next prev parent reply other threads:[~2022-06-29 15:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-29 15:07 [PATCH v1 0/7] Add AesLib and ArmAesLib PierreGondois
2022-06-29 15:07 ` [PATCH v1 1/7] ArmPkg: Update Armpkg.ci.yaml PierreGondois
2022-06-29 15:07 ` [PATCH v1 2/7] ArmPkg/ArmDisassemblerLib: Replace RotateRight() PierreGondois
2022-06-29 15:07 ` [PATCH v1 3/7] ArmPkg/ArmLib: Add ArmReadIdIsaR5() helper PierreGondois
2022-06-29 15:07 ` [PATCH v1 4/7] ArmPkg/ArmLib: Add ArmHasAesExt() PierreGondois
2022-06-29 15:07 ` [PATCH v1 5/7] MdePkg/AesLib: Definition for AES library class interface PierreGondois
2022-06-29 15:07 ` PierreGondois [this message]
2022-06-29 15:22 ` [edk2-devel] [PATCH v1 0/7] Add AesLib and ArmAesLib PierreGondois
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=20220629150713.2600465-7-Pierre.Gondois@arm.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