px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_xtea.h : XTEA (eXtended Tiny Encryption Algorithm)

Description

Block cipher encryption/decryption algorithm.

File(s):

See also
http://en.wikipedia.org/wiki/XTEA

Macros

#define XTEA_KEY_SIZE_BYTES   16
 Key size in bytes. More...
 
#define XTEA_BLOCK_SIZE_BYTES   8
 Data block size in bytes. More...
 

Functions

void px_xtea_init (const uint32_t key[4])
 Initialise 128-bit key for encryption/decryption. More...
 
void px_xtea_encrypt (uint32_t data[2])
 Encrypt 64-bit data with 128-bit key. More...
 
size_t px_xtea_encrypt_data_ecb (const uint8_t *data_in, uint8_t *data_out, size_t nr_of_bytes)
 Encrypt a data buffer using Electronic Codebook (ECB) block cipher operation. More...
 
void px_xtea_decrypt (uint32_t data[2])
 Decrypt 64-bit data with 128-bit key. More...
 
size_t px_xtea_decrypt_data_ecb (const uint8_t *data_in, uint8_t *data_out, size_t nr_of_bytes)
 Decrypt a data buffer using Electronic Codebook (ECB) block cipher operation. More...
 

Macro Definition Documentation

◆ XTEA_KEY_SIZE_BYTES

#define XTEA_KEY_SIZE_BYTES   16

Key size in bytes.

Definition at line 46 of file px_xtea.h.

◆ XTEA_BLOCK_SIZE_BYTES

#define XTEA_BLOCK_SIZE_BYTES   8

Data block size in bytes.

Definition at line 48 of file px_xtea.h.

Function Documentation

◆ px_xtea_init()

void px_xtea_init ( const uint32_t  key[4])

Initialise 128-bit key for encryption/decryption.

Parameters
key4 x 32-bit values

Definition at line 44 of file px_xtea.c.

◆ px_xtea_encrypt()

void px_xtea_encrypt ( uint32_t  data[2])

Encrypt 64-bit data with 128-bit key.

Parameters
data2 x 32-bit values

Definition at line 54 of file px_xtea.c.

◆ px_xtea_encrypt_data_ecb()

size_t px_xtea_encrypt_data_ecb ( const uint8_t *  data_in,
uint8_t *  data_out,
size_t  nr_of_bytes 
)

Encrypt a data buffer using Electronic Codebook (ECB) block cipher operation.

If the data_in is not an exact multiple of the block size (8 bytes), zero padding is used for the last block. The data_out buffer MUST be a multiple of 8 bytes.

The data can be encrypted in place by setting both the data_in and data_out pointer to the start of the buffer to be encrypted.

Parameters
data_inPointer to data buffer to be encrypted
data_outPointer to data buffer to contain encrypted data
nr_of_bytesNumber of bytes to encrypt
Returns
size_t Number of bytes encrypted (multiple of block size)

Definition at line 72 of file px_xtea.c.

◆ px_xtea_decrypt()

void px_xtea_decrypt ( uint32_t  data[2])

Decrypt 64-bit data with 128-bit key.

Parameters
data2 x 32-bit values

Definition at line 112 of file px_xtea.c.

◆ px_xtea_decrypt_data_ecb()

size_t px_xtea_decrypt_data_ecb ( const uint8_t *  data_in,
uint8_t *  data_out,
size_t  nr_of_bytes 
)

Decrypt a data buffer using Electronic Codebook (ECB) block cipher operation.

If the data_in is not an exact multiple of the block size (8 bytes), zero padding is used for the last block. The data_out buffer MUST be a multiple of 8 bytes.

The data can be decrypted in place by setting both the data_in and data_out pointer to the start of the buffer to be decrypted.

Parameters
data_inPointer to data buffer to be decrypted
data_outPointer to data buffer to contain decrypted data
nr_of_bytesNumber of bytes to decrypt
Returns
size_t Number of bytes decrypted (multiple of block size)

Definition at line 130 of file px_xtea.c.