The friendly Operating System for the Internet of Things
ctr.h File Reference

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

Detailed Description

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.

Functions

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

Function Documentation

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

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.
int cipher_encrypt_ctr ( cipher_t cipher,
uint8_t  nonce_counter[16],
uint8_t  nonce_len,
uint8_t *  input,
size_t  length,
uint8_t *  output 
)
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.