Protocol++® (Protocolpp®)
v5.6.2
|
Public Types | |
enum | cipher_t { AES , Serpent , DES , DES_EDE3 , Camellia , ARIA , SEED , SM4 , CHACHA20 , SNOWE , SNOWV , SNOWV_GCM , ZUCE , ARC4 , NONE } |
enum | dir_t { ENC =1 , DEC =0 , DOWNLINK =1 , UPLINK =0 } |
enum | mode_t { ECB , CBC , GCM , CTR , CCM , XTS , XCBC_MAC , GMAC , CMAC , AEAD , AUTH , STREAM } |
Public Member Functions | |
jmodes (cipher_t cipher, dir_t dir, mode_t mode, uint8_t *key, uint32_t keyLen, uint8_t *iv=nullptr, uint32_t ivLen=0, uint32_t icvLen=16, uint32_t count=0, uint8_t bearer=0) | |
jmodes (auth_t auth, uint8_t *authkey=nullptr, uint32_t authkeyLen=0, dir_t dir=DEC, uint32_t count=0, uint32_t fresh=0) | |
jmodes (auth_t auth, dir_t dir, uint8_t *authkey, uint32_t authkeyLen, uint8_t *iv, uint32_t ivLen, uint32_t icvLen) | |
jmodes (auth_t auth=auth_t::CRC32_IEEE, uint32_t poly=0, uint32_t polysize=0, bool zeroinit=false, bool swapin=true, bool swapout=true, bool compout=true) | |
~jmodes () | |
Standard deconstructor. | |
void | ProcessData (uint8_t *input, uint8_t *output, uint32_t length, uint8_t *aad=nullptr, uint32_t aadlen=0, uint8_t *icv=nullptr, uint32_t icvlen=0) |
void | ProcessData (const uint8_t *input, uint32_t length) |
void | context (uint8_t *context, uint32_t length) |
void | result (uint8_t *result, uint32_t length) |
jmodes (jmodes &jmodes)=delete | |
jmodes (const jmodes &jmodes)=delete | |
Encryption Algorithm
AES - Advanced Encryption Standard Serpent - Serpent Encryption Algorithm DES - Data Encryption Standard DES_EDE3 - Triple-DES Camellia - Japanese national standard cipher ARIA - Korean national standard cipher SEED - Korean block cipher SM4 - Chinese block cipher CHACHA20 - Stream cipher SNOWE - Snow3G encryption cipher SNOWV - SNOW-V encryption cipher SNOWV_GCM - SNOWV_GCM encryption and authentication cipher ZUCE - ZUC encryption cipher ARC4 - ARC4 encryption cipher
Mode of operation
ECB - Electronic Code Book (ECB) CBC - Cipher Block Chaining (CBC) GCM - Galois Counter Mode (GCM) CTR - Counter Mode (CTR) CCM - Counter with Cipher Block Chaining-Message Authentication Code (CCM) XTS - XTS drive encryption XCBC_MAC - CBC-MAC with 12-byte ICV GMAC - Galios field based MAC algorithm CMAC - Block-Cipher based MAC algorithm AEAD - AEAD dual mode with POLY1305 AUTH - Authentication mode STREAM - Stream cipher mode (ARC4, CHACHA20)
ProtocolPP::jmodes::jmodes | ( | cipher_t | cipher, |
dir_t | dir, | ||
mode_t | mode, | ||
uint8_t * | key, | ||
uint32_t | keyLen, | ||
uint8_t * | iv = nullptr , |
||
uint32_t | ivLen = 0 , |
||
uint32_t | icvLen = 16 , |
||
uint32_t | count = 0 , |
||
uint8_t | bearer = 0 |
||
) |
Constructor for different cipher modes which supports key sizes of 128, 192, and 256 bits
cipher | - Encryption algorithm to use (AES, DES, DES_EDE3, Camellia, SEED, SM4, ARIA, CHACHA20, ARC4) |
dir | - direction of processing (ENC or DEC) |
mode | - either ECB, CBC, CTR, GCM, XCBC_MAC, CMAC, GMAC, AEAD, STREAM, or AUTH mode |
key | - master key for processing |
keyLen | - Length of the key in bytes |
iv | - initialization vector for CBC/GCM |
ivLen | - Length of the IV in bytes |
icvLen | - Length of the ICV in bytes |
count | - Count value for SNOW3G and ZUC |
bearer | - BEARER value for SNOW3G and ZUC |
Examples:
|
explicit |
Constructor for authentication modes
auth | - Authentication (see jenum.h for modes) |
authkey | - key for processing |
authkeyLen | - Length of the key in bytes |
dir | - direction of processing for SNOW3G and ZUC |
count | - Count value for SNOW3G and ZUC |
fresh | - FRESH/BEARER value for SNOW3G and ZUC |
Examples:
ProtocolPP::jmodes::jmodes | ( | auth_t | auth, |
dir_t | dir, | ||
uint8_t * | authkey, | ||
uint32_t | authkeyLen, | ||
uint8_t * | iv, | ||
uint32_t | ivLen, | ||
uint32_t | icvLen | ||
) |
Constructor for ZUC-256 authentication modes
auth | - Authentication (see jenum.h for modes) |
dir | - direction of processing for SNOW3G and ZUC |
authkey | - key for processing |
authkeyLen | - Length of the key in bytes |
iv | - IV for processing |
ivLen | - Length of the IV in bytes |
icvLen | - Length of the ICV in bytes |
Examples:
|
explicit |
Constructor for CRC modes
auth | - CRC modes (CRC5, CRC7, CRC8, CRC11, CRC12, CRC16, CRC16_CCITT, CRC24, CRC32_IETF, CRC32_IEEE, CRC_POLY) |
poly | - Polynomial for CRC processing |
polysize | - Length of the polynomial in bits |
zeroinit | - Initial value is all zero |
swapin | - swap input data before processing |
swapout | - swap output data (bit and byte) before processing |
compout | - complement output data before processing |
void ProtocolPP::jmodes::context | ( | uint8_t * | context, |
uint32_t | length | ||
) |
Retrieves the context (IV)
context | - data to retrieve |
length | - length of the data to retrieve (bytes) |
void ProtocolPP::jmodes::ProcessData | ( | const uint8_t * | input, |
uint32_t | length | ||
) |
Authenticates the input data
input | - input data to process |
length | - length of the data in bytes |
Examples:
void ProtocolPP::jmodes::ProcessData | ( | uint8_t * | input, |
uint8_t * | output, | ||
uint32_t | length, | ||
uint8_t * | aad = nullptr , |
||
uint32_t | aadlen = 0 , |
||
uint8_t * | icv = nullptr , |
||
uint32_t | icvlen = 0 |
||
) |
Encrypts or decrypts the data based on direction and mode
input | - input data to process |
output | - processed data |
length | - length of the data in bytes |
aad | - authentication only data |
aadlen | - length of the AAD data in bytes |
icv | - received ICV for AEAD mode |
icvlen | - length of the received ICV data in bytes |
Examples:
void ProtocolPP::jmodes::result | ( | uint8_t * | result, |
uint32_t | length | ||
) |
Retrieves the result (ICV). For hash only functions performs the final calculation before returning the data to the user
result | - data to retrieve |
length | - length of the data to retrieve (bytes) |