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

Headers for the packet encryption class. More...

Detailed Description

They are used to encrypt single packets.

Author
Freie Universitaet Berlin, Computer Systems & Telematics
Nicolai Schmittberger nicol.nosp@m.ai.s.nosp@m.chmit.nosp@m.tber.nosp@m.ger@f.nosp@m.u-be.nosp@m.rlin..nosp@m.de
Zakaria Kasmi zkasm.nosp@m.i@in.nosp@m.f.fu-.nosp@m.berl.nosp@m.in.de
Mark Essien marke.nosp@m.ssie.nosp@m.n@gma.nosp@m.il.c.nosp@m.om

Definition in file ciphers.h.

#include <stdint.h>
+ Include dependency graph for ciphers.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cipher_context_t
 the context for cipher-operations More...
 
struct  cipher_interface_st
 BlockCipher-Interface for the Cipher-Algorithms. More...
 
struct  cipher_t
 basic struct for using block ciphers contains the cipher interface and the context More...
 
#define CIPHERS_MAX_KEY_SIZE   20
 the length of keys in bytes
 
#define CIPHER_MAX_BLOCK_SIZE   16
 
#define CIPHER_MAX_CONTEXT_SIZE   1
 Context sizes needed for the different ciphers. More...
 
#define CIPHER_ERR_INVALID_KEY_SIZE   -3
 
#define CIPHER_ERR_INVALID_LENGTH   -4
 
#define CIPHER_ERR_ENC_FAILED   -5
 
#define CIPHER_ERR_DEC_FAILED   -6
 
#define CIPHER_ERR_BAD_CONTEXT_SIZE   0
 Is returned by the cipher_init functions, if the coresponding alogirithm has not been included in the build.
 
#define CIPHER_INIT_SUCCESS   1
 Returned by cipher_init upon succesful initialization of a cipher. More...
 
typedef struct cipher_interface_st cipher_interface_t
 BlockCipher-Interface for the Cipher-Algorithms.
 
typedef const cipher_interface_tcipher_id_t
 
const cipher_id_t CIPHER_3DES
 
const cipher_id_t CIPHER_AES_128
 
int cipher_init (cipher_t *cipher, cipher_id_t cipher_id, const uint8_t *key, uint8_t key_size)
 Initialize new cipher state. More...
 
int cipher_encrypt (const cipher_t *cipher, const uint8_t *input, uint8_t *output)
 Encrypt data of BLOCK_SIZE length *. More...
 
int cipher_decrypt (const cipher_t *cipher, const uint8_t *input, uint8_t *output)
 Decrypt data of BLOCK_SIZE length *. More...
 
int cipher_get_block_size (const cipher_t *cipher)
 Get block size of cipher *. More...
 

Macro Definition Documentation

#define CIPHER_INIT_SUCCESS   1

Definition at line 69 of file ciphers.h.

#define CIPHER_MAX_CONTEXT_SIZE   1

Always order by number of bytes descending!!!

threedes needs 24 bytes
aes needs CIPHERS_MAX_KEY_SIZE bytes

Definition at line 57 of file ciphers.h.

Function Documentation

int cipher_decrypt ( const cipher_t cipher,
const uint8_t *  input,
uint8_t *  output 
)
Parameters
cipherAlready initialized cipher struct
inputpointer to input data (of size BLOCKS_SIZE) to decrypt
outputpointer to allocated memory for decrypted data. It has to be of size BLOCK_SIZE
int cipher_encrypt ( const cipher_t cipher,
const uint8_t *  input,
uint8_t *  output 
)
Parameters
cipherAlready initialized cipher struct
inputpointer to input data to encrypt
outputpointer to allocated memory for encrypted data. It has to be of size BLOCK_SIZE
int cipher_get_block_size ( const cipher_t cipher)
Parameters
cipherAlready initialized cipher struct
int cipher_init ( cipher_t cipher,
cipher_id_t  cipher_id,
const uint8_t *  key,
uint8_t  key_size 
)
Parameters
ciphercipher struct to init (already allocated memory)
cipher_idcipher algorithm id
keyencryption key to use
key_sizelength of the encryption key
Returns
CIPHER_INIT_SUCCESS if the initialization was successful. The command may be unsuccessful if the key size is not valid. CIPHER_ERR_BAD_CONTEXT_SIZE if CIPHER_MAX_CONTEXT_SIZE has not been defined (which means that the cipher has not been included in the build)