cbc.h File Reference

Cipher block chaining mode of operation for block ciphers. More...

Detailed Description

Cipher block chaining mode of operation for block ciphers.

Author
Freie Universitaet Berlin, Computer Systems & Telematics
Nico von Geyso nico..nosp@m.geys.nosp@m.o@fu-.nosp@m.berl.nosp@m.in.de

Definition in file cbc.h.

#include <stddef.h>
#include "crypto/ciphers.h"
+ Include dependency graph for cbc.h:

Go to the source code of this file.

int cipher_encrypt_cbc (const cipher_t *cipher, uint8_t iv[16], const uint8_t *input, size_t input_len, uint8_t *output)
 Encrypt data of arbitrary length in cipher block chaining mode. More...
 
int cipher_decrypt_cbc (const cipher_t *cipher, uint8_t iv[16], const uint8_t *input, size_t input_len, uint8_t *output)
 Decrypt encrypted data in cipher block chaining mode. More...
 

Function Documentation

◆ cipher_decrypt_cbc()

int cipher_decrypt_cbc ( const cipher_t cipher,
uint8_t  iv[16],
const uint8_t *  input,
size_t  input_len,
uint8_t *  output 
)

Decrypt encrypted data in cipher block chaining mode.

Parameters
cipherAlready initialized cipher struct
iv16 octet initialization vector.
inputpointer to input data to decrypt
input_lenlength of the input data
outputpointer to allocated memory for plaintext data. It has to be of size input_len.
Returns
<0 on error
CIPHER_ERR_INVALID_LENGTH when input_len % BLOCK_SIZE != 0
CIPHER_ERR_DEC_FAILED on internal decryption error
otherwise number of bytes decrypted

◆ cipher_encrypt_cbc()

int cipher_encrypt_cbc ( const cipher_t cipher,
uint8_t  iv[16],
const uint8_t *  input,
size_t  input_len,
uint8_t *  output 
)

Encrypt data of arbitrary length in cipher block chaining mode.

Parameters
cipherAlready initialized cipher struct
iv16 octet initialization vector. Must never be used more than once for a given key.
inputpointer to input data to encrypt
input_lenlength of the input data
outputpointer to allocated memory for encrypted data. It has to be of size data_len + BLOCK_SIZE - data_len % BLOCK_SIZE.
Returns
<0 on error
CIPHER_ERR_INVALID_LENGTH when input_len % BLOCK_SIZE != 0
CIPHER_ERR_ENC_FAILED on internal encryption error
otherwise number of input bytes that aren't consumed