RIOT provides a collection of block cipher ciphers, different operation modes and cryptographic hash algorithms. More...

Detailed Description


Riot supports the following block ciphers:

You can use them directly by adding "crypto" to your USEMODULE-List. While you can use the ciphers functions directly, you should resort to the generic API for block ciphers whenever possible.

Additionally you need to set a CFLAG for each cipher you want to use in your Makefile:


#include "crypto/ciphers.h"
cipher_t cipher;
uint8_t key[AES_KEY_SIZE] = {0},
plain_text[AES_BLOCK_SIZE] = {0},
cipher_text[AES_BLOCK_SIZE] = {0};
if (cipher_init(&cipher, CIPHER_AES_128, key, AES_KEY_SIZE) < 0)
printf("Cipher init failed!\n");
if (cipher_encrypt(&cipher, plain_text, cipher_text) < 0)
printf("Cipher encryption failed!\n");
od_hex_dump(cipher_text, AES_BLOCK_SIZE, 0);

If you need to encrypt data of arbitrary size take a look at the different operation modes like: CBC, CTR or CCM.

Additional examples can be found in the test suite.


file  aes.h
 Headers for the implementation of the AES cipher-algorithm.
file  chacha.h
 ChaCha stream cipher.
file  ciphers.h
 Headers for the packet encryption class.
file  helper.h
 helper functions for sys_crypto_modes
file  cbc.h
 Cipher block chaining mode of operation for block ciphers.
file  ccm.h
 Counter with CBC-MAC mode of operation for block ciphers.
file  ctr.h
 Counter mode of operation for block ciphers.
file  ecb.h
 Electronic code book mode of operation for block ciphers.