return TRUE;\r
}\r
\r
-/**\r
- Performs AES encryption on a data buffer of the specified size in ECB mode.\r
-\r
- This function performs AES encryption on data buffer pointed by Input, of specified\r
- size of InputSize, in ECB mode.\r
- InputSize must be multiple of block size (16 bytes). This function does not perform\r
- padding. Caller must perform padding, if necessary, to ensure valid input data size.\r
- AesContext should be already correctly initialized by AesInit(). Behavior with\r
- invalid AES context is undefined.\r
-\r
- If AesContext is NULL, then return FALSE.\r
- If Input is NULL, then return FALSE.\r
- If InputSize is not multiple of block size (16 bytes), then return FALSE.\r
- If Output is NULL, then return FALSE.\r
-\r
- @param[in] AesContext Pointer to the AES 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 AES encryption output.\r
-\r
- @retval TRUE AES encryption succeeded.\r
- @retval FALSE AES encryption failed.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-AesEcbEncrypt (\r
- IN VOID *AesContext,\r
- IN CONST UINT8 *Input,\r
- IN UINTN InputSize,\r
- OUT UINT8 *Output\r
- )\r
-{\r
- AES_KEY *AesKey;\r
-\r
- //\r
- // Check input parameters.\r
- //\r
- if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Output == NULL) {\r
- return FALSE;\r
- }\r
-\r
- AesKey = (AES_KEY *) AesContext;\r
-\r
- //\r
- // Perform AES data encryption with ECB mode (block-by-block)\r
- //\r
- while (InputSize > 0) {\r
- AES_ecb_encrypt (Input, Output, AesKey, AES_ENCRYPT);\r
- Input += AES_BLOCK_SIZE;\r
- Output += AES_BLOCK_SIZE;\r
- InputSize -= AES_BLOCK_SIZE;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
-/**\r
- Performs AES decryption on a data buffer of the specified size in ECB mode.\r
-\r
- This function performs AES decryption on data buffer pointed by Input, of specified\r
- size of InputSize, in ECB mode.\r
- InputSize must be multiple of block size (16 bytes). This function does not perform\r
- padding. Caller must perform padding, if necessary, to ensure valid input data size.\r
- AesContext should be already correctly initialized by AesInit(). Behavior with\r
- invalid AES context is undefined.\r
-\r
- If AesContext is NULL, then return FALSE.\r
- If Input is NULL, then return FALSE.\r
- If InputSize is not multiple of block size (16 bytes), then return FALSE.\r
- If Output is NULL, then return FALSE.\r
-\r
- @param[in] AesContext Pointer to the AES 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 AES decryption output.\r
-\r
- @retval TRUE AES decryption succeeded.\r
- @retval FALSE AES decryption failed.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-AesEcbDecrypt (\r
- IN VOID *AesContext,\r
- IN CONST UINT8 *Input,\r
- IN UINTN InputSize,\r
- OUT UINT8 *Output\r
- )\r
-{\r
- AES_KEY *AesKey;\r
-\r
- //\r
- // Check input parameters.\r
- //\r
- if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Output == NULL) {\r
- return FALSE;\r
- }\r
-\r
- AesKey = (AES_KEY *) AesContext;\r
-\r
- //\r
- // Perform AES data decryption with ECB mode (block-by-block)\r
- //\r
- while (InputSize > 0) {\r
- AES_ecb_encrypt (Input, Output, AesKey + 1, AES_DECRYPT);\r
- Input += AES_BLOCK_SIZE;\r
- Output += AES_BLOCK_SIZE;\r
- InputSize -= AES_BLOCK_SIZE;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
/**\r
Performs AES encryption on a data buffer of the specified size in CBC mode.\r
\r