all repos — TinyCrypT @ 95faecf39b87b4d6d12e0a8b53c50192046edc6f

Short and sweet classical cryptographic primitives

tinycrypt/chacha20_poly1305.h (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
#ifndef TNT_CC20_P1305_H
#define TNT_CC20_P1305_H

#include <stdbool.h>
#include <stdint.h>

/// Implements the AEAD-ChaCha20-Poly1305 encryption and MAC algorithm defined
/// in RFC 8439
void tct_aead_chacha20_poly1305_encrypt (
    const uint8_t *aad, const uint64_t aad_len, const uint8_t *key,
    const uint8_t *nonce, const uint8_t *plaintext,
    const uint64_t plaintext_len, uint8_t *cipher_out, uint8_t *mac_out);

/// Decrypts and verifies an AEAD-ChaCha20-Poly1305 frame
bool tct_aead_chacha20_poly1305_decrypt_and_verify (
    const uint8_t *aad, const uint64_t aad_len, const uint8_t *key,
    const uint8_t *nonce, const uint8_t *frame, const uint64_t ciphertext_len,
    uint8_t *plaintext_out);

#endif