// Symmetric Cryptography Primitive\r
//=====================================================================================\r
\r
-/**\r
- Retrieves the size, in bytes, of the context buffer required for TDES operations.\r
-\r
- If this interface is not supported, then return zero.\r
-\r
- @return The size, in bytes, of the context buffer required for TDES operations.\r
- @retval 0 This interface is not supported.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-TdesGetContextSize (\r
- VOID\r
- )\r
-{\r
- CALL_CRYPTO_SERVICE (TdesGetContextSize, (), 0);\r
-}\r
-\r
-/**\r
- Initializes user-supplied memory as TDES context for subsequent use.\r
-\r
- This function initializes user-supplied memory pointed by TdesContext as TDES context.\r
- In addition, it sets up all TDES key materials for subsequent encryption and decryption\r
- operations.\r
- There are 3 key options as follows:\r
- KeyLength = 64, Keying option 1: K1 == K2 == K3 (Backward compatibility with DES)\r
- KeyLength = 128, Keying option 2: K1 != K2 and K3 = K1 (Less Security)\r
- KeyLength = 192 Keying option 3: K1 != K2 != K3 (Strongest)\r
-\r
- If TdesContext is NULL, then return FALSE.\r
- If Key is NULL, then return FALSE.\r
- If KeyLength is not valid, then return FALSE.\r
- If this interface is not supported, then return FALSE.\r
-\r
- @param[out] TdesContext Pointer to TDES context being initialized.\r
- @param[in] Key Pointer to the user-supplied TDES key.\r
- @param[in] KeyLength Length of TDES key in bits.\r
-\r
- @retval TRUE TDES context initialization succeeded.\r
- @retval FALSE TDES context initialization failed.\r
- @retval FALSE This interface is not supported.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-TdesInit (\r
- OUT VOID *TdesContext,\r
- IN CONST UINT8 *Key,\r
- IN UINTN KeyLength\r
- )\r
-{\r
- CALL_CRYPTO_SERVICE (TdesInit, (TdesContext, Key, KeyLength), FALSE);\r
-}\r
-\r
-/**\r
- Performs TDES encryption on a data buffer of the specified size in ECB mode.\r
-\r
- This function performs TDES encryption on data buffer pointed by Input, of specified\r
- size of InputSize, in ECB mode.\r
- InputSize must be multiple of block size (8 bytes). This function does not perform\r
- padding. Caller must perform padding, if necessary, to ensure valid input data size.\r
- TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
- invalid TDES context is undefined.\r
-\r
- If TdesContext is NULL, then return FALSE.\r
- If Input is NULL, then return FALSE.\r
- If InputSize is not multiple of block size (8 bytes), then return FALSE.\r
- If Output is NULL, then return FALSE.\r
- If this interface is not supported, then return FALSE.\r
-\r
- @param[in] TdesContext Pointer to the TDES 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 TDES encryption output.\r
-\r
- @retval TRUE TDES encryption succeeded.\r
- @retval FALSE TDES encryption failed.\r
- @retval FALSE This interface is not supported.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-TdesEcbEncrypt (\r
- IN VOID *TdesContext,\r
- IN CONST UINT8 *Input,\r
- IN UINTN InputSize,\r
- OUT UINT8 *Output\r
- )\r
-{\r
- CALL_CRYPTO_SERVICE (TdesEcbEncrypt, (TdesContext, Input, InputSize, Output), FALSE);\r
-}\r
-\r
-/**\r
- Performs TDES decryption on a data buffer of the specified size in ECB mode.\r
-\r
- This function performs TDES decryption on data buffer pointed by Input, of specified\r
- size of InputSize, in ECB mode.\r
- InputSize must be multiple of block size (8 bytes). This function does not perform\r
- padding. Caller must perform padding, if necessary, to ensure valid input data size.\r
- TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
- invalid TDES context is undefined.\r
-\r
- If TdesContext is NULL, then return FALSE.\r
- If Input is NULL, then return FALSE.\r
- If InputSize is not multiple of block size (8 bytes), then return FALSE.\r
- If Output is NULL, then return FALSE.\r
- If this interface is not supported, then return FALSE.\r
-\r
- @param[in] TdesContext Pointer to the TDES 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 TDES decryption output.\r
-\r
- @retval TRUE TDES decryption succeeded.\r
- @retval FALSE TDES decryption failed.\r
- @retval FALSE This interface is not supported.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-TdesEcbDecrypt (\r
- IN VOID *TdesContext,\r
- IN CONST UINT8 *Input,\r
- IN UINTN InputSize,\r
- OUT UINT8 *Output\r
- )\r
-{\r
- CALL_CRYPTO_SERVICE (TdesEcbDecrypt, (TdesContext, Input, InputSize, Output), FALSE);\r
-}\r
-\r
-/**\r
- Performs TDES encryption on a data buffer of the specified size in CBC mode.\r
-\r
- This function performs TDES encryption on data buffer pointed by Input, of specified\r
- size of InputSize, in CBC mode.\r
- InputSize must be multiple of block size (8 bytes). This function does not perform\r
- padding. Caller must perform padding, if necessary, to ensure valid input data size.\r
- Initialization vector should be one block size (8 bytes).\r
- TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
- invalid TDES context is undefined.\r
-\r
- If TdesContext is NULL, then return FALSE.\r
- If Input is NULL, then return FALSE.\r
- If InputSize is not multiple of block size (8 bytes), then return FALSE.\r
- If Ivec is NULL, then return FALSE.\r
- If Output is NULL, then return FALSE.\r
- If this interface is not supported, then return FALSE.\r
-\r
- @param[in] TdesContext Pointer to the TDES 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[in] Ivec Pointer to initialization vector.\r
- @param[out] Output Pointer to a buffer that receives the TDES encryption output.\r
-\r
- @retval TRUE TDES encryption succeeded.\r
- @retval FALSE TDES encryption failed.\r
- @retval FALSE This interface is not supported.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-TdesCbcEncrypt (\r
- IN VOID *TdesContext,\r
- IN CONST UINT8 *Input,\r
- IN UINTN InputSize,\r
- IN CONST UINT8 *Ivec,\r
- OUT UINT8 *Output\r
- )\r
-{\r
- CALL_CRYPTO_SERVICE (TdesCbcEncrypt, (TdesContext, Input, InputSize, Ivec, Output), FALSE);\r
-}\r
-\r
-/**\r
- Performs TDES decryption on a data buffer of the specified size in CBC mode.\r
-\r
- This function performs TDES decryption on data buffer pointed by Input, of specified\r
- size of InputSize, in CBC mode.\r
- InputSize must be multiple of block size (8 bytes). This function does not perform\r
- padding. Caller must perform padding, if necessary, to ensure valid input data size.\r
- Initialization vector should be one block size (8 bytes).\r
- TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
- invalid TDES context is undefined.\r
-\r
- If TdesContext is NULL, then return FALSE.\r
- If Input is NULL, then return FALSE.\r
- If InputSize is not multiple of block size (8 bytes), then return FALSE.\r
- If Ivec is NULL, then return FALSE.\r
- If Output is NULL, then return FALSE.\r
- If this interface is not supported, then return FALSE.\r
-\r
- @param[in] TdesContext Pointer to the TDES 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[in] Ivec Pointer to initialization vector.\r
- @param[out] Output Pointer to a buffer that receives the TDES encryption output.\r
-\r
- @retval TRUE TDES decryption succeeded.\r
- @retval FALSE TDES decryption failed.\r
- @retval FALSE This interface is not supported.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-TdesCbcDecrypt (\r
- IN VOID *TdesContext,\r
- IN CONST UINT8 *Input,\r
- IN UINTN InputSize,\r
- IN CONST UINT8 *Ivec,\r
- OUT UINT8 *Output\r
- )\r
-{\r
- CALL_CRYPTO_SERVICE (TdesCbcDecrypt, (TdesContext, Input, InputSize, Ivec, Output), FALSE);\r
-}\r
-\r
/**\r
Retrieves the size, in bytes, of the context buffer required for AES operations.\r
\r