ciphers.h¶
Headers for the packet encryption class.
They are used to encrypt single packets.
-
CIPHERS_MAX_KEY_SIZE
¶ the length of keys in bytes
1
20
-
CIPHER_MAX_BLOCK_SIZE
¶ 1
16
-
CIPHER_MAX_CONTEXT_SIZE
¶ Context sizes needed for the different ciphers.
1
1
Always order by number of bytes descending!!!
threedes needs 24 bytes aes needs CIPHERS_MAX_KEY_SIZE bytes
-
CIPHER_ERR_INVALID_KEY_SIZE
¶ 1
-3
-
CIPHER_ERR_INVALID_LENGTH
¶ 1
-4
-
CIPHER_ERR_ENC_FAILED
¶ 1
-5
-
CIPHER_ERR_DEC_FAILED
¶ 1
-6
-
CIPHER_ERR_BAD_CONTEXT_SIZE
¶ Is returned by the cipher_init functions, if the coresponding alogirithm has not been included in the build.
1
0
-
CIPHER_INIT_SUCCESS
¶ Returned by cipher_init upon succesful initialization of a cipher.
1
1
-
struct cipher_interface_st
cipher_interface_t
¶ BlockCipher-Interface for the Cipher-Algorithms.
-
const
ciphers.h::cipher_interface_t
*cipher_id_t
¶
-
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.
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 Return values
- 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.
-
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 Return values
- The result of the encrypt operation of the underlying cipher, which is always 1 in case of success
- A negative value for an error
-
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 Return values
- The result of the decrypt operation of the underlying cipher, which is always 1 in case of success
- A negative value for an error
-
int
cipher_get_block_size
(const cipher_t * cipher)¶ Get block size of cipher *.
Parameters
cipher: Already initialized cipher struct Return values
- The cipher’s block size (in bytes)
-
struct
cipher_context_t
¶ the context for cipher-operations
-
uint8_t
context
()¶ buffer for cipher operations
-
uint8_t