POK
ceasar.h File Reference

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)

Detailed Description

Ceasar crypto protocol.

Author:
Julien Delange
Date:
2009 This is a very basic crypto protocol that just change the order of bytes in data. There is no public/private key, the algorithm is known by the attacker so that it's a very weak crypto protocol. Interested people can gather more information about this protocol on: http://en.wikipedia.org/wiki/Caesar_cipher

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.


Function Documentation

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;
}