aes.h File Reference
The Advanced Encryption Standard (AES) specifies a FIPS-approved cryptographic algorithm that can be used to protect electronic data.
More...
#include "config.h"
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures |
struct | mbedtls_aes_context |
| The AES context-type definition. More...
|
Defines |
#define | MBEDTLS_AES_ENCRYPT 1 |
#define | MBEDTLS_AES_DECRYPT 0 |
#define | MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 |
#define | MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 |
#define | MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 |
#define | MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 |
#define | MBEDTLS_DEPRECATED |
Functions |
void | mbedtls_aes_init (mbedtls_aes_context *ctx) |
| This function initializes the specified AES context.
|
void | mbedtls_aes_free (mbedtls_aes_context *ctx) |
| This function releases and clears the specified AES context.
|
int | mbedtls_aes_setkey_enc (mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits) |
| This function sets the encryption key.
|
int | mbedtls_aes_setkey_dec (mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits) |
| This function sets the decryption key.
|
int | mbedtls_aes_crypt_ecb (mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16]) |
| This function performs an AES single-block encryption or decryption operation.
|
int | mbedtls_internal_aes_encrypt (mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16]) |
| Internal AES block encryption function. This is only exposed to allow overriding it using MBEDTLS_AES_ENCRYPT_ALT .
|
int | mbedtls_internal_aes_decrypt (mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16]) |
| Internal AES block decryption function. This is only exposed to allow overriding it using see MBEDTLS_AES_DECRYPT_ALT .
|
MBEDTLS_DEPRECATED void | mbedtls_aes_encrypt (mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16]) |
| Deprecated internal AES block encryption function without return value.
|
MBEDTLS_DEPRECATED void | mbedtls_aes_decrypt (mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16]) |
| Deprecated internal AES block decryption function without return value.
|
int | mbedtls_aes_self_test (int verbose) |
| Checkup routine.
|
Detailed Description
The Advanced Encryption Standard (AES) specifies a FIPS-approved cryptographic algorithm that can be used to protect electronic data.
The AES algorithm is a symmetric block cipher that can encrypt and decrypt information. For more information, see FIPS Publication 197: Advanced Encryption Standard and ISO/IEC 18033-2:2006: Information technology -- Security techniques -- Encryption algorithms -- Part 2: Asymmetric ciphers.
Definition in file aes.h.
Define Documentation
#define MBEDTLS_AES_DECRYPT 0 |
AES decryption.
Definition at line 75 of file aes.h.
#define MBEDTLS_AES_ENCRYPT 1 |
AES encryption.
Definition at line 74 of file aes.h.
#define MBEDTLS_DEPRECATED |
#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 |
Feature not available. For example, an unsupported AES key size.
Definition at line 82 of file aes.h.
#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 |
AES hardware accelerator failed.
Definition at line 83 of file aes.h.
#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 |
Invalid data input length.
Definition at line 79 of file aes.h.
#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 |
Invalid key length.
Definition at line 78 of file aes.h.
Function Documentation
int mbedtls_aes_crypt_ecb |
( |
mbedtls_aes_context * |
ctx, |
|
|
int |
mode, |
|
|
const unsigned char |
input[16], |
|
|
unsigned char |
output[16] | |
|
) |
| | |
This function performs an AES single-block encryption or decryption operation.
It performs the operation defined in the mode
parameter (encrypt or decrypt), on the input data buffer defined in the input
parameter.
mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called before the first call to this API with the same context.
- Parameters:
-
| ctx | The AES context to use for encryption or decryption. |
| mode | The AES operation: MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT. |
| input | The 16-Byte buffer holding the input data. |
| output | The 16-Byte buffer holding the output data. |
- Returns:
0
on success.
MBEDTLS_DEPRECATED void mbedtls_aes_decrypt |
( |
mbedtls_aes_context * |
ctx, |
|
|
const unsigned char |
input[16], |
|
|
unsigned char |
output[16] | |
|
) |
| | |
Deprecated internal AES block decryption function without return value.
- Deprecated:
- Superseded by mbedtls_aes_decrypt_ext() in 2.5.0.
- Parameters:
-
| ctx | The AES context to use for decryption. |
| input | Ciphertext block. |
| output | Output (plaintext) block. |
MBEDTLS_DEPRECATED void mbedtls_aes_encrypt |
( |
mbedtls_aes_context * |
ctx, |
|
|
const unsigned char |
input[16], |
|
|
unsigned char |
output[16] | |
|
) |
| | |
Deprecated internal AES block encryption function without return value.
- Deprecated:
- Superseded by mbedtls_aes_encrypt_ext() in 2.5.0.
- Parameters:
-
| ctx | The AES context to use for encryption. |
| input | Plaintext block. |
| output | Output (ciphertext) block. |
This function releases and clears the specified AES context.
- Parameters:
-
| ctx | The AES context to clear. |
This function initializes the specified AES context.
It must be the first API called before using the context.
- Parameters:
-
| ctx | The AES context to initialize. |
int mbedtls_aes_self_test |
( |
int |
verbose |
) |
|
Checkup routine.
- Returns:
0
on success, or 1
on failure.
int mbedtls_aes_setkey_dec |
( |
mbedtls_aes_context * |
ctx, |
|
|
const unsigned char * |
key, |
|
|
unsigned int |
keybits | |
|
) |
| | |
This function sets the decryption key.
- Parameters:
-
| ctx | The AES context to which the key should be bound. |
| key | The decryption key. |
| keybits | The size of data passed. Valid options are:
-
128 bits
-
192 bits
-
256 bits
|
- Returns:
0
on success, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
int mbedtls_aes_setkey_enc |
( |
mbedtls_aes_context * |
ctx, |
|
|
const unsigned char * |
key, |
|
|
unsigned int |
keybits | |
|
) |
| | |
This function sets the encryption key.
- Parameters:
-
| ctx | The AES context to which the key should be bound. |
| key | The encryption key. |
| keybits | The size of data passed in bits. Valid options are:
-
128 bits
-
192 bits
-
256 bits
|
- Returns:
0
on success or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
int mbedtls_internal_aes_decrypt |
( |
mbedtls_aes_context * |
ctx, |
|
|
const unsigned char |
input[16], |
|
|
unsigned char |
output[16] | |
|
) |
| | |
Internal AES block decryption function. This is only exposed to allow overriding it using see MBEDTLS_AES_DECRYPT_ALT
.
- Parameters:
-
| ctx | The AES context to use for decryption. |
| input | The ciphertext block. |
| output | The output (plaintext) block. |
- Returns:
0
on success.
int mbedtls_internal_aes_encrypt |
( |
mbedtls_aes_context * |
ctx, |
|
|
const unsigned char |
input[16], |
|
|
unsigned char |
output[16] | |
|
) |
| | |
Internal AES block encryption function. This is only exposed to allow overriding it using MBEDTLS_AES_ENCRYPT_ALT
.
- Parameters:
-
| ctx | The AES context to use for encryption. |
| input | The plaintext block. |
| output | The output (ciphertext) block. |
- Returns:
0
on success.