TianoCore EDK2 master
Loading...
Searching...
No Matches
AesCore.c File Reference
#include "AesCore.h"

Go to the source code of this file.

Data Structures

struct  AES_KEY
 

Macros

#define AES_NB   4
 
#define ROTATE_RIGHT32(x, n)   (((x) >> (n)) | ((x) << (32-(n))))
 
#define LOAD32H(x, y)
 
#define STORE32H(x, y)
 
#define AES_FT0(x)   AesForwardTable[x]
 
#define AES_FT1(x)   ROTATE_RIGHT32(AesForwardTable[x], 8)
 
#define AES_FT2(x)   ROTATE_RIGHT32(AesForwardTable[x], 16)
 
#define AES_FT3(x)   ROTATE_RIGHT32(AesForwardTable[x], 24)
 

Functions

EFI_STATUS EFIAPI AesExpandKey (IN UINT8 *Key, IN UINTN KeyLenInBits, OUT AES_KEY *AesKey)
 
EFI_STATUS EFIAPI AesEncrypt (IN UINT8 *Key, IN UINT8 *InData, OUT UINT8 *OutData)
 

Variables

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT32 AesForwardTable []
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT32 Rcon []
 

Detailed Description

Core Primitive Implementation of the Advanced Encryption Standard (AES) algorithm. Refer to FIPS PUB 197 ("Advanced Encryption Standard (AES)") for detailed algorithm description of AES.

Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file AesCore.c.

Macro Definition Documentation

◆ AES_FT0

#define AES_FT0 (   x)    AesForwardTable[x]

Definition at line 95 of file AesCore.c.

◆ AES_FT1

#define AES_FT1 (   x)    ROTATE_RIGHT32(AesForwardTable[x], 8)

Definition at line 96 of file AesCore.c.

◆ AES_FT2

#define AES_FT2 (   x)    ROTATE_RIGHT32(AesForwardTable[x], 16)

Definition at line 97 of file AesCore.c.

◆ AES_FT3

#define AES_FT3 (   x)    ROTATE_RIGHT32(AesForwardTable[x], 24)

Definition at line 98 of file AesCore.c.

◆ AES_NB

#define AES_NB   4

Definition at line 17 of file AesCore.c.

◆ LOAD32H

#define LOAD32H (   x,
 
)
Value:
{ x = ((UINT32)((y)[0] & 0xFF) << 24) | ((UINT32)((y)[1] & 0xFF) << 16) | \
((UINT32)((y)[2] & 0xFF) << 8) | ((UINT32)((y)[3] & 0xFF)); }

Definition at line 87 of file AesCore.c.

◆ ROTATE_RIGHT32

#define ROTATE_RIGHT32 (   x,
 
)    (((x) >> (n)) | ((x) << (32-(n))))

Definition at line 82 of file AesCore.c.

◆ STORE32H

#define STORE32H (   x,
 
)
Value:
{ (y)[0] = (UINT8)(((x) >> 24) & 0xFF); (y)[1] = (UINT8)(((x) >> 16) & 0xFF); \
(y)[2] = (UINT8)(((x) >> 8) & 0xFF); (y)[3] = (UINT8)((x) & 0xFF); }

Definition at line 89 of file AesCore.c.

Function Documentation

◆ AesEncrypt()

EFI_STATUS EFIAPI AesEncrypt ( IN UINT8 *  Key,
IN UINT8 *  InData,
OUT UINT8 *  OutData 
)

Encrypts one single block data (128 bits) with AES algorithm.

Parameters
[in]KeyAES symmetric key buffer.
[in]InDataOne block of input plaintext to be encrypted.
[out]OutDataEncrypted output ciphertext.
Return values
EFI_SUCCESSAES Block Encryption succeeded.
EFI_INVALID_PARAMETEROne or more parameters are invalid.

Definition at line 215 of file AesCore.c.

◆ AesExpandKey()

EFI_STATUS EFIAPI AesExpandKey ( IN UINT8 *  Key,
IN UINTN  KeyLenInBits,
OUT AES_KEY AesKey 
)

AES Key Expansion. This function expands the cipher key into encryption schedule.

Parameters
[in]KeyAES symmetric key buffer.
[in]KeyLenInBitsKey length in bits (128, 192, or 256).
[out]AesKeyExpanded AES Key schedule for encryption.
Return values
EFI_SUCCESSAES key expansion succeeded.
EFI_INVALID_PARAMETERUnsupported key length.

Definition at line 123 of file AesCore.c.

Variable Documentation

◆ AesForwardTable

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT32 AesForwardTable[]

Definition at line 25 of file AesCore.c.

◆ Rcon

Initial value:
= {
0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000,
0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000
}

Definition at line 74 of file AesCore.c.