Solaris Software
Loading...
Searching...
No Matches
encryption.h File Reference
#include <string.h>
#include <limits.h>
Include dependency graph for encryption.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AES___   128
#define BLOCKCIPHERS   1
#define AEAD_MODES   1
#define ECB   1
#define CBC   1
#define CFB   1
#define OFB   1
#define CTR   1
#define XEX   1
#define KWA   1
#define FPE   1
#define CMAC   1
#define CCM   1
#define GCM   1
#define EAX   1
#define SIV   1
#define GCM_SIV   1
#define OCB   1
#define POLY1305   1
#define CTS   1
#define XTS   1
#define CTR_NA   1
#define EAXP   0
#define WTF   ! (BLOCKCIPHERS | AEAD_MODES)
#define MICRO_RJNDL   WTF
#define AES_PADDING   0
#define DECRYPTION   1
#define CUSTOM_ALPHABET   0
#define FF_X   1
#define PRESET_COUNTER   0
#define SDCC_REENT

Enumerations

enum  constant_parameters_of_modes {
  CTR_START_VALUE = 1 , CTR_IV_LENGTH = 12 , CCM_NONCE_LEN = 11 , CCM_TAG_LEN = 16 ,
  GCM_NONCE_LEN = 12 , GCM_TAG_LEN = 16 , SIVGCM_NONCE_LEN = 12 , SIVGCM_TAG_LEN = 16 ,
  OCB_NONCE_LEN = 12 , OCB_TAG_LEN = 16 , EAX_NONCE_LEN = 16 , EAX_TAG_LEN = 16 ,
  AES_KEYLENGTH = 16
}
enum  function_result_codes {
  M_ENCRYPTION_ERROR = 'E' , M_DECRYPTION_ERROR = 'D' , M_AUTHENTICATION_ERROR = 'A' , M_DATALENGTH_ERROR = 'L' ,
  M_DATAFORMAT_ERROR = 'F' , M_MEMORY_ERROR = 'M' , M_SUCCESS = 0
}

Functions

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 uint8_t iVec[16], const void *pntxt, const size_t ptextLen, void *crtxt)
char SPP_EXTERNAL_ENCRYPTION_cbcDecrypt (const uint8_t *key, const uint8_t iVec[16], const void *crtxt, const size_t crtxtLen, void *pntxt)
void SPP_EXTERNAL_ENCRYPTION_cfbEncrypt (const uint8_t *key, const uint8_t iVec[16], const void *pntxt, const size_t ptextLen, void *crtxt)
void SPP_EXTERNAL_ENCRYPTION_cfbDecrypt (const uint8_t *key, const uint8_t iVec[16], const void *crtxt, const size_t crtxtLen, void *pntxt)
void SPP_EXTERNAL_ENCRYPTION_ofbEncrypt (const uint8_t *key, const uint8_t iVec[16], const void *pntxt, const size_t ptextLen, void *crtxt)
void SPP_EXTERNAL_ENCRYPTION_ofbDecrypt (const uint8_t *key, const uint8_t iVec[16], const void *crtxt, const size_t crtxtLen, void *pntxt)
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_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
void SPP_EXTERNAL_ENCRYPTION_sivEncrypt (const uint8_t *keys, const void *aData, const size_t aDataLen, const void *pntxt, const size_t ptextLen, uint8_t iv[16], void *crtxt)
char SPP_EXTERNAL_ENCRYPTION_sivDecrypt (const uint8_t *keys, const uint8_t iv[16], const void *aData, const size_t aDataLen, const void *crtxt, const size_t crtxtLen, void *pntxt)
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
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
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
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
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
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
char SPP_EXTERNAL_ENCRYPTION_fpeEncrypt (const uint8_t *key, const uint8_t *tweak, const size_t tweakLen, const void *pntxt, const size_t ptextLen, void *crtxt)
char SPP_EXTERNAL_ENCRYPTION_fpeDecrypt (const uint8_t *key, const uint8_t *tweak, const size_t tweakLen, const void *crtxt, const size_t crtxtLen, void *pntxt)
void SPP_EXTERNAL_ENCRYPTION_poly1305 (const uint8_t *keys, const uint8_t nonce[16], const void *data, const size_t dataSize, uint8_t mac[16])
void SPP_EXTERNAL_ENCRYPTION_cmac (const uint8_t *key, const void *data, const size_t dataSize, uint8_t mac[16])

