Function nrfxlib_sys::ocrypto_chacha20_init
source · pub unsafe extern "C" fn ocrypto_chacha20_init(
ctx: *mut ocrypto_chacha20_ctx,
n: *const u8,
n_len: usize,
key: *const u8,
count: u32
)
Expand description
Incremental ChaCha20 Encoder.
This group of functions can be used to incrementally compute the ChaCha20 encryption for a given message and key, by segmenting a message into smaller chunks.
Use pattern:
Encoding/Decoding: @code ocrypto_chacha20_init(ctx, n, n_len, key, count); ocrypto_chacha20_update(ctx, c, m, m_len); … ocrypto_chacha20_update(ctx, c, m, m_len); @endcode / /@{*/ / ChaCha20 encoder initialization.
The generator state * ctx
- is initialized by this function.
ctx
- Encoder state.n
- Nonce. May be NULL.n_len
- Nonce length. 0 <= *n_len
- <= *ocrypto_chacha20_NONCE_BYTES_MAX
- .key
- Authentication key. May be NULL.count
- Initial block counter, usually 0 or 1.
@remark If * key
- is NULL only * n
- and * count
- are set. If * n
- is NULL only * key
- is set.
Both * key
- and * n
- must be set before update is called.
@remark When reusing an encryption key * key
- for a different message, a
different nonce * n
- or initial block counter * count
- must be used.