![]() |
ISARA Quantum Resistant Toolkit
Version 1.1
Quantum resistant cryptographic primitives and algorithms.
|
Macros | |
#define | IQR_CHACHA20_KEY_SIZE 32 |
#define | IQR_CHACHA20_NONCE_SIZE 12 |
Functions | |
IQR_API iqr_retval | iqr_ChaCha20Encrypt (const uint8_t *key, size_t key_size, const uint8_t *nonce, size_t nonce_size, uint32_t counter, const uint8_t *plaintext, size_t plaintext_size, uint8_t *ciphertext, size_t ciphertext_size) |
IQR_API iqr_retval | iqr_ChaCha20Decrypt (const uint8_t *key, size_t key_size, const uint8_t *nonce, size_t nonce_size, uint32_t counter, const uint8_t *ciphertext, size_t ciphertext_size, uint8_t *plaintext, size_t plaintext_size) |
#define IQR_CHACHA20_KEY_SIZE 32 |
The size of a ChaCha20 key in bytes (256 bits).
#define IQR_CHACHA20_NONCE_SIZE 12 |
The size of a ChaCha20 nonce in bytes (96 bits).
IQR_API iqr_retval iqr_ChaCha20Decrypt | ( | const uint8_t * | key, |
size_t | key_size, | ||
const uint8_t * | nonce, | ||
size_t | nonce_size, | ||
uint32_t | counter, | ||
const uint8_t * | ciphertext, | ||
size_t | ciphertext_size, | ||
uint8_t * | plaintext, | ||
size_t | plaintext_size | ||
) |
Decrypt a ciphertext message using the ChaCha20 stream cipher, standardized in RFC-7539.
ChaCha20 is its own inverse so a second application of the encryption function with identical key, counter, and nonce is equivalent to calling the decryption function.
The plaintext and ciphertext buffers cannot overlap except if they are pointers to the same location with the same size. IQR_EPTROVERLAP
will be returned if the buffers overlap and/or have different sizes.
[in] | key | A buffer containing 256 bits of keying material. |
[in] | key_size | Size of the key buffer in bytes. This value must always be equal to IQR_CHACHA20_KEY_SIZE . |
[in] | nonce | A buffer containing a 96-bit nonce. |
[in] | nonce_size | Size of the nonce buffer in bytes. This value must always be equal to IQR_CHACHA20_NONCE_SIZE . |
[in] | counter | Initial block counter value. |
[in] | ciphertext | A buffer containing the ciphertext message to be decrypted. |
[in] | ciphertext_size | The size of buffer ciphertext in bytes. |
[out] | plaintext | The buffer to which the decrypted message will be written. |
[in] | plaintext_size | The size of buffer plaintext in bytes. This must be greater than or equal to ciphertext_size. |
IQR_OK
on success, or a value from iqr_retval.h when an error occurs. IQR_API iqr_retval iqr_ChaCha20Encrypt | ( | const uint8_t * | key, |
size_t | key_size, | ||
const uint8_t * | nonce, | ||
size_t | nonce_size, | ||
uint32_t | counter, | ||
const uint8_t * | plaintext, | ||
size_t | plaintext_size, | ||
uint8_t * | ciphertext, | ||
size_t | ciphertext_size | ||
) |
Encrypt a plaintext message using the ChaCha20 stream cipher, standardized in RFC-7539.
ChaCha20 is its own inverse so a second application of the encryption function with identical key, counter, and nonce is equivalent to calling the decryption function.
The plaintext and ciphertext buffers cannot overlap except if they are pointers to the same location with the same size. IQR_EPTROVERLAP
will be returned if the buffers overlap and/or have different sizes.
[in] | key | A buffer containing 256 bits of keying material. |
[in] | key_size | Size of the key buffer in bytes. This value must always be equal to IQR_CHACHA20_KEY_SIZE . |
[in] | nonce | A buffer containing a 96-bit nonce. |
[in] | nonce_size | Size of the nonce buffer in bytes. This value must always be equal to IQR_CHACHA20_NONCE_SIZE . |
[in] | counter | Initial block counter value. |
[in] | plaintext | A buffer containing the plaintext message to be encrypted. |
[in] | plaintext_size | The size of plaintext in bytes. |
[out] | ciphertext | The buffer to which the encrypted message will be written. |
[in] | ciphertext_size | The size of ciphertext in bytes. This must be greater than or equal to plaintext_size. |
IQR_OK
on success, or a value from iqr_retval.h when an error occurs. ISARA Quantum Resistant Toolkit external interface for the ChaCha20 stream cipher.
ChaCha20 is a refinement of the Salsa20 stream cipher. It uses 256 bits of keying material, a 32-bit counter, and a 96-bit nonce to encrypt an arbitrary length plaintext. The output ciphertext is the same length as the plaintext.
The specification for ChaCha20 can be found in RFC-7539.