12#include "InternalCryptLib.h"
13#include <mbedtls/gcm.h>
56 mbedtls_gcm_context Ctx;
59 if (DataInSize > INT_MAX) {
63 if (ADataSize > INT_MAX) {
80 if ((TagSize != 12) && (TagSize != 13) && (TagSize != 14) && (TagSize != 15) && (TagSize != 16)) {
84 if (DataOutSize !=
NULL) {
85 if ((*DataOutSize > INT_MAX) || (*DataOutSize < DataInSize)) {
90 mbedtls_gcm_init (&Ctx);
92 Ret = mbedtls_gcm_setkey (&Ctx, MBEDTLS_CIPHER_ID_AES, Key, (UINT32)(KeySize * 8));
97 Ret = mbedtls_gcm_crypt_and_tag (
110 mbedtls_gcm_free (&Ctx);
115 if (DataOutSize !=
NULL) {
116 *DataOutSize = DataInSize;
164 mbedtls_gcm_context Ctx;
167 if (DataInSize > INT_MAX) {
171 if (ADataSize > INT_MAX) {
188 if ((TagSize != 12) && (TagSize != 13) && (TagSize != 14) && (TagSize != 15) && (TagSize != 16)) {
192 if (DataOutSize !=
NULL) {
193 if ((*DataOutSize > INT_MAX) || (*DataOutSize < DataInSize)) {
198 mbedtls_gcm_init (&Ctx);
200 Ret = mbedtls_gcm_setkey (&Ctx, MBEDTLS_CIPHER_ID_AES, Key, (UINT32)(KeySize * 8));
205 Ret = mbedtls_gcm_auth_decrypt (
217 mbedtls_gcm_free (&Ctx);
222 if (DataOutSize !=
NULL) {
223 *DataOutSize = DataInSize;
BOOLEAN EFIAPI AeadAesGcmDecrypt(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Iv, IN UINTN IvSize, IN CONST UINT8 *AData, IN UINTN ADataSize, IN CONST UINT8 *DataIn, IN UINTN DataInSize, IN CONST UINT8 *Tag, IN UINTN TagSize, OUT UINT8 *DataOut, OUT UINTN *DataOutSize)
BOOLEAN EFIAPI AeadAesGcmEncrypt(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Iv, IN UINTN IvSize, IN CONST UINT8 *AData, IN UINTN ADataSize, IN CONST UINT8 *DataIn, IN UINTN DataInSize, OUT UINT8 *TagOut, IN UINTN TagSize, OUT UINT8 *DataOut, OUT UINTN *DataOutSize)