Macro Definition Documentation

◆ AES___

#define AES___   128

You can use different AES algorithms by changing this macro. Default is AES-128

Definition at line 18 of file encryption.h.

◆ BLOCKCIPHERS

#define BLOCKCIPHERS   1

AES block-cipher modes of operation. The following modes can be enabled/disabled

by setting their corresponding macros to TRUE (1) or FALSE (0).

Definition at line 24 of file encryption.h.

◆ AEAD_MODES

#define AEAD_MODES   1

Definition at line 25 of file encryption.h.

◆ ECB

#define ECB   1

Definition at line 28 of file encryption.h.

◆ CBC

#define CBC   1

Definition at line 29 of file encryption.h.

◆ CFB

#define CFB   1

Definition at line 30 of file encryption.h.

◆ OFB

#define OFB   1

Definition at line 31 of file encryption.h.

◆ CTR

#define CTR   1

Definition at line 32 of file encryption.h.

◆ XEX

#define XEX   1

Definition at line 33 of file encryption.h.

◆ KWA

#define KWA   1

Definition at line 34 of file encryption.h.

◆ FPE

#define FPE   1

Definition at line 35 of file encryption.h.

◆ CMAC

#define CMAC   1

Definition at line 39 of file encryption.h.

◆ CCM

#define CCM   1

Definition at line 42 of file encryption.h.

◆ GCM

#define GCM   1

Definition at line 43 of file encryption.h.

◆ EAX

#define EAX   1

Definition at line 44 of file encryption.h.

◆ SIV

#define SIV   1

Definition at line 45 of file encryption.h.

◆ GCM_SIV

#define GCM_SIV   1

Definition at line 46 of file encryption.h.

◆ OCB

#define OCB   1

Definition at line 50 of file encryption.h.

◆ POLY1305

#define POLY1305   1

Definition at line 53 of file encryption.h.

◆ CTS

#define CTS   1

Definition at line 57 of file encryption.h.

◆ XTS

#define XTS   1

Definition at line 61 of file encryption.h.

◆ CTR_NA

#define CTR_NA   1

Definition at line 65 of file encryption.h.

◆ EAXP

◆ WTF

#define WTF   ! (BLOCKCIPHERS | AEAD_MODES)

Definition at line 72 of file encryption.h.

◆ MICRO_RJNDL

#define MICRO_RJNDL   WTF

Definition at line 73 of file encryption.h.

◆ AES_PADDING

#define AES_PADDING   0

Parameters and MACROs; refer to the bottom of this document for more info:

Definition at line 80 of file encryption.h.

Referenced by padBlock().

◆ DECRYPTION

#define DECRYPTION   1

Definition at line 84 of file encryption.h.

◆ CUSTOM_ALPHABET

#define CUSTOM_ALPHABET   0

Definition at line 88 of file encryption.h.

◆ FF_X

#define FF_X   1

◆ PRESET_COUNTER

#define PRESET_COUNTER   0

Definition at line 101 of file encryption.h.

◆ SDCC_REENT

#define SDCC_REENT

Since <stdint.h> is not a part of ANSI-C, we may need a 'trick' to use uint8_t

Definition at line 153 of file encryption.h.

Enumeration Type Documentation

◆ constant_parameters_of_modes

Enumerator
CTR_START_VALUE 
CTR_IV_LENGTH 
CCM_NONCE_LEN 
CCM_TAG_LEN 
GCM_NONCE_LEN 
GCM_TAG_LEN 
SIVGCM_NONCE_LEN 
SIVGCM_TAG_LEN 
OCB_NONCE_LEN 
OCB_TAG_LEN 
EAX_NONCE_LEN 
EAX_TAG_LEN 
AES_KEYLENGTH 

Definition at line 92 of file encryption.h.

◆ function_result_codes


Define some error codes here

Enumerator
M_ENCRYPTION_ERROR 
M_DECRYPTION_ERROR 
M_AUTHENTICATION_ERROR 
M_DATALENGTH_ERROR 
M_DATAFORMAT_ERROR 
M_MEMORY_ERROR 
M_SUCCESS 

