POK
|
Ceasar crypto protocol. More...
Go to the source code of this file.
Functions | |
void | pok_protocols_ceasar_unmarshall (void *crypted_data, pok_size_t crypted_size, void *uncrypted_data, size_t *uncrypted_size) |
void | pok_protocols_ceasar_marshall (void *uncrypted_data, pok_size_t uncrypted_size, void *crypted_data, size_t *crypted_size) |
Ceasar crypto protocol.
We don't provide an associated marshalling type for the Ceasar protocol since the crypted size is the same than the uncrypted size.
Definition in file ceasar.h.
void pok_protocols_ceasar_marshall | ( | void * | uncrypted_data, |
pok_size_t | uncrypted_size, | ||
void * | crypted_data, | ||
size_t * | crypted_size | ||
) |
Function that encrypts data
\file libpok/protocols/ceasar.c \brief Function to crypt/uncrypt data using the Ceasar cipher. \author Julien Delange \brief Marshall data, the crypted size has the same size than uncrypted data.
Definition at line 34 of file ceasar.c.
{ uint8_t* uncrypted; uint8_t* crypted; size_t tmp; uncrypted = (uint8_t*) uncrypted_data; crypted = (uint8_t*) crypted_data; for (tmp = 0 ; tmp < uncrypted_size ; tmp++) { crypted[tmp] = (uncrypted[tmp] + 4) % 255; } *crypted_size = uncrypted_size; }
void pok_protocols_ceasar_unmarshall | ( | void * | crypted_data, |
pok_size_t | crypted_size, | ||
void * | uncrypted_data, | ||
size_t * | uncrypted_size | ||
) |
Function that uncrypts data
\brief Unmarshall data, the crypted size has the same size than uncrypted data.
Definition at line 56 of file ceasar.c.
{ uint8_t* uncrypted; uint8_t* crypted; size_t tmp; uncrypted = (uint8_t*) uncrypted_data; crypted = (uint8_t*) crypted_data; for (tmp = 0 ; tmp < crypted_size ; tmp++) { uncrypted[tmp] = (crypted[tmp] - 4) % 255; } *uncrypted_size = crypted_size; }