nrfxlib API 0.1.0
Loading...
Searching...
No Matches
ChaCha20-Poly1305 incremental APIs

Type declaration and APIs for authenticated encryption and additional data using the ChaCha20-Poly1305 algorithm in incremental steps. More...

Macros

#define ocrypto_chacha20_poly1305_KEY_BYTES   (32)
 
#define ocrypto_chacha20_poly1305_NONCE_BYTES_MAX   (12)
 
#define ocrypto_chacha20_poly1305_TAG_BYTES   (16)
 

Functions

void ocrypto_chacha20_poly1305_encrypt (uint8_t tag[(16)], uint8_t *c, const uint8_t *m, size_t m_len, const uint8_t *a, size_t a_len, const uint8_t *n, size_t n_len, const uint8_t k[(32)])
 
int ocrypto_chacha20_poly1305_decrypt (const uint8_t tag[(16)], uint8_t *m, const uint8_t *c, size_t c_len, const uint8_t *a, size_t a_len, const uint8_t *n, size_t n_len, const uint8_t k[(32)])
 

Incremental ChaCha20-Poly1305 generator.

This group of functions can be used to incrementally encode and decode a message using the ChaCha20-Poly1305 stream cipher.

Use pattern:

Encoding:

ocrypto_chacha20_poly1305_init(ctx, nonce, nonce_len, key);
...
ocrypto_chacha20_poly1305_update_aad(ctx, aad, aad_len);
...
ocrypto_chacha20_poly1305_update_enc(ctx, ct, pt, pt_len);
void ocrypto_chacha20_poly1305_update_enc(ocrypto_chacha20_poly1305_ctx *ctx, uint8_t *c, const uint8_t *m, size_t m_len)
void ocrypto_chacha20_poly1305_update_aad(ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t *a, size_t a_len)
void ocrypto_chacha20_poly1305_init(ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t *n, size_t n_len, const uint8_t k[(32)])
void ocrypto_chacha20_poly1305_final_enc(ocrypto_chacha20_poly1305_ctx *ctx, uint8_t tag[(16)])

Decoding:

ocrypto_chacha20_poly1305_init(ctx, nonce, nonce_len, key);
...
ocrypto_chacha20_poly1305_update_aad(ctx, aad, aad_len);
...
ocrypto_chacha20_poly1305_update_dec(ctx, pt, ct, ct_len);
void ocrypto_chacha20_poly1305_update_dec(ocrypto_chacha20_poly1305_ctx *ctx, uint8_t *m, const uint8_t *c, size_t c_len)
int ocrypto_chacha20_poly1305_final_dec(ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t tag[(16)])
void ocrypto_chacha20_poly1305_init (ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t *n, size_t n_len, const uint8_t k[(32)])
 
void ocrypto_chacha20_poly1305_update_aad (ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t *a, size_t a_len)
 
void ocrypto_chacha20_poly1305_update_enc (ocrypto_chacha20_poly1305_ctx *ctx, uint8_t *c, const uint8_t *m, size_t m_len)
 
void ocrypto_chacha20_poly1305_update_dec (ocrypto_chacha20_poly1305_ctx *ctx, uint8_t *m, const uint8_t *c, size_t c_len)
 
void ocrypto_chacha20_poly1305_final_enc (ocrypto_chacha20_poly1305_ctx *ctx, uint8_t tag[(16)])
 
int ocrypto_chacha20_poly1305_final_dec (ocrypto_chacha20_poly1305_ctx *ctx, const uint8_t tag[(16)])
 

Detailed Description

Type declaration and APIs for authenticated encryption and additional data using the ChaCha20-Poly1305 algorithm in incremental steps.

ChaCha20-Poly1305 is an authenticated encryption algorithm with optional additional authenticated data developed by Daniel J.Bernstein.

The ChaCha20 stream cipher is combined with the Poly1305 authenticator.

See also
RFC 8439 - ChaCha20 and Poly1305 for IETF Protocols