nrfxlib API 2.7.99
Loading...
Searching...
No Matches
ocrypto_chacha20_poly1305.h File Reference
#include <stdint.h>
#include <stddef.h>
#include "ocrypto_chacha20.h"
#include "ocrypto_poly1305.h"

Go to the source code of this file.

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)])