]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Driver/Crypto.c
CryptoPkg/BaseCryptLib: Add MARCO to disable the deprecated MD5
[mirror_edk2.git] / CryptoPkg / Driver / Crypto.c
index 73ae56675548add2e26245c9ebfed08a3c78c07a..7e7e31a35e25b33fb3fcdcd4e19d278c36ee20ea 100644 (file)
@@ -243,6 +243,154 @@ DeprecatedCryptoServiceMd4HashAll (
   return BaseCryptLibServiceDeprecated ("Md4HashAll"), FALSE;\r
 }\r
 \r
+#ifdef DISABLE_MD5_DEPRECATED_INTERFACES\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r
+\r
+  If this interface is not supported, then return zero.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+DeprecatedCryptoServiceMd5GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  return BaseCryptLibServiceDeprecated ("Md5GetContextSize"), 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r
+  subsequent use.\r
+\r
+  If Md5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[out]  Md5Context  Pointer to MD5 context being initialized.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DeprecatedCryptoServiceMd5Init (\r
+  OUT  VOID  *Md5Context\r
+  )\r
+{\r
+  return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing MD5 context.\r
+\r
+  If Md5Context is NULL, then return FALSE.\r
+  If NewMd5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[in]  Md5Context     Pointer to MD5 context being copied.\r
+  @param[out] NewMd5Context  Pointer to new MD5 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DeprecatedCryptoServiceMd5Duplicate (\r
+  IN   CONST VOID  *Md5Context,\r
+  OUT  VOID        *NewMd5Context\r
+  )\r
+{\r
+  return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates MD5 context.\r
+\r
+  This function performs MD5 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
+  MD5 context should be already correctly initialized by Md5Init(), and should not be finalized\r
+  by Md5Final(). Behavior with invalid context is undefined.\r
+\r
+  If Md5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[in, out]  Md5Context  Pointer to the MD5 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 FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DeprecatedCryptoServiceMd5Update (\r
+  IN OUT  VOID        *Md5Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the MD5 digest value.\r
+\r
+  This function completes MD5 hash computation and retrieves the digest value into\r
+  the specified memory. After this function has been called, the MD5 context cannot\r
+  be used again.\r
+  MD5 context should be already correctly initialized by Md5Init(), and should not be\r
+  finalized by Md5Final(). Behavior with invalid MD5 context is undefined.\r
+\r
+  If Md5Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[in, out]  Md5Context  Pointer to the MD5 context.\r
+  @param[out]      HashValue   Pointer to a buffer that receives the MD5 digest\r
+                               value (16 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DeprecatedCryptoServiceMd5Final (\r
+  IN OUT  VOID   *Md5Context,\r
+  OUT     UINT8  *HashValue\r
+  )\r
+{\r
+  return BaseCryptLibServiceDeprecated ("Md5Final"), FALSE;\r
+}\r
+\r
+/**\r
+  Computes the MD5 message digest of a input data buffer.\r
+\r
+  This function performs the MD5 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 MD5 digest\r
+                           value (16 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DeprecatedCryptoServiceMd5HashAll (\r
+  IN   CONST VOID  *Data,\r
+  IN   UINTN       DataSize,\r
+  OUT  UINT8       *HashValue\r
+  )\r
+{\r
+  return BaseCryptLibServiceDeprecated ("Md5HashAll"), FALSE;\r
+}\r
+#else\r
 /**\r
   Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r
 \r
@@ -400,6 +548,7 @@ CryptoServiceMd5HashAll (
 {\r
   return CALL_BASECRYPTLIB (Md5.Services.HashAll, Md5HashAll, (Data, DataSize, HashValue), FALSE);\r
 }\r
+#endif\r
 \r
 /**\r
   Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.\r
@@ -4194,6 +4343,15 @@ const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto = {
   DeprecatedCryptoServiceMd4Update,\r
   DeprecatedCryptoServiceMd4Final,\r
   DeprecatedCryptoServiceMd4HashAll,\r
+#ifdef DISABLE_MD5_DEPRECATED_INTERFACES\r
+  /// Md5 - deprecated and unsupported\r
+  DeprecatedCryptoServiceMd5GetContextSize,\r
+  DeprecatedCryptoServiceMd5Init,\r
+  DeprecatedCryptoServiceMd5Duplicate,\r
+  DeprecatedCryptoServiceMd5Update,\r
+  DeprecatedCryptoServiceMd5Final,\r
+  DeprecatedCryptoServiceMd5HashAll,\r
+#else\r
   /// Md5\r
   CryptoServiceMd5GetContextSize,\r
   CryptoServiceMd5Init,\r
@@ -4201,6 +4359,7 @@ const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto = {
   CryptoServiceMd5Update,\r
   CryptoServiceMd5Final,\r
   CryptoServiceMd5HashAll,\r
+#endif\r
   /// Pkcs\r
   CryptoServicePkcs1v2Encrypt,\r
   CryptoServicePkcs5HashPassword,\r