Definition at line 470 of file encryption.h.

Function Documentation

◆ 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


Encryption/decryption of a single block with Rijndael


Main functions for ECB-AES block ciphering

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

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 uint8_t iVec[16],
const void * pntxt,
const size_t ptextLen,
void * crtxt )

Main functions for CBC-AES block ciphering

References SPP_EXTERNAL_ENCRYPTION_cbcEncrypt().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cbcDecrypt()

char SPP_EXTERNAL_ENCRYPTION_cbcDecrypt ( const uint8_t * key,
const uint8_t iVec[16],
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

References SPP_EXTERNAL_ENCRYPTION_cbcDecrypt().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cfbEncrypt()

void SPP_EXTERNAL_ENCRYPTION_cfbEncrypt ( const uint8_t * key,
const uint8_t iVec[16],
const void * pntxt,
const size_t ptextLen,
void * crtxt )

Main functions for CFB-AES block ciphering

References SPP_EXTERNAL_ENCRYPTION_cfbEncrypt().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cfbDecrypt()

void SPP_EXTERNAL_ENCRYPTION_cfbDecrypt ( const uint8_t * key,
const uint8_t iVec[16],
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

References SPP_EXTERNAL_ENCRYPTION_cfbDecrypt().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ofbEncrypt()

void SPP_EXTERNAL_ENCRYPTION_ofbEncrypt ( const uint8_t * key,
const uint8_t iVec[16],
const void * pntxt,
const size_t ptextLen,
void * crtxt )

Main functions for OFB-AES block ciphering

References SPP_EXTERNAL_ENCRYPTION_ofbEncrypt().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_ofbDecrypt()

void SPP_EXTERNAL_ENCRYPTION_ofbDecrypt ( const uint8_t * key,
const uint8_t iVec[16],
const void * crtxt,
const size_t crtxtLen,
void * pntxt )

References SPP_EXTERNAL_ENCRYPTION_ctrDecrypt(), SPP_EXTERNAL_ENCRYPTION_ctrEncrypt(), SPP_EXTERNAL_ENCRYPTION_ofbDecrypt(), SPP_EXTERNAL_ENCRYPTION_xtsDecrypt(), and SPP_EXTERNAL_ENCRYPTION_xtsEncrypt().

Here is the call 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


Main functions for XTS-AES block ciphering

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

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_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


Main functions for CTR-AES block ciphering

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

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:

◆ 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,
uint8_t iv[16],
void * crtxt )

Main functions for SIV-AES block ciphering

References SPP_EXTERNAL_ENCRYPTION_sivEncrypt().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_sivDecrypt()

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

◆ 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


Main functions for GCM-AES block ciphering

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

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:

◆ 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


Main functions for CCM-AES block ciphering

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

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:

◆ 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


Main functions for OCB-AES block ciphering

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

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_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


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

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')

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:

◆ 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


Main functions for GCM-SIV-AES block ciphering

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

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:

◆ 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


Main functions for AES key-wrapping

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

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:

◆ SPP_EXTERNAL_ENCRYPTION_fpeEncrypt()

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

Main functions for FPE-AES; more info at the bottom of this page.

References FF_X, and SPP_EXTERNAL_ENCRYPTION_fpeEncrypt().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_fpeDecrypt()

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

References FF_X, and SPP_EXTERNAL_ENCRYPTION_fpeDecrypt().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_poly1305()

void SPP_EXTERNAL_ENCRYPTION_poly1305 ( const uint8_t * keys,
const uint8_t nonce[16],
const void * data,
const size_t dataSize,
uint8_t mac[16] )

Main function for Poly1305-AES message authentication code

References SPP_EXTERNAL_ENCRYPTION_poly1305().

Here is the call graph for this function:

◆ SPP_EXTERNAL_ENCRYPTION_cmac()

void SPP_EXTERNAL_ENCRYPTION_cmac ( const uint8_t * key,
const void * data,
const size_t dataSize,
uint8_t mac[16] )

Main function for AES Cipher-based Message Authentication Code

References SPP_EXTERNAL_ENCRYPTION_cmac().

Here is the call graph for this function: