bfcodec 0.0.4
Tools and a C/C++ library to manipulate BFCodec-encrypted content
Loading...
Searching...
No Matches
Macros | Typedefs | Functions
bfcodec.h File Reference
#include <stddef.h>
#include <stdint.h>
Include dependency graph for bfcodec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct C_BLOWFISH C_BLOWFISH
 

Functions

BFCODEC_API C_BLOWFISHbfcodec_init (void)
 Allocate and initialise a Blowfish codec with pi-derived P and S boxes.
 
BFCODEC_API void bfcodec_expand_key (C_BLOWFISH *blf, const uint8_t *key, size_t key_len)
 Expand key into the codec state (XOR P with key bytes, then expand via encrypt).
 
BFCODEC_API void bfcodec_decrypt (C_BLOWFISH *blf, uint8_t *data, size_t len, const uint8_t iv[8])
 Decrypt data in place using CBC with the given 8-byte IV.
 
BFCODEC_API void bfcodec_encrypt (C_BLOWFISH *blf, uint8_t *data, size_t len, const uint8_t iv[8])
 Encrypt data in place using CBC with the given 8-byte IV.
 

Function Documentation

◆ bfcodec_decrypt()

BFCODEC_API void bfcodec_decrypt ( C_BLOWFISH blf,
uint8_t *  data,
size_t  len,
const uint8_t  iv[8] 
)

Decrypt data in place using CBC with the given 8-byte IV.

Parameters
blfCodec instance with key already expanded.
dataBuffer to decrypt in place.
lenLength of data in bytes; must be a multiple of 8.
ivInitialisation vector; exactly 8 bytes.

◆ bfcodec_encrypt()

BFCODEC_API void bfcodec_encrypt ( C_BLOWFISH blf,
uint8_t *  data,
size_t  len,
const uint8_t  iv[8] 
)

Encrypt data in place using CBC with the given 8-byte IV.

Parameters
blfCodec instance with key already expanded.
dataBuffer to encrypt in place.
lenLength of data in bytes; must be a multiple of 8.
ivInitialisation vector; exactly 8 bytes.

◆ bfcodec_expand_key()

BFCODEC_API void bfcodec_expand_key ( C_BLOWFISH blf,
const uint8_t *  key,
size_t  key_len 
)

Expand key into the codec state (XOR P with key bytes, then expand via encrypt).

Parameters
blfCodec instance from bfcodec_init().
keyKey bytes; key_len may be any positive length.
key_lenLength of key in bytes; key bytes are used big-endian in 32-bit chunks.

◆ bfcodec_init()

BFCODEC_API C_BLOWFISH * bfcodec_init ( void  )

Allocate and initialise a Blowfish codec with pi-derived P and S boxes.

Returns
A new codec instance, or NULL on allocation failure.