Solaris Software
Loading...
Searching...
No Matches
encryption.c File Reference
#include "encryption.h"
#include <stdlib.h>
Include dependency graph for encryption.c:

Go to the source code of this file.

Macros

#define IMPLEMENT(x)
#define INCREASE_SECURITY   0
#define AVOID_FUNCTION_CALL   0
#define SMALL_CIPHER   0
#define SBoxValue(x)
#define InvSBoxValue(x)
#define COPYDWORD(x, y)
#define XOR32BITS(x, y)
#define XOR64BITS(x, y)
#define AES_setkey(key)
#define BURN(key)
#define SABOTAGE(buf, len)
#define memcmp_s   memcmp
#define IV_KWA   "\xA6\xA6\xA6\xA6\xA6\xA6\xA6\xA6"
#define ALPHABET   "0123456789"
#define RADIX   10
#define LOGRDX   3.32192809488736
#define MINLEN   6
#define MAXLEN   56
#define FPE_PERMUTE   FF1_cipher
#define TWEAK_PARAMS   uint8_t* tweak, const size_t tweakLen
#define TWEAK_AGRS   tweak, tweakLen

Typedefs

typedef uint8_t block_t[BLOCKSIZE]
typedef uint8_t state_t[Nb][4]
typedef void(*) fmix_t(const block_t, block_t)
typedef char alpha_t
typedef unsigned short radix_t

Enumerations

enum  basic_constants {
  BLOCKSIZE = 128 / 8 , KEYSIZE = AES_KEYLENGTH , Nb = BLOCKSIZE / 4 , Nk = KEYSIZE / 4 ,
  ROUNDS = Nk + 6 , HB = BLOCKSIZE / 2 , LAST = BLOCKSIZE - 1 , MIDST = LAST / 2 ,
  PL = BLOCKSIZE + 1
}
enum  ctr_based_modes { CTR_DEFAULT , SIV_CTR = 'S' , SIVGCM_CTR = 'S' & 'G' , CCM_GCM = 'C' | 'G' }

Functions

