Loading...
Searching...
No Matches
ctr.h File Reference

Counter mode of operation for block ciphers. More...

Detailed Description

Counter 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 ctr.h.

#include "crypto/ciphers.h"
+ Include dependency graph for ctr.h:

Go to the source code of this file.

int cipher_encrypt_ctr (const cipher_t *cipher, uint8_t nonce_counter[16], uint8_t nonce_len, const uint8_t *input, size_t length, uint8_t *output)
 Encrypt data of arbitrary length in counter mode.
 
int cipher_decrypt_ctr (const cipher_t *cipher, uint8_t nonce_counter[16], uint8_t nonce_len, const uint8_t *input, size_t length, uint8_t *output)
 Decrypt data of arbitrary length in counter mode.
 

Function Documentation

◆ cipher_decrypt_ctr()

int cipher_decrypt_ctr ( const cipher_t cipher,
uint8_t  nonce_counter[16],
uint8_t  nonce_len,
const uint8_t *  input,
size_t  length,
uint8_t *  output 
)

Decrypt data of arbitrary length in counter mode.

Encryption and decryption in ctr mode are basically the same.

Parameters
cipherAlready initialized cipher struct
nonce_counterA nounce and a counter encoded in 16 octets. The counter will be modified in each block encryption.
nonce_lenLength of the nonce in octets. As nounce and counter have to fit in one aligned 16 octet block, maximum length of nonce is limited by input_len: 16 - log_2(input_len)
inputpointer to input data to encrypt
lengthlength of the input data
outputpointer to allocated memory for encrypted data. It has to be of size data_len.
Returns
Length of decrypted data on a successful decryption
A negative error code if something went wrong

◆ cipher_encrypt_ctr()

int cipher_encrypt_ctr ( const cipher_t cipher,
uint8_t  nonce_counter[16],
uint8_t  nonce_len,
const uint8_t *  input,
size_t  length,
uint8_t *  output 
)

Encrypt data of arbitrary length in counter mode.

Parameters
cipherAlready initialized cipher struct
nonce_counterA nounce and a counter encoded in 16 octets. The counter will be modified in each block encryption.
nonce_lenLength of the nonce in octets. As nounce and counter have to fit in one aligned 16 octet block, maximum length of nonce is limited by input_len: 16 - log_2(input_len)
inputpointer to input data to encrypt
lengthlength of the input data
outputpointer to allocated memory for encrypted data. It has to be of size data_len.
Returns
Length of encrypted data on a successful encryption
A negative error code if something went wrong