Protocol++® (Protocolpp®)  v5.6.2
ProtocolPP::jmodes Class Reference

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
 

Member Enumeration Documentation

◆ cipher_t

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

Enumerator
AES 

Advanced Encryption Standard.

Serpent 

Serpent Encryption Algorithm.

DES 

Data Encryption Standard.

DES_EDE3 

Triple-DES with 192-bit key.

Camellia 

Camellia Cipher.

ARIA 

ARIA cipher.

SEED 

SEED cipher.

SM4 

SM4 cipher.

CHACHA20 

CHACHA20 stream cipher.

SNOWE 

SNOW3G F8 encryption mode.

SNOWV 

SNOW-V F8 encryption mode.

SNOWV_GCM 

SNOWV-GCM AEAD encrypt and authentication mode.

ZUCE 

ZUC F8 encryption mode.

ARC4 

ARC4 stream cipher.

NONE 

No cipher used.

◆ dir_t

Direction of processing

ENC - Encrypt the data DEC - Decrypt the data DOWNLINK - Connection from Tower to User UPLINK - Connection from User to Tower

Enumerator
ENC 

Encryption.

DEC 

Decryption.

DOWNLINK 

Tower to user.

UPLINK 

User to tower.

◆ mode_t

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)

Enumerator
ECB 

Electronic Code Book.

CBC 

Cipher Block Chaining.

GCM 

Galois Counter Mode.

CTR 

Counter Mode.

CCM 

Counter with Cipher Block Chaining-Message Authentication Code.

XTS 

XTS drive encryption.

XCBC_MAC 

AES-XCBC-MAC-96 one way hash.

GMAC 

Galios field based MAC algorithm.

CMAC 

Cipher-based MAC algorithm.

AEAD 

AEAD dual mode with POLY1305.

AUTH 

Authentication mode.

STREAM 

Stream cipher mode (ARC4, CHACHA20)

Constructor & Destructor Documentation

◆ jmodes() [1/4]

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

Parameters
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:

jmodes aesgcm(cipher_t::AES,
dir_t::ENCAP,
mode_t::GCM,
cipherkey.get_ptr(),
cipherkey.get_size(),
iv.get_ptr(),
iv.get_size(),
16);
jmodes aesghash(cipher_t::AES,
dir_t::ENCAP,
mode_t::GMAC,
cipherkey.get_ptr(),
cipherkey.get_size(),
iv.get_ptr(),
iv.get_size(),
16);
jmodes chachapoly(cipher_t::CHACHA20,
dir_t::ENCAP,
mode_t::AEAD,
cipherkey.get_ptr(),
cipherkey.get_size(),
iv.get_ptr(),
iv.get_size(),
16);
jmodes chachastream(cipher_t::CHACHA20,
dir_t::ENCAP,
mode_t::STREAM,
cipherkey.get_ptr(),
cipherkey.get_size());
jmodes snowvstream(cipher_t::SNOWV,
dir_t::ENCAP,
mode_t::STREAM,
cipherkey.get_ptr(),
cipherkey.get_size());
jmodes snowvgcm(cipher_t::SNOWV_GCM,
dir_t::ENCAP,
mode_t::AEAD,
cipherkey.get_ptr(),
cipherkey.get_size(),
iv.get_ptr(),
iv.get_size(),
16);

◆ jmodes() [2/4]

ProtocolPP::jmodes::jmodes ( auth_t  auth,
uint8_t *  authkey = nullptr,
uint32_t  authkeyLen = 0,
dir_t  dir = DEC,
uint32_t  count = 0,
uint32_t  fresh = 0 
)
explicit

Constructor for authentication modes

Parameters
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:

jmodes sha3(auth_t::SHA3_256);
jmodes shake(auth_t::SHAKE128);
jmodes hash(auth_t::SHA384);
jmodes hmac(auth_t::HMAC_SHA3_224,
authkey.get_ptr(),
authkey.get_size());
jmodes hmac(auth_t::POLY1305,
authkey.get_ptr(),
authkey.get_size());
jmodes hash(auth_t::SM3);

◆ jmodes() [3/4]

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

Parameters
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:

jmodes hmac(auth_t::ZUCA,
dir_t::UPLINK
authkey.get_ptr(),
authkey.get_size()
iv.get_ptr(),
iv.get_size(),
8);

◆ jmodes() [4/4]

ProtocolPP::jmodes::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 
)
explicit

Constructor for CRC modes

Parameters
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

Member Function Documentation

◆ context()

void ProtocolPP::jmodes::context ( uint8_t *  context,
uint32_t  length 
)

Retrieves the context (IV)

Parameters
context- data to retrieve
length- length of the data to retrieve (bytes)

◆ ProcessData() [1/2]

void ProtocolPP::jmodes::ProcessData ( const uint8_t *  input,
uint32_t  length 
)

Authenticates the input data

Parameters
input- input data to process
length- length of the data in bytes

Examples:

// Process SHA3
sha3.ProcessData(input.get_ptr(),
input.get_size());
// Process POLY1305
poly1305.ProcessData(input.get_ptr(),
input.get_size());

◆ ProcessData() [2/2]

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

Parameters
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:

// Process AES-GCM
aesgcm.ProcessData(input.get_ptr(),
output.get_ptr(),
input.get_size(),
authdata.get_ptr(),
authdata.get_size(),
ricv.get_ptr(),
ricv.get_size())
aesgcm.result(icv.get_ptr(),
icv.get_size());
// Process AES-GMAC
ghash.ProcessData(nullptr,
nullptr,
0,
authdata.get_ptr(),
authdata.get_size(),
ricv.get_ptr(),
ricv.get_size())
ghash.result(icv.get_ptr(),
icv.get_size());
// Process SNOWV stream cipher
snowvstream.ProcessData(input.get_ptr(),
output.get_ptr(),
input.get_size());

◆ result()

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

Parameters
result- data to retrieve
length- length of the data to retrieve (bytes)

The documentation for this class was generated from the following file: