]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4.c
CryptoPkg/BaseCryptLib: Retire ARC4 algorithm
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Cipher / CryptArc4.c
diff --git a/CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4.c b/CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4.c
deleted file mode 100644 (file)
index 388d312..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/** @file\r
-  ARC4 Wrapper Implementation over OpenSSL.\r
-\r
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "InternalCryptLib.h"\r
-#include <openssl/rc4.h>\r
-\r
-/**\r
-  Retrieves the size, in bytes, of the context buffer required for ARC4 operations.\r
-\r
-  @return  The size, in bytes, of the context buffer required for ARC4 operations.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-Arc4GetContextSize (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Memory for 2 copies of RC4_KEY is allocated, one for working copy, and the other\r
-  // for backup copy. When Arc4Reset() is called, we can use the backup copy to restore\r
-  // the working copy to the initial state.\r
-  //\r
-  return (UINTN) (2 * sizeof (RC4_KEY));\r
-}\r
-\r
-/**\r
-  Initializes user-supplied memory as ARC4 context for subsequent use.\r
-\r
-  This function initializes user-supplied memory pointed by Arc4Context as ARC4 context.\r
-  In addition, it sets up all ARC4 key materials for subsequent encryption and decryption\r
-  operations.\r
-\r
-  If Arc4Context is NULL, then return FALSE.\r
-  If Key is NULL, then return FALSE.\r
-  If KeySize does not in the range of [5, 256] bytes, then return FALSE.\r
-\r
-  @param[out]  Arc4Context  Pointer to ARC4 context being initialized.\r
-  @param[in]   Key          Pointer to the user-supplied ARC4 key.\r
-  @param[in]   KeySize      Size of ARC4 key in bytes.\r
-\r
-  @retval TRUE   ARC4 context initialization succeeded.\r
-  @retval FALSE  ARC4 context initialization failed.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-Arc4Init (\r
-  OUT  VOID         *Arc4Context,\r
-  IN   CONST UINT8  *Key,\r
-  IN   UINTN        KeySize\r
-  )\r
-{\r
-  RC4_KEY  *Rc4Key;\r
-\r
-  //\r
-  // Check input parameters.\r
-  //\r
-  if (Arc4Context == NULL || Key == NULL || (KeySize < 5 || KeySize > 256)) {\r
-    return FALSE;\r
-  }\r
-\r
-  Rc4Key = (RC4_KEY *) Arc4Context;\r
-\r
-  RC4_set_key (Rc4Key, (UINT32) KeySize, Key);\r
-\r
-  CopyMem (Rc4Key +  1, Rc4Key, sizeof (RC4_KEY));\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Performs ARC4 encryption on a data buffer of the specified size.\r
-\r
-  This function performs ARC4 encryption on data buffer pointed by Input, of specified\r
-  size of InputSize.\r
-  Arc4Context should be already correctly initialized by Arc4Init(). Behavior with\r
-  invalid ARC4 context is undefined.\r
-\r
-  If Arc4Context is NULL, then return FALSE.\r
-  If Input is NULL, then return FALSE.\r
-  If Output is NULL, then return FALSE.\r
-\r
-  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
-  @param[in]       Input        Pointer to the buffer containing the data to be encrypted.\r
-  @param[in]       InputSize    Size of the Input buffer in bytes.\r
-  @param[out]      Output       Pointer to a buffer that receives the ARC4 encryption output.\r
-\r
-  @retval TRUE   ARC4 encryption succeeded.\r
-  @retval FALSE  ARC4 encryption failed.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-Arc4Encrypt (\r
-  IN OUT  VOID         *Arc4Context,\r
-  IN      CONST UINT8  *Input,\r
-  IN      UINTN        InputSize,\r
-  OUT     UINT8        *Output\r
-  )\r
-{\r
-  RC4_KEY  *Rc4Key;\r
-\r
-  //\r
-  // Check input parameters.\r
-  //\r
-  if (Arc4Context == NULL || Input == NULL || Output == NULL || InputSize > INT_MAX) {\r
-    return FALSE;\r
-  }\r
-\r
-  Rc4Key = (RC4_KEY *) Arc4Context;\r
-\r
-  RC4 (Rc4Key, (UINT32) InputSize, Input, Output);\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Performs ARC4 decryption on a data buffer of the specified size.\r
-\r
-  This function performs ARC4 decryption on data buffer pointed by Input, of specified\r
-  size of InputSize.\r
-  Arc4Context should be already correctly initialized by Arc4Init(). Behavior with\r
-  invalid ARC4 context is undefined.\r
-\r
-  If Arc4Context is NULL, then return FALSE.\r
-  If Input is NULL, then return FALSE.\r
-  If Output is NULL, then return FALSE.\r
-\r
-  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
-  @param[in]       Input        Pointer to the buffer containing the data to be decrypted.\r
-  @param[in]       InputSize    Size of the Input buffer in bytes.\r
-  @param[out]      Output       Pointer to a buffer that receives the ARC4 decryption output.\r
-\r
-  @retval TRUE   ARC4 decryption succeeded.\r
-  @retval FALSE  ARC4 decryption failed.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-Arc4Decrypt (\r
-  IN OUT  VOID   *Arc4Context,\r
-  IN      UINT8  *Input,\r
-  IN      UINTN  InputSize,\r
-  OUT     UINT8  *Output\r
-  )\r
-{\r
-  RC4_KEY  *Rc4Key;\r
-\r
-  //\r
-  // Check input parameters.\r
-  //\r
-  if (Arc4Context == NULL || Input == NULL || Output == NULL || InputSize > INT_MAX) {\r
-    return FALSE;\r
-  }\r
-\r
-  Rc4Key = (RC4_KEY *) Arc4Context;\r
-\r
-  RC4 (Rc4Key, (UINT32) InputSize, Input, Output);\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Resets the ARC4 context to the initial state.\r
-\r
-  The function resets the ARC4 context to the state it had immediately after the\r
-  ARC4Init() function call.\r
-  Contrary to ARC4Init(), Arc4Reset() requires no secret key as input, but ARC4 context\r
-  should be already correctly initialized by ARC4Init().\r
-\r
-  If Arc4Context is NULL, then return FALSE.\r
-\r
-  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
-\r
-  @retval TRUE   ARC4 reset succeeded.\r
-  @retval FALSE  ARC4 reset failed.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-Arc4Reset (\r
-  IN OUT  VOID  *Arc4Context\r
-  )\r
-{\r
-  RC4_KEY  *Rc4Key;\r
-\r
-  //\r
-  // Check input parameters.\r
-  //\r
-  if (Arc4Context == NULL) {\r
-    return FALSE;\r
-  }\r
-\r
-  Rc4Key = (RC4_KEY *) Arc4Context;\r
-\r
-  CopyMem (Rc4Key, Rc4Key + 1, sizeof (RC4_KEY));\r
-\r
-  return TRUE;\r
-}\r