]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLibNull/Hash/CryptSm3Null.c
CryptoPkg: Add Null instance of the BaseCryptLib class
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLibNull / Hash / CryptSm3Null.c
diff --git a/CryptoPkg/Library/BaseCryptLibNull/Hash/CryptSm3Null.c b/CryptoPkg/Library/BaseCryptLibNull/Hash/CryptSm3Null.c
new file mode 100644 (file)
index 0000000..0f3c89b
--- /dev/null
@@ -0,0 +1,164 @@
+/** @file\r
+  SM3 Digest Wrapper Null Implementation.\r
+\r
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.\r
+\r
+  @return  The size, in bytes, of the context buffer required for SM3 hash operations.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Sm3GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for\r
+  subsequent use.\r
+\r
+  If Sm3Context is NULL, then return FALSE.\r
+\r
+  @param[out]  Sm3Context  Pointer to SM3 context being initialized.\r
+\r
+  @retval TRUE   SM3 context initialization succeeded.\r
+  @retval FALSE  SM3 context initialization failed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sm3Init (\r
+  OUT  VOID  *Sm3Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing SM3 context.\r
+\r
+  If Sm3Context is NULL, then return FALSE.\r
+  If NewSm3Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[in]  Sm3Context     Pointer to SM3 context being copied.\r
+  @param[out] NewSm3Context  Pointer to new SM3 context.\r
+\r
+  @retval TRUE   SM3 context copy succeeded.\r
+  @retval FALSE  SM3 context copy failed.\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sm3Duplicate (\r
+  IN   CONST VOID  *Sm3Context,\r
+  OUT  VOID        *NewSm3Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates SM3 context.\r
+\r
+  This function performs SM3 digest on a data buffer of the specified size.\r
+  It can be called multiple times to compute the digest of long or discontinuous data streams.\r
+  SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized\r
+  by Sm3Final(). Behavior with invalid context is undefined.\r
+\r
+  If Sm3Context is NULL, then return FALSE.\r
+\r
+  @param[in, out]  Sm3Context     Pointer to the SM3 context.\r
+  @param[in]       Data           Pointer to the buffer containing the data to be hashed.\r
+  @param[in]       DataSize       Size of Data buffer in bytes.\r
+\r
+  @retval TRUE   SM3 data digest succeeded.\r
+  @retval FALSE  SM3 data digest failed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sm3Update (\r
+  IN OUT  VOID        *Sm3Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the SM3 digest value.\r
+\r
+  This function completes SM3 hash computation and retrieves the digest value into\r
+  the specified memory. After this function has been called, the SM3 context cannot\r
+  be used again.\r
+  SM3 context should be already correctly initialized by Sm3Init(), and should not be\r
+  finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.\r
+\r
+  If Sm3Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
+\r
+  @param[in, out]  Sm3Context     Pointer to the SM3 context.\r
+  @param[out]      HashValue      Pointer to a buffer that receives the SM3 digest\r
+                                  value (32 bytes).\r
+\r
+  @retval TRUE   SM3 digest computation succeeded.\r
+  @retval FALSE  SM3 digest computation failed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sm3Final (\r
+  IN OUT  VOID   *Sm3Context,\r
+  OUT     UINT8  *HashValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Computes the SM3 message digest of a input data buffer.\r
+\r
+  This function performs the SM3 message digest of a given data buffer, and places\r
+  the digest value into the specified memory.\r
+\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[in]   Data        Pointer to the buffer containing the data to be hashed.\r
+  @param[in]   DataSize    Size of Data buffer in bytes.\r
+  @param[out]  HashValue   Pointer to a buffer that receives the SM3 digest\r
+                           value (32 bytes).\r
+\r
+  @retval TRUE   SM3 digest computation succeeded.\r
+  @retval FALSE  SM3 digest computation failed.\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sm3HashAll (\r
+  IN   CONST VOID  *Data,\r
+  IN   UINTN       DataSize,\r
+  OUT  UINT8       *HashValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r