MCPcopy Create free account
hub / github.com/ElementsProject/elements / ChaCha20Poly1305AEAD

Method ChaCha20Poly1305AEAD

src/crypto/chacha_poly_aead.cpp:30–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#endif // TIMINGSAFE_BCMP
29
30ChaCha20Poly1305AEAD::ChaCha20Poly1305AEAD(const unsigned char* K_1, size_t K_1_len, const unsigned char* K_2, size_t K_2_len)
31{
32 assert(K_1_len == CHACHA20_POLY1305_AEAD_KEY_LEN);
33 assert(K_2_len == CHACHA20_POLY1305_AEAD_KEY_LEN);
34
35 m_chacha_header.SetKey(K_1, CHACHA20_POLY1305_AEAD_KEY_LEN);
36 m_chacha_main.SetKey(K_2, CHACHA20_POLY1305_AEAD_KEY_LEN);
37
38 // set the cached sequence number to uint64 max which hints for an unset cache.
39 // we can't hit uint64 max since the rekey rule (which resets the sequence number) is 1GB
40 m_cached_aad_seqnr = std::numeric_limits<uint64_t>::max();
41}
42
43bool ChaCha20Poly1305AEAD::Crypt(uint64_t seqnr_payload, uint64_t seqnr_aad, int aad_pos, unsigned char* dest, size_t dest_len /* length of the output buffer for sanity checks */, const unsigned char* src, size_t src_len, bool is_encrypt)
44{

Callers

nothing calls this directly

Calls 1

SetKeyMethod · 0.45

Tested by

no test coverage detected