PebbleOS v4.47.0
Loading...
Searching...
No Matches

AES block cipher (FIPS 197), on single blocks or in ECB mode. More...

Data Structures

struct  pbl_aes_ctx
 Expanded key. More...
 

Macros

#define PBL_AES_BLOCK_SIZE   16U
 Size of a block, in bytes.
 
#define PBL_AES_KEYSIZE_128   16U
 Size of an AES-128 key, in bytes.
 
#define PBL_AES_KEYSIZE_192   24U
 Size of an AES-192 key, in bytes.
 
#define PBL_AES_KEYSIZE_256   32U
 Size of an AES-256 key, in bytes.
 
#define PBL_AES_MAX_KEYLENGTH_U32   60U
 Most 32-bit words in a key schedule, for AES-256.
 

Functions

int pbl_aes_expandkey (struct pbl_aes_ctx *ctx, const uint8_t *key, size_t key_len)
 Expand a key.
 
void pbl_aes_encrypt (const struct pbl_aes_ctx *ctx, uint8_t out[PBL_AES_BLOCK_SIZE], const uint8_t in[PBL_AES_BLOCK_SIZE])
 Encrypt a block.
 
void pbl_aes_decrypt (const struct pbl_aes_ctx *ctx, uint8_t out[PBL_AES_BLOCK_SIZE], const uint8_t in[PBL_AES_BLOCK_SIZE])
 Decrypt a block.
 
int pbl_aes_ecb_encrypt (const struct pbl_aes_ctx *ctx, uint8_t *out, const uint8_t *in, size_t len)
 Encrypt blocks in ECB mode.
 
int pbl_aes_ecb_decrypt (const struct pbl_aes_ctx *ctx, uint8_t *out, const uint8_t *in, size_t len)
 Decrypt blocks in ECB mode.
 

Detailed Description

AES block cipher (FIPS 197), on single blocks or in ECB mode.

Runs of at least CONFIG_CRYPTO_AES_HW_MIN_LEN bytes are processed by a hardware accelerator when a driver provides one (see Crypto), the rest in software. Other modes of operation are built by the caller.

struct pbl_aes_ctx ctx;
ret = pbl_aes_ecb_encrypt(&ctx, buf, buf, len);
Expanded key.
Definition aes.h:41
int pbl_aes_ecb_encrypt(const struct pbl_aes_ctx *ctx, uint8_t *out, const uint8_t *in, size_t len)
Encrypt blocks in ECB mode.
#define PBL_AES_KEYSIZE_128
Size of an AES-128 key, in bytes.
Definition aes.h:31
int pbl_aes_expandkey(struct pbl_aes_ctx *ctx, const uint8_t *key, size_t key_len)
Expand a key.

Data Structure Documentation

◆ pbl_aes_ctx

struct pbl_aes_ctx

Expanded key.

Data Fields
uint32_t key_dec[PBL_AES_MAX_KEYLENGTH_U32] Decryption round keys.
uint32_t key_enc[PBL_AES_MAX_KEYLENGTH_U32] Encryption round keys; the first words are the key itself.
uint32_t key_length Key length in bytes.

Macro Definition Documentation

◆ PBL_AES_BLOCK_SIZE

#define PBL_AES_BLOCK_SIZE   16U

Size of a block, in bytes.

◆ PBL_AES_KEYSIZE_128

#define PBL_AES_KEYSIZE_128   16U

Size of an AES-128 key, in bytes.

◆ PBL_AES_KEYSIZE_192

#define PBL_AES_KEYSIZE_192   24U

Size of an AES-192 key, in bytes.

◆ PBL_AES_KEYSIZE_256

#define PBL_AES_KEYSIZE_256   32U

Size of an AES-256 key, in bytes.

◆ PBL_AES_MAX_KEYLENGTH_U32

#define PBL_AES_MAX_KEYLENGTH_U32   60U

Most 32-bit words in a key schedule, for AES-256.

Function Documentation

◆ pbl_aes_decrypt()

void pbl_aes_decrypt ( const struct pbl_aes_ctx *  ctx,
uint8_t  out[PBL_AES_BLOCK_SIZE],
const uint8_t  in[PBL_AES_BLOCK_SIZE] 
)

Decrypt a block.

Parameters
ctxExpanded key.
[out]outPlaintext, which may be in.
inCiphertext.

◆ pbl_aes_ecb_decrypt()

int pbl_aes_ecb_decrypt ( const struct pbl_aes_ctx *  ctx,
uint8_t *  out,
const uint8_t *  in,
size_t  len 
)

Decrypt blocks in ECB mode.

Parameters
ctxExpanded key.
[out]outPlaintext, which may be in.
inCiphertext.
lenLength of in in bytes, a multiple of PBL_AES_BLOCK_SIZE.
Return values
0on success.
-EINVALif len is not a multiple of PBL_AES_BLOCK_SIZE.

◆ pbl_aes_ecb_encrypt()

int pbl_aes_ecb_encrypt ( const struct pbl_aes_ctx *  ctx,
uint8_t *  out,
const uint8_t *  in,
size_t  len 
)

Encrypt blocks in ECB mode.

Parameters
ctxExpanded key.
[out]outCiphertext, which may be in.
inPlaintext.
lenLength of in in bytes, a multiple of PBL_AES_BLOCK_SIZE.
Return values
0on success.
-EINVALif len is not a multiple of PBL_AES_BLOCK_SIZE.

◆ pbl_aes_encrypt()

void pbl_aes_encrypt ( const struct pbl_aes_ctx *  ctx,
uint8_t  out[PBL_AES_BLOCK_SIZE],
const uint8_t  in[PBL_AES_BLOCK_SIZE] 
)

Encrypt a block.

Parameters
ctxExpanded key.
[out]outCiphertext, which may be in.
inPlaintext.

◆ pbl_aes_expandkey()

int pbl_aes_expandkey ( struct pbl_aes_ctx *  ctx,
const uint8_t *  key,
size_t  key_len 
)

Expand a key.

Parameters
[out]ctxExpanded key.
keyKey.
key_lenLength of key in bytes: PBL_AES_KEYSIZE_128, PBL_AES_KEYSIZE_192 or PBL_AES_KEYSIZE_256.
Return values
0on success.
-EINVALif key_len is not a valid key size.