XenevaOS
Loading...
Searching...
No Matches
Functions
block_cipher_internal.h File Reference

Lightweight abstraction layer for block ciphers with 128 bit blocks, for use by the GCM and CCM modules. More...

#include "mbedtls/build_info.h"
#include "mbedtls/cipher.h"
#include "mbedtls/block_cipher.h"
Include dependency graph for block_cipher_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mbedtls_block_cipher_setup (mbedtls_block_cipher_context_t *ctx, mbedtls_cipher_id_t cipher_id)
 Set the block cipher to use with this context. This must be called after mbedtls_block_cipher_init().
 
int mbedtls_block_cipher_setkey (mbedtls_block_cipher_context_t *ctx, const unsigned char *key, unsigned key_bitlen)
 Set the key into the context.
 
int mbedtls_block_cipher_encrypt (mbedtls_block_cipher_context_t *ctx, const unsigned char input[16], unsigned char output[16])
 Encrypt one block (16 bytes) with the configured key.
 
void mbedtls_block_cipher_free (mbedtls_block_cipher_context_t *ctx)
 Clear the context.
 

Detailed Description

Lightweight abstraction layer for block ciphers with 128 bit blocks, for use by the GCM and CCM modules.

Function Documentation

◆ mbedtls_block_cipher_encrypt()

int mbedtls_block_cipher_encrypt ( mbedtls_block_cipher_context_t *  ctx,
const unsigned char  input[16],
unsigned char  output[16] 
)

Encrypt one block (16 bytes) with the configured key.

Parameters
ctxThe context holding the key.
inputThe buffer holding the input block. Must be 16 bytes.
outputThe buffer to which the output block will be written. Must be writable and 16 bytes long. This must either not overlap with input, or be equal.
Return values

c 0 on success.

Return values
MBEDTLS_ERR_CIPHER_INVALID_CONTEXTif the context was not properly set up before calling this function.
Anothernegative value if encryption failed.

◆ mbedtls_block_cipher_free()

void mbedtls_block_cipher_free ( mbedtls_block_cipher_context_t *  ctx)

Clear the context.

Parameters
ctxThe context to clear.

◆ mbedtls_block_cipher_setkey()

int mbedtls_block_cipher_setkey ( mbedtls_block_cipher_context_t *  ctx,
const unsigned char *  key,
unsigned  key_bitlen 
)

Set the key into the context.

Parameters
ctxThe context to configure.
keyThe buffer holding the key material.
key_bitlenThe size of the key in bits.
Return values

c 0 on success.

Return values
MBEDTLS_ERR_CIPHER_INVALID_CONTEXTif the context was not properly set up before calling this function.
Oneof MBEDTLS_ERR_AES_INVALID_KEY_LENGTH, MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA if key_bitlen is invalid.

◆ mbedtls_block_cipher_setup()

int mbedtls_block_cipher_setup ( mbedtls_block_cipher_context_t *  ctx,
mbedtls_cipher_id_t  cipher_id 
)

Set the block cipher to use with this context. This must be called after mbedtls_block_cipher_init().

Parameters
ctxThe context to set up.
cipher_idThe identifier of the cipher to use. This must be either AES, ARIA or Camellia. Warning: this is a mbedtls_cipher_id_t, not a mbedtls_block_cipher_id_t!
Return values

c 0 on success.

Return values
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATAif cipher_id was invalid.