Headers for the packet encryption class.  
More...
Headers for the packet encryption class. 
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 "modules.h"
 
Go to the source code of this file.
◆ CIPHER_MAX_CONTEXT_SIZE
      
        
          | #define CIPHER_MAX_CONTEXT_SIZE   1 | 
        
      
 
Context sizes needed for the different ciphers. 
Always order by number of bytes descending!!! 
aes needs CIPHERS_MAX_KEY_SIZE bytes 
 
Definition at line 59 of file ciphers.h.
 
 
◆ CIPHERS_MAX_KEY_SIZE
      
        
          | #define CIPHERS_MAX_KEY_SIZE   16 | 
        
      
 
the length of keys in bytes 
As of now AES is the only cipher which supports different key sizes. Here we optimize the CIPHERS_MAX_KEY_SIZE to always have the smallest possible value based on which AES key sizes are used. 
Definition at line 44 of file ciphers.h.
 
 
◆ cipher_decrypt()
      
        
          | int cipher_decrypt  | 
          ( | 
          const cipher_t *  | 
          cipher,  | 
        
        
           | 
           | 
          const uint8_t *  | 
          input,  | 
        
        
           | 
           | 
          uint8_t *  | 
          output  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Decrypt data of BLOCK_SIZE length *. 
- Parameters
 - 
  
    | cipher | Already initialized cipher struct  | 
    | input | pointer to input data (of size BLOCKS_SIZE) to decrypt  | 
    | output | pointer to allocated memory for decrypted data. It has to be of size BLOCK_SIZE | 
  
   
- Returns
 - The result of the decrypt operation of the underlying cipher, which is always 1 in case of success 
 
- 
A negative value for an error 
 
 
 
◆ cipher_encrypt()
      
        
          | int cipher_encrypt  | 
          ( | 
          const cipher_t *  | 
          cipher,  | 
        
        
           | 
           | 
          const uint8_t *  | 
          input,  | 
        
        
           | 
           | 
          uint8_t *  | 
          output  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Encrypt data of BLOCK_SIZE length *. 
- Parameters
 - 
  
    | cipher | Already initialized cipher struct  | 
    | input | pointer to input data to encrypt  | 
    | output | pointer to allocated memory for encrypted data. It has to be of size BLOCK_SIZE | 
  
   
- Returns
 - The result of the encrypt operation of the underlying cipher, which is always 1 in case of success 
 
- 
A negative value for an error 
 
 
 
◆ cipher_get_block_size()
      
        
          | int cipher_get_block_size  | 
          ( | 
          const cipher_t *  | 
          cipher | ) | 
           | 
        
      
 
Get block size of cipher *. 
- Parameters
 - 
  
    | cipher | Already initialized cipher struct | 
  
   
- Returns
 - The cipher's block size (in bytes) 
 
 
 
◆ cipher_init()
      
        
          | int cipher_init  | 
          ( | 
          cipher_t *  | 
          cipher,  | 
        
        
           | 
           | 
          cipher_id_t  | 
          cipher_id,  | 
        
        
           | 
           | 
          const uint8_t *  | 
          key,  | 
        
        
           | 
           | 
          uint8_t  | 
          key_size  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Initialize new cipher state. 
- Parameters
 - 
  
    | cipher | cipher struct to init (already allocated memory)  | 
    | cipher_id | cipher algorithm id  | 
    | key | encryption key to use  | 
    | key_size | length of the encryption key | 
  
   
- Returns
 - CIPHER_INIT_SUCCESS if the initialization was successful. 
 
- 
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) 
 
- 
The command may return CIPHER_ERR_INVALID_KEY_SIZE if the key size is not valid.