OPTIGA Trust M  1.1.0
C++ library for Optiga Trust M Chip Security Controller
blowfish.h File Reference

Blowfish block cipher. More...

#include "config.h"
#include <stddef.h>
#include <stdint.h>
#include "platform_util.h"
Include dependency graph for blowfish.h:

Go to the source code of this file.

Classes

struct  mbedtls_blowfish_context
 Blowfish context structure. More...
 

Macros

#define MBEDTLS_BLOWFISH_ENCRYPT   1
 
#define MBEDTLS_BLOWFISH_DECRYPT   0
 
#define MBEDTLS_BLOWFISH_MAX_KEY_BITS   448
 
#define MBEDTLS_BLOWFISH_MIN_KEY_BITS   32
 
#define MBEDTLS_BLOWFISH_ROUNDS   16
 
#define MBEDTLS_BLOWFISH_BLOCKSIZE   8 /* Blowfish uses 64 bit blocks */
 
#define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH   MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x0016 )
 
#define MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA   -0x0016
 
#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH   -0x0018
 
#define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED   -0x0017
 

Typedefs

typedef struct mbedtls_blowfish_context mbedtls_blowfish_context
 Blowfish context structure. More...
 

Functions

void mbedtls_blowfish_init (mbedtls_blowfish_context *ctx)
 Initialize a Blowfish context. More...
 
void mbedtls_blowfish_free (mbedtls_blowfish_context *ctx)
 Clear a Blowfish context. More...
 
int mbedtls_blowfish_setkey (mbedtls_blowfish_context *ctx, const unsigned char *key, unsigned int keybits)
 Perform a Blowfish key schedule operation. More...
 
int mbedtls_blowfish_crypt_ecb (mbedtls_blowfish_context *ctx, int mode, const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE])
 Perform a Blowfish-ECB block encryption/decryption operation. More...
 

Detailed Description

Blowfish block cipher.

Macro Definition Documentation

◆ MBEDTLS_BLOWFISH_BLOCKSIZE

#define MBEDTLS_BLOWFISH_BLOCKSIZE   8 /* Blowfish uses 64 bit blocks */

◆ MBEDTLS_BLOWFISH_DECRYPT

#define MBEDTLS_BLOWFISH_DECRYPT   0

◆ MBEDTLS_BLOWFISH_ENCRYPT

#define MBEDTLS_BLOWFISH_ENCRYPT   1

◆ MBEDTLS_BLOWFISH_MAX_KEY_BITS

#define MBEDTLS_BLOWFISH_MAX_KEY_BITS   448

◆ MBEDTLS_BLOWFISH_MIN_KEY_BITS

#define MBEDTLS_BLOWFISH_MIN_KEY_BITS   32

◆ MBEDTLS_BLOWFISH_ROUNDS

#define MBEDTLS_BLOWFISH_ROUNDS   16

Rounds to use. When increasing this value, make sure to extend the initialisation vectors

◆ MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA

#define MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA   -0x0016

Bad input data.

◆ MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED

#define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED   -0x0017

Blowfish hardware accelerator failed.

◆ MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH

#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH   -0x0018

Invalid data input length.

◆ MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH

#define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH   MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x0016 )

Typedef Documentation

◆ mbedtls_blowfish_context

Blowfish context structure.

Function Documentation

◆ mbedtls_blowfish_crypt_ecb()

int mbedtls_blowfish_crypt_ecb ( mbedtls_blowfish_context ctx,
int  mode,
const unsigned char  input[MBEDTLS_BLOWFISH_BLOCKSIZE],
unsigned char  output[MBEDTLS_BLOWFISH_BLOCKSIZE] 
)

Perform a Blowfish-ECB block encryption/decryption operation.

Parameters
ctxThe Blowfish context to use. This must be initialized and bound to a key.
modeThe mode of operation. Possible values are MBEDTLS_BLOWFISH_ENCRYPT for encryption, or MBEDTLS_BLOWFISH_DECRYPT for decryption.
inputThe input block. This must be a readable buffer of size 8 Bytes.
outputThe output block. This must be a writable buffer of size 8 Bytes.
Returns
0 if successful.
A negative error code on failure.

◆ mbedtls_blowfish_free()

void mbedtls_blowfish_free ( mbedtls_blowfish_context ctx)

Clear a Blowfish context.

Parameters
ctxThe Blowfish context to be cleared. This may be NULL, in which case this function returns immediately. If it is not NULL, it must point to an initialized Blowfish context.

◆ mbedtls_blowfish_init()

void mbedtls_blowfish_init ( mbedtls_blowfish_context ctx)

Initialize a Blowfish context.

Parameters
ctxThe Blowfish context to be initialized. This must not be NULL.

◆ mbedtls_blowfish_setkey()

int mbedtls_blowfish_setkey ( mbedtls_blowfish_context ctx,
const unsigned char *  key,
unsigned int  keybits 
)

Perform a Blowfish key schedule operation.

Parameters
ctxThe Blowfish context to perform the key schedule on.
keyThe encryption key. This must be a readable buffer of length keybits Bits.
keybitsThe length of key in Bits. This must be between 32 and 448 and a multiple of 8.
Returns
0 if successful.
A negative error code on failure.