SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration

Detailed Description

CHACHA20.

Data Structures

struct  SharkSslChaChaCtx
 CHACHA20. More...
 

Functions

SHARKSSL_API SHARKSSL_CHACHA_API_STATUS SharkSslChaChaCtx_constructor (SharkSslChaChaCtx *ctx, const U8 *key, U8 keyLen)
 Initialize. More...
 
SHARKSSL_API SHARKSSL_CHACHA_API_STATUS SharkSslChaChaCtx_setIV (SharkSslChaChaCtx *ctx, const U8 IV[12])
 Initialize. More...
 
SHARKSSL_API SHARKSSL_CHACHA_API_STATUS SharkSslChaChaCtx_crypt (SharkSslChaChaCtx *ctx, const U8 *input, U8 *output, U32 len)
 Encrypt or decrypt. More...
 

Function Documentation

◆ SharkSslChaChaCtx_constructor()

SHARKSSL_CHACHA_API_STATUS SharkSslChaChaCtx_constructor ( SharkSslChaChaCtx *  ctx,
const U8 *  key,
U8  keyLen 
)

Initialize.

Use caller-owned context storage.

Parameters
ctxUninitialized data of size sizeof(SharkSslChaChaCtx)
key16- or 32-byte key; the PSA consumer profile requires 32 bytes
keyLenthe key length in bytes (32 in the PSA consumer profile)

The PSA implementation owns an imported key; call its destructor before reusing that storage.

Returns
Native build: void, with no return value. With SHARKSSL_PSA_CONSUMER_STANDALONE_CHACHA20=1: int, 0 on success and -1 on an argument/state/provider failure.

◆ SharkSslChaChaCtx_crypt()

SHARKSSL_CHACHA_API_STATUS SharkSslChaChaCtx_crypt ( SharkSslChaChaCtx *  ctx,
const U8 *  input,
U8 *  output,
U32  len 
)

Encrypt or decrypt.

This stream cipher alone does not authenticate messages.

Use an authenticated construction when integrity is required.

Parameters
ctxSharkSslChaChaCtx *; required context with its key and IV initialized.
inputconst U8 *; input bytes, required when len is nonzero.
outputU8 *; output buffer of at least len bytes; exact in-place operation is supported.
lenU32; byte count. For continuous processing across calls, use multiples of 64 except for the final call: unused bytes from a partial block are discarded.
Returns
Native build: void, with no return value. With SHARKSSL_PSA_CONSUMER_STANDALONE_CHACHA20=1: int, 0 on success and -1 on an argument/state/provider failure.

◆ SharkSslChaChaCtx_setIV()

SHARKSSL_CHACHA_API_STATUS SharkSslChaChaCtx_setIV ( SharkSslChaChaCtx *  ctx,
const U8  IV[12] 
)

Initialize.

Sets a new 12-byte nonce and resets the stream position.

Parameters
ctxInitialized data of size sizeof(SharkSslChaChaCtx)
IV12-byte initialization vector (per RFC 7905)

Never reuse a key/nonce pair to encrypt different messages.

Returns
Native build: void, with no return value. With SHARKSSL_PSA_CONSUMER_STANDALONE_CHACHA20=1: int, 0 on success and -1 on an argument/state/provider failure.