ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Macros | Functions
xxtea.c File Reference

XXTEA block cipher. More...

#include <lib/random/xxtea.h>
#include <assert.h>
Include dependency graph for xxtea.c:

Macros

#define XXTEA_DELTA   UINT32_C(0x9e3779b9)
 XXTEA magic number.
 

Functions

static uint32_t xxtea_mx (uint32_t y, uint32_t z, uint32_t sum, unsigned p, unsigned e, const uint32_t key[4])
 Main XXTEA Feistel network based routine. More...
 
void xxtea_encode (uint32_t *restrict v, unsigned n, uint32_t const key[restrict 4])
 Encode a array of data with the XXTEA algorithm Encoding is done in place. More...
 
void xxtea_decode (uint32_t *restrict v, unsigned n, uint32_t const key[restrict 4])
 Decode a array of data with the XXTEA algorithm Decoding is done in place. More...
 

Detailed Description

XXTEA block cipher.

An implementation of the XXTEA block cipher (code based on "Correction to xtea" by David J. Wheeler and Roger M. Needham)

Function Documentation

◆ xxtea_decode()

void xxtea_decode ( uint32_t *restrict  v,
unsigned  n,
uint32_t const  key[restrict 4] 
)

Decode a array of data with the XXTEA algorithm Decoding is done in place.

Parameters
va pointer to the array of data to decode
nthe number of 32 bits blocks in v
keythe key used to perform the decoding

◆ xxtea_encode()

void xxtea_encode ( uint32_t *restrict  v,
unsigned  n,
uint32_t const  key[restrict 4] 
)

Encode a array of data with the XXTEA algorithm Encoding is done in place.

Parameters
va pointer to the array of data to encode
nthe number of 32 bits blocks in v
keythe key used to perform the encoding

◆ xxtea_mx()

static uint32_t xxtea_mx ( uint32_t  y,
uint32_t  z,
uint32_t  sum,
unsigned  p,
unsigned  e,
const uint32_t  key[4] 
)
inlinestatic

Main XXTEA Feistel network based routine.

Parameters
ythe y block to mix
zthe z block to mix
sumthe cumulative sum of XXTEA delta values
pan helper key block selector value
ean helper key block selector value
keythe key used for encoding/decoding
Returns
the value of the next y/z block