
|
My Project
|
Functions | |
| WOLFSSL_API int | wc_Chacha_SetIV (ChaCha *ctx, const byte *inIv, word32 counter) |
| This function sets the initialization vector (nonce) for a ChaCha object, initializing it for use as a cipher. It should be called after the key has been set, using wc_Chacha_SetKey. A difference nonce should be used for each round of encryption. | |
| WOLFSSL_API int | wc_Chacha_Process (ChaCha *ctx, byte *cipher, const byte *plain, word32 msglen) |
| This function processes the text from the buffer input, encrypts or decrypts it, and stores the result in the buffer output. | |
| WOLFSSL_API int | wc_Chacha_SetKey (ChaCha *ctx, const byte *key, word32 keySz) |
| This function sets the key for a ChaCha object, initializing it for use as a cipher. It should be called before setting the nonce with wc_Chacha_SetIV, and before using it for encryption with wc_Chacha_Process. | |
| WOLFSSL_API int wc_Chacha_Process | ( | ChaCha * | ctx, |
| byte * | output, | ||
| const byte * | input, | ||
| word32 | msglen ) |
This function processes the text from the buffer input, encrypts or decrypts it, and stores the result in the buffer output.
| ctx | pointer to the ChaCha structure on which to set the iv |
| output | pointer to a buffer in which to store the output ciphertext or decrypted plaintext |
| input | pointer to the buffer containing the input plaintext to encrypt or the input ciphertext to decrypt |
| msglen | length of the message to encrypt or the ciphertext to decrypt |
Example
API to encrypt/decrypt a message of any size.
| WOLFSSL_API int wc_Chacha_SetIV | ( | ChaCha * | ctx, |
| const byte * | inIv, | ||
| word32 | counter ) |
This function sets the initialization vector (nonce) for a ChaCha object, initializing it for use as a cipher. It should be called after the key has been set, using wc_Chacha_SetKey. A difference nonce should be used for each round of encryption.
| ctx | pointer to the ChaCha structure on which to set the iv |
| inIv | pointer to a buffer containing the 12 byte initialization vector with which to initialize the ChaCha structure |
| counter | the value at which the block counter should start–usually zero. |
Example
Set up iv(nonce). Earlier versions used 64 bits instead of 96, this version uses the typical AEAD 96 bit nonce and can do record sizes of 256 GB.
| WOLFSSL_API int wc_Chacha_SetKey | ( | ChaCha * | ctx, |
| const byte * | key, | ||
| word32 | keySz ) |
This function sets the key for a ChaCha object, initializing it for use as a cipher. It should be called before setting the nonce with wc_Chacha_SetIV, and before using it for encryption with wc_Chacha_Process.
| ctx | pointer to the ChaCha structure in which to set the key |
| key | pointer to a buffer containing the 16 or 32 byte key with which to initialize the ChaCha structure |
| keySz | the length of the key passed in |
Example
Key setup. 8 word iv (nonce)