static uint8_t xtime (uint8_t x)
static void xorBlock (const block_t src, block_t dest)
static uint8_t mixG8 (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
static void KeyExpansion (const uint8_t *key)
static void AddRoundKey (const uint8_t round, block_t state)
static void SubBytes (block_t state)
static void ShiftRows (state_t state)
static void MixColumns (state_t state)
static void rijndaelEncrypt (const block_t input, block_t output)
static void InvSubBytes (block_t state)
static void InvShiftRows (state_t state)
static void InvMixColumns (state_t state)
static void rijndaelDecrypt (const block_t input, block_t output)
static void xorBEint (uint8_t *buff, size_t num, uint8_t pos)
static void incBlock (block_t block, uint8_t index)
static void doubleBblock (block_t array)
static void doubleLblock (block_t array)
static void divideBblock (block_t array)
static void mulGF128 (const block_t x, block_t y)
static void divideLblock (block_t array)
static void dotGF128 (const block_t x, block_t y)
static void mixThenXor (fmix_t mix, const block_t B, block_t f, const uint8_t *X, uint8_t n, uint8_t *Y)
static void xMac (const void *data, const size_t dataSize, const block_t seed, fmix_t mix, block_t result)
static void cMac (const block_t K1, const block_t K2, const void *data, const size_t dataSize, block_t mac)
static void getSubkeys (fdouble_t gfdouble, const char quad, const uint8_t *key, block_t D, block_t Q)
static char padBlock (const uint8_t len, block_t block)
void SPP_EXTERNAL_ENCRYPTION_ecbEncrypt (const uint8_t *key, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using ECB-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_ecbDecrypt (const uint8_t *key, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using ECB-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_cbcEncrypt (const uint8_t *key, const block_t iVec, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using CBC-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_cbcDecrypt (const uint8_t *key, const block_t iVec, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using CBC-AES block-cipher method
static void CFB_cipher (const uint8_t *key, const block_t iVec, const char mode, const void *input, const size_t dataSize, void *output)
 the general scheme of CFB-AES block-ciphering algorithm
void SPP_EXTERNAL_ENCRYPTION_cfbEncrypt (const uint8_t *key, const block_t iVec, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using CFB-AES block-cipher method
void SPP_EXTERNAL_ENCRYPTION_cfbDecrypt (const uint8_t *key, const block_t iVec, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using CFB-AES block-cipher method
void SPP_EXTERNAL_ENCRYPTION_ofbEncrypt (const uint8_t *key, const block_t iVec, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using OFB-AES block-cipher method
void SPP_EXTERNAL_ENCRYPTION_ofbDecrypt (const uint8_t *key, const block_t iVec, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using OFB-AES block-cipher method
static void CTR_cipher (const block_t iCtr, const char mode, const void *input, const size_t dataSize, void *output)
 the general scheme of operation in block-counter mode
void SPP_EXTERNAL_ENCRYPTION_ctrEncrypt (const uint8_t *key, const uint8_t *iv, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using CTR-AES block-cipher method
void SPP_EXTERNAL_ENCRYPTION_ctrDecrypt (const uint8_t *key, const uint8_t *iv, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using CTR-AES block-cipher method
static char XTS_cipher (const uint8_t *keypair, const char mode, const block_t tweak, const size_t sectid, const size_t dataSize, void *storage)
 encrypt or decrypt a data unit with XTS method
char SPP_EXTERNAL_ENCRYPTION_xtsEncrypt (const uint8_t *keys, const uint8_t *tweak, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using XTS-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_xtsDecrypt (const uint8_t *keys, const uint8_t *tweak, const void *crtxt, const size_t crtxtLen, void *pntxt)
 encrypt the input ciphertext using XTS-AES block-cipher method
void SPP_EXTERNAL_ENCRYPTION_cmac (const uint8_t *key, const void *data, const size_t dataSize, block_t mac)
 derive the AES-CMAC of input data using an encryption key
static void gHash (const block_t H, const void *aData, const void *crtxt, const size_t aDataLen, const size_t crtxtLen, block_t gh)
static void GCMsetup (const uint8_t *key, const uint8_t *nonce, block_t auKey, block_t iv)
void SPP_EXTERNAL_ENCRYPTION_gcmEncrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using GCM-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_gcmDecrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using GCM-AES block-cipher method
static void CCMtag (const block_t iv, const void *aData, const void *pntxt, const size_t aDataLen, const size_t ptextLen, block_t M)
void SPP_EXTERNAL_ENCRYPTION_ccmEncrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using CCM-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_ccmDecrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using CCM-AES block-cipher method
static void S2V (const uint8_t *key, const void *aData, const void *pntxt, const size_t aDataLen, const size_t ptextLen, block_t IV)
void SPP_EXTERNAL_ENCRYPTION_sivEncrypt (const uint8_t *keys, const void *aData, const size_t aDataLen, const void *pntxt, const size_t ptextLen, block_t iv, void *crtxt)
 encrypt the input plaintext using SIV-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_sivDecrypt (const uint8_t *keys, const block_t iv, const void *aData, const size_t aDataLen, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using SIV-AES block-cipher method
static void polyval (const block_t H, const void *aData, const void *pntxt, const size_t aDataLen, const size_t ptextLen, block_t pv)
static void GCM_SIVsetup (const uint8_t *key, const uint8_t *nonce, block_t AK)
static void GCM_SIVtag (const uint8_t *nonce, block_t pv, block_t tag)
void SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using SIV-GCM-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using SIV-GCM-AES block-cipher method
static void oMac (const uint8_t indx, const block_t D, const block_t Q, const void *data, const size_t dataSize, block_t mac)
void SPP_EXTERNAL_ENCRYPTION_eaxEncrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input plaintext using EAX-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_eaxDecrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input ciphertext using EAX-AES block-cipher method
static void nop (const block_t x, block_t y)
static void getDelta (const count_t index, const block_t Ld, const block_t delta0, block_t delta)
static void OCB_cipher (const uint8_t *key, const uint8_t *nonce, const size_t ptextLen, const size_t aDataLen, const size_t dataSize, const void *aData, void *data, block_t tag)
 encrypt or decrypt the data using OCB method
void SPP_EXTERNAL_ENCRYPTION_ocbEncrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input stream using OCB-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_ocbDecrypt (const uint8_t *key, const uint8_t *nonce, const void *aData, const size_t aDataLen, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt the input stream using OCB-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_keyWrap (const uint8_t *kek, const void *secret, const size_t secretLen, void *wrapped)
 encrypt the input secret with key-wrapping method
char SPP_EXTERNAL_ENCRYPTION_keyUnwrap (const uint8_t *kek, const void *wrapped, const size_t wrapLen, void *secret)
 unwrap/decrypt a wrapped secret according to RFC-3394
static void addLblocks (const uint8_t *x, const uint8_t len, uint8_t *y)
static void modP1305 (uint8_t *block, int32_t q)
static void mulLblocks (const uint8_t *x, uint8_t *y)
void SPP_EXTERNAL_ENCRYPTION_poly1305 (const uint8_t *keys, const block_t nonce, const void *data, const size_t dataSize, block_t mac)
 derive the Poly1305-AES mac of message using a nonce and key pair.
static void numRadix (const radix_t *s, size_t len, uint8_t *num, size_t bytes)
static void strRadix (const uint8_t *num, size_t bytes, radix_t *s, size_t len)
static void addRadix (const radix_t *x, const size_t len, radix_t *y)
static void subRadix (const radix_t *x, const size_t len, radix_t *y)
static void FF1round (const uint8_t i, const block_t P, const size_t u, const size_t v, radix_t *C)
static void FF1_cipher (const uint8_t *key, const char mode, const TWEAK_PARAMS, const size_t len, radix_t *X)
static char FPE_cipher (const uint8_t *key, const char mode, const TWEAK_PARAMS, const void *input, const size_t dataSize, void *output)
 encrypt or decrypt the input string with FPE method
char SPP_EXTERNAL_ENCRYPTION_fpeEncrypt (const uint8_t *key, const TWEAK_PARAMS, const void *pntxt, const size_t ptextLen, void *crtxt)
 encrypt the input string using FPE-AES block-cipher method
char SPP_EXTERNAL_ENCRYPTION_fpeDecrypt (const uint8_t *key, const TWEAK_PARAMS, const void *crtxt, const size_t crtxtLen, void *pntxt)
 decrypt a ciphertext string using FPE-AES block-cipher method

Variables

static const char sbox [256]
static const char rsbox [256]
static uint8_t RoundKey [BLOCKSIZE *ROUNDS+KEYSIZE]
static size_t b1

Macro Definition Documentation

◆ IMPLEMENT

#define IMPLEMENT ( x)
Value:
(x) > 0

Definition at line 29 of file encryption.c.

◆ INCREASE_SECURITY

#define INCREASE_SECURITY   0

Definition at line 31 of file encryption.c.

◆ AVOID_FUNCTION_CALL

#define AVOID_FUNCTION_CALL   0

Definition at line 32 of file encryption.c.

◆ SMALL_CIPHER

#define SMALL_CIPHER   0

Definition at line 33 of file encryption.c.

◆ SBoxValue

#define SBoxValue ( x)
Value:
*(sbox + x)
static const char sbox[256]
Definition encryption.c:41

Definition at line 83 of file encryption.c.

Referenced by KeyExpansion(), and SubBytes().

◆ InvSBoxValue

#define InvSBoxValue ( x)
Value:
(rsbox[x])
static const char rsbox[256]
Definition encryption.c:54

Definition at line 84 of file encryption.c.

Referenced by InvSubBytes().

◆ COPYDWORD

#define COPYDWORD ( x,
y )
Value:
*(int32_t*) &y = *(int32_t*) &x

Definition at line 86 of file encryption.c.

Referenced by InvMixColumns(), MixColumns(), and SPP_EXTERNAL_ENCRYPTION_eaxEncrypt().

◆ XOR32BITS

#define XOR32BITS ( x,
y )
Value:
*(int32_t*) &y ^= *(int32_t*) &x

Definition at line 87 of file encryption.c.

Referenced by GCM_SIVtag(), KeyExpansion(), SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), and SPP_EXTERNAL_ENCRYPTION_eaxEncrypt().

◆ XOR64BITS

#define XOR64BITS ( x,
y )
Value:
XOR32BITS(x, y); XOR32BITS(*(&x + 4), *(&y + 4))
#define XOR32BITS(x, y)
Definition encryption.c:87

Definition at line 92 of file encryption.c.

Referenced by GCM_SIVtag().

◆ AES_setkey

◆ BURN

◆ SABOTAGE

◆ memcmp_s

◆ IV_KWA

#define IV_KWA   "\xA6\xA6\xA6\xA6\xA6\xA6\xA6\xA6"

◆ ALPHABET

#define ALPHABET   "0123456789"

Definition at line 2009 of file encryption.c.

Referenced by FPE_cipher().

◆ RADIX

#define RADIX   10

Definition at line 2010 of file encryption.c.

Referenced by addRadix(), FF1_cipher(), FPE_cipher(), numRadix(), strRadix(), and subRadix().

◆ LOGRDX

#define LOGRDX   3.32192809488736

Definition at line 2011 of file encryption.c.

Referenced by FPE_cipher().

◆ MINLEN

#define MINLEN   6

Definition at line 2012 of file encryption.c.

Referenced by FPE_cipher().

◆ MAXLEN

#define MAXLEN   56

Definition at line 2013 of file encryption.c.

Referenced by FPE_cipher().

◆ FPE_PERMUTE

#define FPE_PERMUTE   FF1_cipher

Definition at line 2033 of file encryption.c.

Referenced by FPE_cipher().

◆ TWEAK_PARAMS

#define TWEAK_PARAMS   uint8_t* tweak, const size_t tweakLen

◆ TWEAK_AGRS

#define TWEAK_AGRS   tweak, tweakLen

Typedef Documentation

◆ block_t

typedef uint8_t block_t[BLOCKSIZE]

block_t indicates fixed-size memory blocks, and state_t represents the state matrix. note that state[i][j] means the i-th COLUMN and j-th ROW of matrix

Definition at line 76 of file encryption.c.

◆ state_t

typedef uint8_t state_t[Nb][4]

Definition at line 77 of file encryption.c.

◆ fmix_t

typedef void(*) fmix_t(const block_t, block_t)

function-pointer types, indicating functions that take fixed-size blocks:

Definition at line 358 of file encryption.c.

◆ alpha_t

typedef char alpha_t

Definition at line 2019 of file encryption.c.

◆ radix_t

typedef unsigned short radix_t

Definition at line 2025 of file encryption.c.

Enumeration Type Documentation

◆ basic_constants

Enumerator
BLOCKSIZE 
KEYSIZE 
Nb 
Nk 
ROUNDS 
HB 
LAST 
MIDST 
PL 

Definition at line 16 of file encryption.c.

◆ ctr_based_modes

Enumerator
CTR_DEFAULT 
SIV_CTR 
SIVGCM_CTR 
CCM_GCM 

Definition at line 906 of file encryption.c.

Function Documentation

◆ xtime()

uint8_t xtime ( uint8_t x)
static

doubling the value of x in Galois bit field GF(2^8) with polynomial 0x11b

Definition at line 105 of file encryption.c.

References xtime().

Referenced by MixColumns(), mixG8(), and xtime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xorBlock()

void xorBlock ( const block_t src,
block_t dest )
static

XOR two 128bit blocks, i.e. add two numbers in Galois bit field GF(2^128)

Definition at line 111 of file encryption.c.

References BLOCKSIZE, and xorBlock().

Referenced by AddRoundKey(), CCMtag(), CFB_cipher(), cMac(), CTR_cipher(), dotGF128(), getDelta(), mulGF128(), OCB_cipher(), S2V(), SPP_EXTERNAL_ENCRYPTION_cbcDecrypt(), SPP_EXTERNAL_ENCRYPTION_cbcEncrypt(), SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), SPP_EXTERNAL_ENCRYPTION_eaxEncrypt(), SPP_EXTERNAL_ENCRYPTION_gcmDecrypt(), SPP_EXTERNAL_ENCRYPTION_gcmEncrypt(), SPP_EXTERNAL_ENCRYPTION_ofbEncrypt(), xMac(), xorBlock(), and XTS_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixG8()

uint8_t mixG8 ( uint8_t a,
uint8_t b,
uint8_t c,
uint8_t d )
static

inverse multiply in 8bit GF: mul(a,14) ^ mul(b,11) ^ mul(c,13) ^ mul(d,9)

Definition at line 124 of file encryption.c.

References mixG8(), and xtime().

Referenced by InvMixColumns(), and mixG8().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ KeyExpansion()

void KeyExpansion ( const uint8_t * key)
static

This function produces (ROUNDS+1) round keys, which are used in each round to encrypt/decrypt the intermediate states. First round key is the main key itself, and other rounds are constructed from the previous ones as follows

Definition at line 145 of file encryption.c.

References BLOCKSIZE, KeyExpansion(), KEYSIZE, Nk, RoundKey, ROUNDS, SBoxValue, and XOR32BITS.

Referenced by KeyExpansion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddRoundKey()

void AddRoundKey ( const uint8_t round,
block_t state )
static

XOR the round keys with the rijndael state matrix; namely, add them in GF

Definition at line 182 of file encryption.c.

References AddRoundKey(), BLOCKSIZE, RoundKey, and xorBlock().

Referenced by AddRoundKey(), rijndaelDecrypt(), and rijndaelEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SubBytes()

void SubBytes ( block_t state)
static

Substitute values in the state matrix with associated values in the S-box

Definition at line 188 of file encryption.c.

References BLOCKSIZE, SBoxValue, and SubBytes().

Referenced by rijndaelEncrypt(), and SubBytes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShiftRows()

void ShiftRows ( state_t state)
static

Shift/rotate the rows of the state matrix to the left. Each row is shifted with a different offset (= Row number). So the "zeroth" row is not shifted

Definition at line 199 of file encryption.c.

References ShiftRows().

Referenced by rijndaelEncrypt(), and ShiftRows().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MixColumns()

void MixColumns ( state_t state)
static

Use matrix multiplication in Galois field to mix the columns of the state

Definition at line 222 of file encryption.c.

References COPYDWORD, MixColumns(), Nb, and xtime().

Referenced by MixColumns(), and rijndaelEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rijndaelEncrypt()

void rijndaelEncrypt ( const block_t input,
block_t output )
static

Encrypt a plaintext input block and save the result/ciphertext as output.

Definition at line 243 of file encryption.c.

References AddRoundKey(), BLOCKSIZE, MixColumns(), rijndaelEncrypt(), ROUNDS, ShiftRows(), and SubBytes().

Referenced by CCMtag(), CFB_cipher(), cMac(), CTR_cipher(), FF1_cipher(), FF1round(), GCM_SIVsetup(), GCM_SIVtag(), GCMsetup(), getSubkeys(), OCB_cipher(), oMac(), rijndaelEncrypt(), S2V(), SPP_EXTERNAL_ENCRYPTION_cbcEncrypt(), SPP_EXTERNAL_ENCRYPTION_ecbEncrypt(), SPP_EXTERNAL_ENCRYPTION_gcmDecrypt(), SPP_EXTERNAL_ENCRYPTION_gcmEncrypt(), SPP_EXTERNAL_ENCRYPTION_keyWrap(), SPP_EXTERNAL_ENCRYPTION_ofbEncrypt(), SPP_EXTERNAL_ENCRYPTION_poly1305(), and XTS_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvSubBytes()

void InvSubBytes ( block_t state)
static

Substitutes the values in state matrix with values of the inverted S-box.

Definition at line 269 of file encryption.c.

References BLOCKSIZE, InvSBoxValue, and InvSubBytes().

Referenced by InvSubBytes(), and rijndaelDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvShiftRows()

void InvShiftRows ( state_t state)
static

This function shifts (i.e rotates) the rows of the state matrix to right.

Definition at line 279 of file encryption.c.

References InvShiftRows().

Referenced by InvShiftRows(), and rijndaelDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvMixColumns()

void InvMixColumns ( state_t state)
static

Reverse the process of mixing columns by matrix multiplication in GF(2^8)

Definition at line 302 of file encryption.c.

References COPYDWORD, InvMixColumns(), mixG8(), and Nb.

Referenced by InvMixColumns(), and rijndaelDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rijndaelDecrypt()

void rijndaelDecrypt ( const block_t input,
block_t output )
static

Decrypt a ciphertext input block and save the result/plaintext to output.

Definition at line 316 of file encryption.c.

References AddRoundKey(), BLOCKSIZE, InvMixColumns(), InvShiftRows(), InvSubBytes(), rijndaelDecrypt(), and ROUNDS.

Referenced by OCB_cipher(), rijndaelDecrypt(), SPP_EXTERNAL_ENCRYPTION_cbcDecrypt(), SPP_EXTERNAL_ENCRYPTION_ecbDecrypt(), SPP_EXTERNAL_ENCRYPTION_keyUnwrap(), and XTS_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xorBEint()

void xorBEint ( uint8_t * buff,
size_t num,
uint8_t pos )
static

xor a byte array with a big-endian integer, whose LSB is at specified pos

Definition at line 412 of file encryption.c.

References xorBEint().

Referenced by CCMtag(), FF1_cipher(), FF1round(), gHash(), SPP_EXTERNAL_ENCRYPTION_ctrEncrypt(), SPP_EXTERNAL_ENCRYPTION_keyUnwrap(), SPP_EXTERNAL_ENCRYPTION_keyWrap(), and xorBEint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ incBlock()

void incBlock ( block_t block,
uint8_t index )
static

increment the value of a 128-bit counter block, regarding its endian-ness

Definition at line 423 of file encryption.c.

References HB, and incBlock().

Referenced by CTR_cipher(), and incBlock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doubleBblock()

void doubleBblock ( block_t array)
static

Multiply a block by two in Galois bit field GF(2^128): big-endian version

Definition at line 436 of file encryption.c.

References BLOCKSIZE, doubleBblock(), and LAST.

Referenced by doubleBblock(), getDelta(), OCB_cipher(), S2V(), SPP_EXTERNAL_ENCRYPTION_cmac(), SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), and SPP_EXTERNAL_ENCRYPTION_eaxEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doubleLblock()

void doubleLblock ( block_t array)
static

Multiply a block by two in Galois field GF(2^128): little-endian version.

Definition at line 451 of file encryption.c.

References doubleLblock().

Referenced by doubleLblock(), SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), SPP_EXTERNAL_ENCRYPTION_eaxEncrypt(), and XTS_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ divideBblock()

void divideBblock ( block_t array)
static

Divide a 128-bit big-endian integer by two in Galois bit field GF(2^128).

Definition at line 466 of file encryption.c.

References BLOCKSIZE, and divideBblock().

Referenced by divideBblock(), and mulGF128().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mulGF128()

void mulGF128 ( const block_t x,
block_t y )
static

Multiply two 128-bit numbers (big-endian blocks) in the Galois bit field.

Definition at line 478 of file encryption.c.

References BLOCKSIZE, divideBblock(), mulGF128(), and xorBlock().

Referenced by gHash(), and mulGF128().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ divideLblock()

void divideLblock ( block_t array)
static

Divide a block by two in 128-bit Galois field: the little-endian version.

Definition at line 501 of file encryption.c.

References BLOCKSIZE, divideLblock(), and LAST.

Referenced by divideLblock(), and dotGF128().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dotGF128()

void dotGF128 ( const block_t x,
block_t y )
static

The so-called "dot multiplying" in GF(2^128), used in POLYVAL calculation

Definition at line 513 of file encryption.c.

References BLOCKSIZE, divideLblock(), dotGF128(), and xorBlock().

Referenced by dotGF128(), and polyval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixThenXor()

void mixThenXor ( fmix_t mix,
const block_t B,
block_t f,
const uint8_t * X,
uint8_t n,
uint8_t * Y )
static

mix/cipher the block B and then xor the result with n bytes of X to get Y

Definition at line 536 of file encryption.c.

References mixThenXor().

Referenced by CFB_cipher(), CTR_cipher(), mixThenXor(), OCB_cipher(), SPP_EXTERNAL_ENCRYPTION_cbcDecrypt(), and SPP_EXTERNAL_ENCRYPTION_ofbEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xMac()

void xMac ( const void * data,
const size_t dataSize,
const block_t seed,
fmix_t mix,
block_t result )
static

xor the result with input data and then apply the digest/mixing function. repeat this process for each block of data, until all blocks are digested.

Definition at line 554 of file encryption.c.

References BLOCKSIZE, xMac(), and xorBlock().

Referenced by CCMtag(), cMac(), FF1_cipher(), FF1round(), gHash(), OCB_cipher(), polyval(), and xMac().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cMac()

void cMac ( const block_t K1,
const block_t K2,
const void * data,
const size_t dataSize,
block_t mac )
static

calculate CMAC of input data using pre-calculated keys: K1 (D) and K2 (Q)

Definition at line 579 of file encryption.c.

References BLOCKSIZE, cMac(), rijndaelEncrypt(), xMac(), and xorBlock().

Referenced by cMac(), OCB_cipher(), oMac(), S2V(), and SPP_EXTERNAL_ENCRYPTION_cmac().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSubkeys()

void getSubkeys ( fdouble_t gfdouble,
const char quad,
const uint8_t * key,
block_t D,
block_t Q )
static

calculate key-dependent constants D and Q using a given doubling function

Definition at line 596 of file encryption.c.

References AES_setkey, BLOCKSIZE, getSubkeys(), and rijndaelEncrypt().

Referenced by getSubkeys(), OCB_cipher(), S2V(), SPP_EXTERNAL_ENCRYPTION_cmac(), SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), and SPP_EXTERNAL_ENCRYPTION_eaxEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ padBlock()

char padBlock ( const uint8_t len,
block_t block )
static

in ECB mode & CBC without CTS, the last (partial) block has to be padded.

Definition at line 613 of file encryption.c.

References AES_PADDING, BLOCKSIZE, and padBlock().

Referenced by padBlock(), SPP_EXTERNAL_ENCRYPTION_cbcEncrypt(), and SPP_EXTERNAL_ENCRYPTION_ecbEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ecbEncrypt()

void SPP_EXTERNAL_ENCRYPTION_ecbEncrypt ( const uint8_t * key,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using ECB-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
pntxtinput plaintext buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer

Encryption/decryption of a single block with Rijndael


Main functions for ECB-AES block ciphering

Definition at line 639 of file encryption.c.

References AES_setkey, BLOCKSIZE, BURN, padBlock(), rijndaelEncrypt(), RoundKey, and SPP_EXTERNAL_ENCRYPTION_ecbEncrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_ecbEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ecbDecrypt()

char SPP_EXTERNAL_ENCRYPTION_ecbDecrypt ( const uint8_t * key,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using ECB-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
crtxtinput ciphertext buffer
crtxtLensize of ciphertext in bytes
pntxtresulting plaintext buffer
Returns
error if the ciphertext has a partial block

Definition at line 666 of file encryption.c.

References AES_setkey, BLOCKSIZE, BURN, M_DECRYPTION_ERROR, M_SUCCESS, rijndaelDecrypt(), RoundKey, and SPP_EXTERNAL_ENCRYPTION_ecbDecrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_ecbDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cbcEncrypt()

char SPP_EXTERNAL_ENCRYPTION_cbcEncrypt ( const uint8_t * key,
const block_t iVec,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using CBC-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
iVecinitialization vector
pntxtinput plaintext buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer
Returns
error in CTS mode, if plaintext is a single partial block

Definition at line 700 of file encryption.c.

References AES_setkey, BLOCKSIZE, BURN, M_DATALENGTH_ERROR, M_SUCCESS, padBlock(), rijndaelEncrypt(), RoundKey, SPP_EXTERNAL_ENCRYPTION_cbcEncrypt(), and xorBlock().

Referenced by SPP_EXTERNAL_ENCRYPTION_cbcEncrypt(), and SPP_EXTERNAL_ENCRYPTION_cbcEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cbcDecrypt()

char SPP_EXTERNAL_ENCRYPTION_cbcDecrypt ( const uint8_t * key,
const block_t iVec,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using CBC-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
iVecinitialization vector
crtxtinput ciphertext buffer
crtxtLensize of ciphertext in bytes
pntxtresulting plaintext buffer
Returns
error if the size of ciphertext is not a valid value

Definition at line 749 of file encryption.c.

References AES_setkey, BLOCKSIZE, BURN, M_DATALENGTH_ERROR, M_SUCCESS, mixThenXor(), rijndaelDecrypt(), RoundKey, SPP_EXTERNAL_ENCRYPTION_cbcDecrypt(), and xorBlock().

Referenced by SPP_EXTERNAL_ENCRYPTION_cbcDecrypt(), and SPP_EXTERNAL_ENCRYPTION_cbcDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CFB_cipher()

void CFB_cipher ( const uint8_t * key,
const block_t iVec,
const char mode,
const void * input,
const size_t dataSize,
void * output )
static

the general scheme of CFB-AES block-ciphering algorithm

Parameters
keyencryption key with a fixed size specified by KEYSIZE
iVecinitialization vector
modemode of operation: (1) to encrypt, (0) to decrypt
inputbuffer of the input plain/cipher-text
dataSizesize of input in bytes
outputbuffer of the resulting cipher/plain-text

Definition at line 802 of file encryption.c.

References AES_setkey, BLOCKSIZE, BURN, CFB_cipher(), mixThenXor(), rijndaelEncrypt(), RoundKey, and xorBlock().

Referenced by CFB_cipher(), SPP_EXTERNAL_ENCRYPTION_cfbDecrypt(), and SPP_EXTERNAL_ENCRYPTION_cfbEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cfbEncrypt()

void SPP_EXTERNAL_ENCRYPTION_cfbEncrypt ( const uint8_t * key,
const block_t iVec,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using CFB-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
iVecinitialization vector
pntxtinput plaintext buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer

Definition at line 830 of file encryption.c.

References CFB_cipher(), and SPP_EXTERNAL_ENCRYPTION_cfbEncrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_cfbEncrypt(), and SPP_EXTERNAL_ENCRYPTION_cfbEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cfbDecrypt()

void SPP_EXTERNAL_ENCRYPTION_cfbDecrypt ( const uint8_t * key,
const block_t iVec,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using CFB-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
iVecinitialization vector
crtxtinput ciphertext buffer
crtxtLensize of ciphertext in bytes
pntxtresulting plaintext buffer

Definition at line 844 of file encryption.c.

References CFB_cipher(), and SPP_EXTERNAL_ENCRYPTION_cfbDecrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_cfbDecrypt(), and SPP_EXTERNAL_ENCRYPTION_cfbDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ofbEncrypt()

void SPP_EXTERNAL_ENCRYPTION_ofbEncrypt ( const uint8_t * key,
const block_t iVec,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using OFB-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
iVecinitialization vector
pntxtinput plaintext buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer

Definition at line 864 of file encryption.c.

References AES_setkey, BLOCKSIZE, BURN, mixThenXor(), rijndaelEncrypt(), RoundKey, SPP_EXTERNAL_ENCRYPTION_ofbEncrypt(), and xorBlock().

Referenced by SPP_EXTERNAL_ENCRYPTION_ofbDecrypt(), SPP_EXTERNAL_ENCRYPTION_ofbEncrypt(), and SPP_EXTERNAL_ENCRYPTION_ofbEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ofbDecrypt()

void SPP_EXTERNAL_ENCRYPTION_ofbDecrypt ( const uint8_t * key,
const block_t iVec,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using OFB-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
iVecinitialization vector
crtxtinput ciphertext buffer
crtxtLensize of ciphertext in bytes
pntxtresulting plaintext buffer

Definition at line 892 of file encryption.c.

References SPP_EXTERNAL_ENCRYPTION_ofbDecrypt(), and SPP_EXTERNAL_ENCRYPTION_ofbEncrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_ofbDecrypt(), and SPP_EXTERNAL_ENCRYPTION_ofbDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CTR_cipher()

void CTR_cipher ( const block_t iCtr,
const char mode,
const void * input,
const size_t dataSize,
void * output )
static

the general scheme of operation in block-counter mode

Parameters
iCtrinitialized counter block
modespecifies the "counter based" block-cipher or AEAD mode
inputbuffer of the input plain/cipher-text
dataSizesize of input in bytes
outputbuffer of the resulting cipher/plain-text

Definition at line 922 of file encryption.c.

References BLOCKSIZE, CCM_GCM, CTR_cipher(), incBlock(), LAST, mixThenXor(), rijndaelEncrypt(), SIV_CTR, SIVGCM_CTR, and xorBlock().

Referenced by CTR_cipher(), SPP_EXTERNAL_ENCRYPTION_ccmDecrypt(), SPP_EXTERNAL_ENCRYPTION_ccmEncrypt(), SPP_EXTERNAL_ENCRYPTION_ctrEncrypt(), SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), SPP_EXTERNAL_ENCRYPTION_eaxEncrypt(), SPP_EXTERNAL_ENCRYPTION_gcmDecrypt(), SPP_EXTERNAL_ENCRYPTION_gcmEncrypt(), SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt(), SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt(), SPP_EXTERNAL_ENCRYPTION_sivDecrypt(), and SPP_EXTERNAL_ENCRYPTION_sivEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ctrEncrypt()

void SPP_EXTERNAL_ENCRYPTION_ctrEncrypt ( const uint8_t * key,
const uint8_t * iv,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using CTR-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
ivinitialization vector a.k.a. nonce
pntxtinput plaintext buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer

Main functions for CTR-AES block ciphering

Definition at line 965 of file encryption.c.

References AES_setkey, BURN, CTR_cipher(), CTR_DEFAULT, CTR_IV_LENGTH, CTR_START_VALUE, LAST, RoundKey, SPP_EXTERNAL_ENCRYPTION_ctrEncrypt(), and xorBEint().

Referenced by SPP_EXTERNAL_ENCRYPTION_ctrDecrypt(), SPP_EXTERNAL_ENCRYPTION_ctrEncrypt(), and SPP_EXTERNAL_ENCRYPTION_ofbDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ctrDecrypt()

void SPP_EXTERNAL_ENCRYPTION_ctrDecrypt ( const uint8_t * key,
const uint8_t * iv,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using CTR-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
ivinitialization vector a.k.a. nonce
crtxtinput ciphertext buffer
crtxtLensize of ciphertext in bytes
pntxtresulting plaintext buffer

Definition at line 989 of file encryption.c.

References SPP_EXTERNAL_ENCRYPTION_ctrDecrypt(), and SPP_EXTERNAL_ENCRYPTION_ctrEncrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_ctrDecrypt(), and SPP_EXTERNAL_ENCRYPTION_ofbDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XTS_cipher()

char XTS_cipher ( const uint8_t * keypair,
const char mode,
const block_t tweak,
const size_t sectid,
const size_t dataSize,
void * storage )
static

encrypt or decrypt a data unit with XTS method

Parameters
keypairpair of encryption keys, each one has KEYSIZE bytes
modemode of operation: encrypting (1) or decrypting (0)
tweakdata unit identifier block, similar to nonce in CTR mode
sectidsector id: in case of a null tweak, use this instead
dataSizesize of input data, to be encrypted/decrypted
storageresult of encryption/decryption process
Returns
error if the data is too small (less than one block)

Definition at line 1012 of file encryption.c.

References AES_setkey, BLOCKSIZE, BURN, doubleLblock(), KEYSIZE, M_DATALENGTH_ERROR, M_SUCCESS, rijndaelDecrypt(), rijndaelEncrypt(), RoundKey, xorBlock(), and XTS_cipher().

Referenced by SPP_EXTERNAL_ENCRYPTION_xtsDecrypt(), SPP_EXTERNAL_ENCRYPTION_xtsEncrypt(), and XTS_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_xtsEncrypt()

char SPP_EXTERNAL_ENCRYPTION_xtsEncrypt ( const uint8_t * keys,
const uint8_t * tweak,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using XTS-AES block-cipher method

Parameters
keystwo-part encryption key with a fixed size of 2*KEYSIZE
tweaktweak bytes of data unit, a.k.a sector ID (little-endian)
pntxtinput plaintext buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer
Returns
error if plaintext is a single partial block

Main functions for XTS-AES block ciphering

Definition at line 1073 of file encryption.c.

References SPP_EXTERNAL_ENCRYPTION_xtsEncrypt(), and XTS_cipher().

Referenced by SPP_EXTERNAL_ENCRYPTION_ofbDecrypt(), and SPP_EXTERNAL_ENCRYPTION_xtsEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_xtsDecrypt()

char SPP_EXTERNAL_ENCRYPTION_xtsDecrypt ( const uint8_t * keys,
const uint8_t * tweak,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

encrypt the input ciphertext using XTS-AES block-cipher method

Parameters
keystwo-part encryption key with a fixed size of 2*KEYSIZE
tweaktweak bytes of data unit, a.k.a sector ID (little-endian)
crtxtinput ciphertext buffer
crtxtLensize of ciphertext in bytes
pntxtresulting plaintext buffer
Returns
error if ciphertext is a single partial block

Definition at line 1089 of file encryption.c.

References SPP_EXTERNAL_ENCRYPTION_xtsDecrypt(), and XTS_cipher().

Referenced by SPP_EXTERNAL_ENCRYPTION_ofbDecrypt(), and SPP_EXTERNAL_ENCRYPTION_xtsDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cmac()

void SPP_EXTERNAL_ENCRYPTION_cmac ( const uint8_t * key,
const void * data,
const size_t dataSize,
block_t mac )

derive the AES-CMAC of input data using an encryption key

Parameters
keyAES encryption key
databuffer of input data
dataSizesize of data in bytes
maccalculated CMAC hash

Definition at line 1109 of file encryption.c.

References BURN, cMac(), doubleBblock(), getSubkeys(), RoundKey, and SPP_EXTERNAL_ENCRYPTION_cmac().

Referenced by SPP_EXTERNAL_ENCRYPTION_cmac(), and SPP_EXTERNAL_ENCRYPTION_cmac().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gHash()

void gHash ( const block_t H,
const void * aData,
const void * crtxt,
const size_t aDataLen,
const size_t crtxtLen,
block_t gh )
static

calculate G-Hash of ciphertext and AAD using an authentication subkey H

Definition at line 1128 of file encryption.c.

References gHash(), LAST, MIDST, mulGF128(), xMac(), and xorBEint().

Referenced by GCMsetup(), gHash(), SPP_EXTERNAL_ENCRYPTION_gcmDecrypt(), and SPP_EXTERNAL_ENCRYPTION_gcmEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCMsetup()

void GCMsetup ( const uint8_t * key,
const uint8_t * nonce,
block_t auKey,
block_t iv )
static

encrypt zeros to get the authentication subkey (H), and construct the IV.

Definition at line 1141 of file encryption.c.

References AES_setkey, GCM_NONCE_LEN, GCMsetup(), gHash(), LAST, and rijndaelEncrypt().

Referenced by GCMsetup(), SPP_EXTERNAL_ENCRYPTION_gcmDecrypt(), and SPP_EXTERNAL_ENCRYPTION_gcmEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_gcmEncrypt()

void SPP_EXTERNAL_ENCRYPTION_gcmEncrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using GCM-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
noncea.k.a initialization vector with fixed size: GCM_NONCE_LEN
aDataadditional authentication data
aDataLensize of additional authentication data
pntxtinput plain-text buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer + message authentication tag

Main functions for GCM-AES block ciphering

Definition at line 1165 of file encryption.c.

References BURN, CCM_GCM, CTR_cipher(), GCM_TAG_LEN, GCMsetup(), gHash(), rijndaelEncrypt(), RoundKey, SPP_EXTERNAL_ENCRYPTION_gcmEncrypt(), and xorBlock().

Referenced by SPP_EXTERNAL_ENCRYPTION_CYPHER_encryptPacket(), SPP_EXTERNAL_ENCRYPTION_gcmEncrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_gcmDecrypt()

char SPP_EXTERNAL_ENCRYPTION_gcmDecrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using GCM-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
noncea.k.a initialization vector with fixed size: GCM_NONCE_LEN
aDataadditional authentication data
aDataLensize of additional authentication data
crtxtinput cipher-text buffer + appended authentication tag
crtxtLensize of ciphertext, excluding tag
pntxtresulting plaintext buffer
Returns
whether message authentication/decryption was successful

Definition at line 1193 of file encryption.c.

References BURN, CCM_GCM, CTR_cipher(), GCM_TAG_LEN, GCMsetup(), gHash(), M_AUTHENTICATION_ERROR, M_SUCCESS, memcmp_s, rijndaelEncrypt(), RoundKey, SPP_EXTERNAL_ENCRYPTION_gcmDecrypt(), and xorBlock().

Referenced by SPP_EXTERNAL_ENCRYPTION_gcmDecrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CCMtag()

void CCMtag ( const block_t iv,
const void * aData,
const void * pntxt,
const size_t aDataLen,
const size_t ptextLen,
block_t M )
static

this function calculates the CBC-MAC of plaintext and authentication data

Definition at line 1223 of file encryption.c.

References BLOCKSIZE, CCM_TAG_LEN, CCMtag(), LAST, rijndaelEncrypt(), xMac(), xorBEint(), and xorBlock().

Referenced by CCMtag(), SPP_EXTERNAL_ENCRYPTION_ccmDecrypt(), and SPP_EXTERNAL_ENCRYPTION_ccmEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ccmEncrypt()

void SPP_EXTERNAL_ENCRYPTION_ccmEncrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using CCM-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
noncea.k.a initialization vector with fixed size: CCM_NONCE_LEN
aDataadditional authentication data
aDataLensize of additional authentication data
pntxtinput plain-text buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer + message authentication tag

Main functions for CCM-AES block ciphering

Definition at line 1269 of file encryption.c.

References AES_setkey, BURN, CCM_GCM, CCM_NONCE_LEN, CCM_TAG_LEN, CCMtag(), CTR_cipher(), RoundKey, and SPP_EXTERNAL_ENCRYPTION_ccmEncrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_ccmEncrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ccmDecrypt()

char SPP_EXTERNAL_ENCRYPTION_ccmDecrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using CCM-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
noncea.k.a initialization vector with fixed size: CCM_NONCE_LEN
aDataadditional authentication data
aDataLensize of additional authentication data
crtxtinput cipher-text buffer + appended authentication tag
crtxtLensize of ciphertext, excluding tag
pntxtresulting plaintext buffer
Returns
whether message decryption/authentication was successful

Definition at line 1296 of file encryption.c.

References AES_setkey, BURN, CCM_GCM, CCM_NONCE_LEN, CCM_TAG_LEN, CCMtag(), CTR_cipher(), M_AUTHENTICATION_ERROR, M_SUCCESS, memcmp_s, RoundKey, SABOTAGE, and SPP_EXTERNAL_ENCRYPTION_ccmDecrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_ccmDecrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ S2V()

void S2V ( const uint8_t * key,
const void * aData,
const void * pntxt,
const size_t aDataLen,
const size_t ptextLen,
block_t IV )
static

calculate the CMAC* of AAD unit(s), then plaintext, and synthesize the IV

Definition at line 1325 of file encryption.c.

References BLOCKSIZE, cMac(), doubleBblock(), getSubkeys(), rijndaelEncrypt(), S2V(), and xorBlock().

Referenced by S2V(), SPP_EXTERNAL_ENCRYPTION_sivDecrypt(), and SPP_EXTERNAL_ENCRYPTION_sivEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_sivEncrypt()

void SPP_EXTERNAL_ENCRYPTION_sivEncrypt ( const uint8_t * keys,
const void * aData,
const size_t aDataLen,
const void * pntxt,
const size_t ptextLen,
block_t iv,
void * crtxt )

encrypt the input plaintext using SIV-AES block-cipher method

Parameters
keystwo-part encryption key with a fixed size of 2*KEYSIZE
aDataadditional authentication data
aDataLensize of additional authentication data
pntxtinput plain-text buffer
ptextLensize of plaintext in bytes
ivsynthesized I.V block, typically prepended to ciphertext
crtxtresulting cipher-text buffer

Definition at line 1373 of file encryption.c.

References AES_setkey, BURN, CTR_cipher(), KEYSIZE, RoundKey, S2V(), SIV_CTR, and SPP_EXTERNAL_ENCRYPTION_sivEncrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_sivEncrypt(), and SPP_EXTERNAL_ENCRYPTION_sivEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_sivDecrypt()

char SPP_EXTERNAL_ENCRYPTION_sivDecrypt ( const uint8_t * keys,
const block_t iv,
const void * aData,
const size_t aDataLen,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using SIV-AES block-cipher method

Parameters
keystwo-part encryption key with a fixed size of 2*KEYSIZE
ivprovided I.V block to validate
aDataadditional authentication data
aDataLensize of additional authentication data
crtxtinput cipher-text buffer
crtxtLensize of ciphertext in bytes
pntxtresulting plaintext buffer
Returns
whether message decryption/authentication was successful

Definition at line 1395 of file encryption.c.

References AES_setkey, BURN, CTR_cipher(), KEYSIZE, M_AUTHENTICATION_ERROR, M_SUCCESS, memcmp_s, RoundKey, S2V(), SABOTAGE, SIV_CTR, and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_sivDecrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ polyval()

void polyval ( const block_t H,
const void * aData,
const void * pntxt,
const size_t aDataLen,
const size_t ptextLen,
block_t pv )
static

calculate the POLYVAL of plaintext and AAD using authentication subkey H.

Definition at line 1422 of file encryption.c.

References dotGF128(), HB, polyval(), and xMac().

Referenced by polyval(), SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt(), and SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCM_SIVsetup()

void GCM_SIVsetup ( const uint8_t * key,
const uint8_t * nonce,
block_t AK )
static

derive the pair of authentication-encryption-keys from main key and nonce

Definition at line 1435 of file encryption.c.

References AES_setkey, BLOCKSIZE, GCM_SIVsetup(), HB, KEYSIZE, Nk, rijndaelEncrypt(), and SIVGCM_NONCE_LEN.

Referenced by GCM_SIVsetup(), SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt(), and SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCM_SIVtag()

void GCM_SIVtag ( const uint8_t * nonce,
block_t pv,
block_t tag )
static

get the tag in GCM-SIV mode, given the nonce and calculated POLYVAL block

Definition at line 1452 of file encryption.c.

References GCM_SIVtag(), LAST, rijndaelEncrypt(), XOR32BITS, and XOR64BITS.

Referenced by GCM_SIVtag(), SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt(), and SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt()

void SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using SIV-GCM-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
nonceprovided 96-bit nonce
aDataadditional authentication data
aDataLensize of additional authentication data
pntxtinput plain-text buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer + message authentication tag

Main functions for GCM-SIV-AES block ciphering

Definition at line 1470 of file encryption.c.

References BURN, CTR_cipher(), GCM_SIVsetup(), GCM_SIVtag(), polyval(), RoundKey, SIVGCM_CTR, and SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_gcmSivEncrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt()

char SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using SIV-GCM-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
nonceprovided 96-bit nonce
aDataadditional authentication data
aDataLensize of additional authentication data
crtxtinput cipher-text buffer + appended authentication tag
crtxtLensize of ciphertext, excluding tag
pntxtresulting plaintext buffer
Returns
whether message decryption/authentication was successful

Definition at line 1496 of file encryption.c.

References BURN, CTR_cipher(), GCM_SIVsetup(), GCM_SIVtag(), M_AUTHENTICATION_ERROR, M_SUCCESS, memcmp_s, polyval(), RoundKey, SABOTAGE, SIVGCM_CTR, SIVGCM_TAG_LEN, and SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_gcmSivDecrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ oMac()

void oMac ( const uint8_t indx,
const block_t D,
const block_t Q,
const void * data,
const size_t dataSize,
block_t mac )
static

this function calculates the OMAC of a data array using D (K1) and Q (K2)

Definition at line 1525 of file encryption.c.

References BLOCKSIZE, cMac(), LAST, oMac(), and rijndaelEncrypt().

Referenced by oMac(), SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), and SPP_EXTERNAL_ENCRYPTION_eaxEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_eaxEncrypt()

void SPP_EXTERNAL_ENCRYPTION_eaxEncrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input plaintext using EAX-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
noncenonce with variable size in EAX' and fixed size in EAX
nonceLensize of the nonce byte array; should be non-zero in EAX'
aDataadditional authentication data; used in EAX only
aDataLensize of additional authentication data
pntxtinput plain-text buffer
ptextLensize of plaintext in bytes
crtxtciphertext result + auth. tag (4 bytes mac in EAX')

Main functions for EAX-AES mode; more info at the bottom of this document.

Definition at line 1557 of file encryption.c.

References BURN, COPYDWORD, CTR_cipher(), CTR_DEFAULT, doubleBblock(), doubleLblock(), EAX_NONCE_LEN, EAX_TAG_LEN, EAXP, getSubkeys(), oMac(), RoundKey, SPP_EXTERNAL_ENCRYPTION_eaxEncrypt(), XOR32BITS, and xorBlock().

Referenced by SPP_EXTERNAL_ENCRYPTION_eaxEncrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_eaxDecrypt()

char SPP_EXTERNAL_ENCRYPTION_eaxDecrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input ciphertext using EAX-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
noncenonce with variable size in EAX' and fixed size in EAX
nonceLensize of the nonce byte array; only used in EAX'
aDataadditional authentication data; for EAX only, not EAX'
aDataLensize of additional authentication data
crtxtinput cipher-text buffer + appended authentication tag
crtxtLensize of cipher-text; excluding tag / 4-bytes mac in EAX'
pntxtresulting plaintext buffer
Returns
whether message authentication/decryption was successful

Definition at line 1607 of file encryption.c.

References BURN, CTR_cipher(), CTR_DEFAULT, doubleBblock(), doubleLblock(), EAX_NONCE_LEN, EAX_TAG_LEN, EAXP, getSubkeys(), M_AUTHENTICATION_ERROR, M_SUCCESS, memcmp_s, oMac(), RoundKey, SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), XOR32BITS, and xorBlock().

Referenced by SPP_EXTERNAL_ENCRYPTION_eaxDecrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nop()

void nop ( const block_t x,
block_t y )
static

Definition at line 1656 of file encryption.c.

References nop().

Referenced by nop(), and OCB_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDelta()

void getDelta ( const count_t index,
const block_t Ld,
const block_t delta0,
block_t delta )
static

Calculate the offset block (Δ_i) at a specified index, given the initial Δ_0 and L$ blocks. This method has minimum memory usage, but it might be slow. To make it faster, pre-calculate all L_{i}s (avoid doubling inside the loop).

Definition at line 1661 of file encryption.c.

References BLOCKSIZE, doubleBblock(), getDelta(), and xorBlock().

Referenced by getDelta(), and OCB_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OCB_cipher()

void OCB_cipher ( const uint8_t * key,
const uint8_t * nonce,
const size_t ptextLen,
const size_t aDataLen,
const size_t dataSize,
const void * aData,
void * data,
block_t tag )
static

encrypt or decrypt the data using OCB method

Parameters
keyencryption or decryption key
noncebyte array with a fixed size of OCB_NONCE_LEN
ptextLensize of input 'plain'text; which is zero in decryption
aDataLensize of additional authentication data
dataSizesize of input data, to be encrypted/decrypted
aDataadditional authentication data
dataresult of encryption/decryption process
tagcalculated tag from plaintext checksum, and PMAC of aData

Definition at line 1692 of file encryption.c.

References BLOCKSIZE, BURN, cMac(), doubleBblock(), getDelta(), getSubkeys(), HB, LAST, mixThenXor(), nop(), OCB_cipher(), OCB_NONCE_LEN, OCB_TAG_LEN, rijndaelDecrypt(), rijndaelEncrypt(), RoundKey, xMac(), and xorBlock().

Referenced by OCB_cipher(), SPP_EXTERNAL_ENCRYPTION_ocbDecrypt(), and SPP_EXTERNAL_ENCRYPTION_ocbEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ocbEncrypt()

void SPP_EXTERNAL_ENCRYPTION_ocbEncrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input stream using OCB-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
noncea.k.a initialization vector with fixed size: OCB_NONCE_LEN
aDataadditional authentication data
aDataLensize of additional authentication data
pntxtinput plain-text buffer
ptextLensize of plaintext in bytes
crtxtresulting cipher-text buffer + message authentication tag

Main functions for OCB-AES block ciphering

Definition at line 1773 of file encryption.c.

References OCB_cipher(), OCB_TAG_LEN, and SPP_EXTERNAL_ENCRYPTION_ocbEncrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_ocbEncrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ocbDecrypt()

char SPP_EXTERNAL_ENCRYPTION_ocbDecrypt ( const uint8_t * key,
const uint8_t * nonce,
const void * aData,
const size_t aDataLen,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt the input stream using OCB-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
noncea.k.a initialization vector with fixed size: OCB_NONCE_LEN
aDataadditional authentication data
aDataLensize of additional authentication data
crtxtinput cipher-text buffer + appended authentication tag
crtxtLensize of ciphertext, excluding tag
pntxtresulting plaintext buffer
Returns
whether message decryption/authentication was successful

Definition at line 1796 of file encryption.c.

References M_AUTHENTICATION_ERROR, M_SUCCESS, memcmp_s, OCB_cipher(), OCB_TAG_LEN, SABOTAGE, and SPP_EXTERNAL_ENCRYPTION_ocbDecrypt().

Referenced by SPP_EXTERNAL_ENCRYPTION_ocbDecrypt(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_keyWrap()

char SPP_EXTERNAL_ENCRYPTION_keyWrap ( const uint8_t * kek,
const void * secret,
const size_t secretLen,
void * wrapped )

encrypt the input secret with key-wrapping method

Parameters
kekkey-encryption-key a.k.a master key
secretinput plaintext secret
secretLensize of secret in bytes
wrappedwrapped secret, prepended with an additional half-block
Returns
error if size is not a multiple of HB, or size < BLOCKSIZE

Main functions for AES key-wrapping

Definition at line 1829 of file encryption.c.

References AES_setkey, BURN, HB, IV_KWA, M_DATALENGTH_ERROR, M_SUCCESS, MIDST, rijndaelEncrypt(), RoundKey, SPP_EXTERNAL_ENCRYPTION_keyWrap(), and xorBEint().

Referenced by SPP_EXTERNAL_ENCRYPTION_keyWrap(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_keyUnwrap()

char SPP_EXTERNAL_ENCRYPTION_keyUnwrap ( const uint8_t * kek,
const void * wrapped,
const size_t wrapLen,
void * secret )

unwrap/decrypt a wrapped secret according to RFC-3394

Parameters
kekkey-encryption-key a.k.a master key
wrappedciphertext input, the wrapped secret
wrapLensize of ciphertext/wrapped input in bytes
secretunwrapped secret, which is a half block shorter than input
Returns
whether decrypting/unwrapping secret was successful

Definition at line 1865 of file encryption.c.

References AES_setkey, BURN, HB, IV_KWA, M_AUTHENTICATION_ERROR, M_DATALENGTH_ERROR, M_SUCCESS, memcmp_s, MIDST, rijndaelDecrypt(), RoundKey, SABOTAGE, SPP_EXTERNAL_ENCRYPTION_keyUnwrap(), and xorBEint().

Referenced by SPP_EXTERNAL_ENCRYPTION_keyUnwrap(), and SPP_EXTERNAL_ENCRYPTION_sivDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addLblocks()

void addLblocks ( const uint8_t * x,
const uint8_t len,
uint8_t * y )
static

add two little-endian blocks x and y up to length len, so that: y = y + x

Definition at line 1905 of file encryption.c.

References addLblocks().

Referenced by addLblocks(), and SPP_EXTERNAL_ENCRYPTION_poly1305().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modP1305()

void modP1305 ( uint8_t * block,
int32_t q )
static

derive modulo(2^130-5) for a large integer saved in a little-endian block

Definition at line 1916 of file encryption.c.

References modP1305(), and PL.

Referenced by modP1305(), mulLblocks(), and SPP_EXTERNAL_ENCRYPTION_poly1305().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mulLblocks()

void mulLblocks ( const uint8_t * x,
uint8_t * y )
static

modular multiplication of two little-endian poly1305 blocks: y *= x mod P

Definition at line 1930 of file encryption.c.

References modP1305(), mulLblocks(), and PL.

Referenced by mulLblocks(), and SPP_EXTERNAL_ENCRYPTION_poly1305().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_poly1305()

void SPP_EXTERNAL_ENCRYPTION_poly1305 ( const uint8_t * keys,
const block_t nonce,
const void * data,
const size_t dataSize,
block_t mac )

derive the Poly1305-AES mac of message using a nonce and key pair.

Parameters
keyspair of encryption/mixing keys (k, r); size = KEYSIZE + 16
noncea 128 bit string which is encrypted by AES_k
databuffer of input data
dataSizesize of data in bytes
maccalculated Poly1305-AES mac

Definition at line 1957 of file encryption.c.

References addLblocks(), AES_setkey, BLOCKSIZE, BURN, KEYSIZE, modP1305(), mulLblocks(), PL, rijndaelEncrypt(), RoundKey, and SPP_EXTERNAL_ENCRYPTION_poly1305().

Referenced by SPP_EXTERNAL_ENCRYPTION_poly1305(), and SPP_EXTERNAL_ENCRYPTION_poly1305().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ numRadix()

void numRadix ( const radix_t * s,
size_t len,
uint8_t * num,
size_t bytes )
static

convert the string s in base-RADIX to a big-endian number, denoted by num

Definition at line 2040 of file encryption.c.

References numRadix(), and RADIX.

Referenced by FF1round(), and numRadix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strRadix()

void strRadix ( const uint8_t * num,
size_t bytes,
radix_t * s,
size_t len )
static

convert a big-endian number to string s, its representation in base-RADIX

Definition at line 2055 of file encryption.c.

References RADIX, and strRadix().

Referenced by FF1round(), and strRadix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addRadix()

void addRadix ( const radix_t * x,
const size_t len,
radix_t * y )
static

add two numbers x, y in base-RADIX and save the result in y, i.e. y += x;

Definition at line 2070 of file encryption.c.

References addRadix(), and RADIX.

Referenced by addRadix(), and FF1_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subRadix()

void subRadix ( const radix_t * x,
const size_t len,
radix_t * y )
static

subtract two numbers in base-RADIX and save the result in y, i.e. y -= x;

Definition at line 2081 of file encryption.c.

References RADIX, and subRadix().

Referenced by FF1_cipher(), and subRadix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FF1round()

void FF1round ( const uint8_t i,
const block_t P,
const size_t u,
const size_t v,
radix_t * C )
static

derive C at step i of FF1 rounds, given the values: u, v and PRF_init = P

Definition at line 2092 of file encryption.c.

References b1, BLOCKSIZE, FF1round(), LAST, numRadix(), rijndaelEncrypt(), strRadix(), xMac(), and xorBEint().

Referenced by FF1_cipher(), and FF1round().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FF1_cipher()

void FF1_cipher ( const uint8_t * key,
const char mode,
const TWEAK_PARAMS ,
const size_t len,
radix_t * X )
static

encrypt/decrypt a base-RADIX string X with length len using FF1 algorithm

Definition at line 2118 of file encryption.c.

References addRadix(), AES_setkey, b1, BLOCKSIZE, FF1_cipher(), FF1round(), LAST, RADIX, rijndaelEncrypt(), subRadix(), TWEAK_PARAMS, xMac(), and xorBEint().

Referenced by FF1_cipher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FPE_cipher()

char FPE_cipher ( const uint8_t * key,
const char mode,
const TWEAK_PARAMS ,
const void * input,
const size_t dataSize,
void * output )
static

encrypt or decrypt the input string with FPE method

Parameters
keyencryption or decryption key
modemode of operation: encrypting (1) or decrypting (0)
tweaktweak byte array
tweakLensize of tweak. must be exactly 7 in FF3-1
inputinput string, consisted of characters in ALPHABET
dataSizelength of the string, or its number of characters
outputresult of format-preserved encryption/decryption
Returns
an associated error code in case of failure

Definition at line 2269 of file encryption.c.

References ALPHABET, b1, BURN, FPE_cipher(), FPE_PERMUTE, KEYSIZE, LAST, LOGRDX, M_DATAFORMAT_ERROR, M_DATALENGTH_ERROR, M_MEMORY_ERROR, M_SUCCESS, MAXLEN, MINLEN, RADIX, RoundKey, TWEAK_AGRS, and TWEAK_PARAMS.

Referenced by FPE_cipher(), SPP_EXTERNAL_ENCRYPTION_fpeDecrypt(), and SPP_EXTERNAL_ENCRYPTION_fpeEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_fpeEncrypt()

char SPP_EXTERNAL_ENCRYPTION_fpeEncrypt ( const uint8_t * key,
const TWEAK_PARAMS ,
const void * pntxt,
const size_t ptextLen,
void * crtxt )

encrypt the input string using FPE-AES block-cipher method

Parameters
keyencryption key with a fixed size specified by KEYSIZE
tweaktweak byte array; similar to nonce in other schemes
tweakLensize of tweak. must be exactly 7 in FF3-1
pntxtinput plaintext string, consisted of ALPHABET characters
ptextLensize of plaintext string, or number of characters
crtxtresulting ciphertext string
Returns
whether encryption was successful

Definition at line 2328 of file encryption.c.

References FPE_cipher(), SPP_EXTERNAL_ENCRYPTION_fpeEncrypt(), TWEAK_AGRS, and TWEAK_PARAMS.

Referenced by SPP_EXTERNAL_ENCRYPTION_fpeEncrypt(), and SPP_EXTERNAL_ENCRYPTION_fpeEncrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_fpeDecrypt()

char SPP_EXTERNAL_ENCRYPTION_fpeDecrypt ( const uint8_t * key,
const TWEAK_PARAMS ,
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

decrypt a ciphertext string using FPE-AES block-cipher method

Parameters
keydecryption key with a fixed size specified by KEYSIZE
tweaktweak byte array; similar to nonce in other schemes
tweakLensize of tweak. must be exactly 7 in FF3-1
crtxtinput ciphertext string, consisted of ALPHABET characters
crtxtLensize of ciphertext string, or number of characters
pntxtresulting plaintext string
Returns
whether decryption was successful

Definition at line 2344 of file encryption.c.

References FPE_cipher(), SPP_EXTERNAL_ENCRYPTION_fpeDecrypt(), TWEAK_AGRS, and TWEAK_PARAMS.

Referenced by SPP_EXTERNAL_ENCRYPTION_fpeDecrypt(), and SPP_EXTERNAL_ENCRYPTION_fpeDecrypt().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ sbox

const char sbox[256]
static
Initial value:
=
"c|w{\362ko\3050\01g+\376\327\253v\312\202\311}\372YG\360\255\324\242\257"""
"\234\244r\300\267\375\223&6\?\367\3144\245\345\361q\3301\25\04\307#\303\30"
"\226\05\232\a\22\200\342\353\'\262u\t\203,\32\33nZ\240R;\326\263)\343/\204"
"S\321\0\355 \374\261[j\313\2769JLX\317\320\357\252\373CM3\205E\371\02\177P"
"<\237\250Q\243@\217\222\2358\365\274\266\332!\20\377\363\322\315\f\23\354_"
"\227D\27\304\247~=d]\31s`\201O\334\"*\220\210F\356\270\24\336^\v\333\3402:"
"\nI\06$\\\302\323\254b\221\225\344y\347\3107m\215\325N\251lV\364\352ez\256"
"\b\272x%.\34\246\264\306\350\335t\37K\275\213\212p>\265fH\03\366\16a5W\271"
"\206\301\035\236\341\370\230\021i\331\216\224\233\36\207\351\316U(\337\214"
"\241\211\r\277\346BhA\231-\17\260T\273\26"

Lookup-tables are "static constant", so that they can be placed in read-only storage instead of RAM. They can be computed dynamically trading ROM for RAM. This may be useful in (embedded) bootloader applications, where ROM is often limited. Note that sbox[y] = x, if and only if rsbox[x] = y. For more details on dynamic sbox computation, see https://en.wikipedia.org/wiki/Rijndael_S-box

Definition at line 41 of file encryption.c.

◆ rsbox

const char rsbox[256]
static
Initial value:
=
"R\tj\32506\2458\277@\243\236\201\363\327\373|\3439\202\233/\377\2074\216CD"
"\304\336\351\313T{\2242\246\302#=\356L\225\vB\372\303N\b.\241f(\331$\262v["
"\242Im\213\321%r\370\366d\206h\230\026\324\244\\\314]e\266\222lpHP\375\355"
"\271\332^\25FW\247\215\235\204\220\330\253\0\214\274\323\n\367\344X\05\270"
"\263E\06\320,\036\217\312?\17\02\301\257\275\03\01\23\212k:\221\021AOg\334"
"\352\227\362\317\316\360\264\346s\226\254t\"\347\2555\205\342\3717\350\34u"
"\337nG\361\32q\35)\305\211o\267b\16\252\30\276\33\374V>K\306\322y \232\333"
"\300\376x\315Z\364\037\335\2503\210\a\3071\261\22\20Y\'\200\354_`Q\177\251"
"\31\265J\r-\345z\237\223\311\234\357\240\340;M\256*\365\260\310\353\273<"""
"\203S\231a\27+\4~\272w\326&\341i\24cU!\f}"

Definition at line 54 of file encryption.c.

◆ RoundKey

◆ b1

size_t b1
static

Definition at line 2037 of file encryption.c.

Referenced by FF1_cipher(), FF1round(), and FPE_cipher().