Functions
Algorithms - HC-128

Functions

WOLFSSL_API int wc_Hc128_Process (HC128 *, byte *, const byte *, word32)
 This function encrypts or decrypts a message of any size from the input buffer input, and stores the resulting plaintext/ciphertext in the output buffer output. More...
 
WOLFSSL_API int wc_Hc128_SetKey (HC128 *, const byte *key, const byte *iv)
 This function initializes an HC128 context object by setting its key and iv. More...
 

Detailed Description

Function Documentation

◆ wc_Hc128_Process()

WOLFSSL_API int wc_Hc128_Process ( HC128 ,
byte *  ,
const byte *  ,
word32   
)

This function encrypts or decrypts a message of any size from the input buffer input, and stores the resulting plaintext/ciphertext in the output buffer output.

Returns
0 Returned upon successfully encrypting/decrypting the given input
MEMORY_E Returned if the input and output buffers are not aligned along a 4-byte boundary, and there is an error allocating memory
BAD_ALIGN_E Returned if the input or output buffers are not aligned along a 4-byte boundary, and NO_WOLFSSL_ALLOC_ALIGN is defined
Parameters
ctxpointer to a HC-128 context object with an initialized key to use for encryption or decryption
outputbuffer in which to store the processed input
inputbuffer containing the plaintext to encrypt or the ciphertext to decrypt
msglenlength of the plaintext to encrypt or the ciphertext to decrypt

Example

HC128 enc;
byte key[] = { // initialize with key };
byte iv[] = { // initialize with iv };
wc_Hc128_SetKey(&enc, key, iv);
byte msg[] = { // initialize with message };
byte cipher[sizeof(msg)];
if (wc_Hc128_Process(*enc, cipher, plain, sizeof(plain)) != 0) {
// error encrypting msg
}
See also
wc_Hc128_SetKey

◆ wc_Hc128_SetKey()

WOLFSSL_API int wc_Hc128_SetKey ( HC128 ,
const byte *  key,
const byte *  iv 
)

This function initializes an HC128 context object by setting its key and iv.

Returns
0 Returned upon successfully setting the key and iv for the HC128 context object
Parameters
ctxpointer to an HC-128 context object to initialize
keypointer to the buffer containing the 16 byte key to use with encryption/decryption
ivpointer to the buffer containing the 16 byte iv (nonce) with which to initialize the HC128 object

Example

HC128 enc;
byte key[] = { // initialize with key };
byte iv[] = { // initialize with iv };
wc_Hc128_SetKey(&enc, key, iv);
See also
wc_Hc128_Process