MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Encrypt

Method Encrypt

src/crypto/chacha20poly1305.cpp:69–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67} // namespace
68
69void AEADChaCha20Poly1305::Encrypt(std::span<const std::byte> plain1, std::span<const std::byte> plain2, std::span<const std::byte> aad, Nonce96 nonce, std::span<std::byte> cipher) noexcept
70{
71 assert(cipher.size() == plain1.size() + plain2.size() + EXPANSION);
72
73 // Encrypt using ChaCha20 (starting at block 1).
74 m_chacha20.Seek(nonce, 1);
75 m_chacha20.Crypt(plain1, cipher.first(plain1.size()));
76 m_chacha20.Crypt(plain2, cipher.subspan(plain1.size()).first(plain2.size()));
77
78 // Seek to block 0, and compute tag using key drawn from there.
79 m_chacha20.Seek(nonce, 0);
80 ComputeTag(m_chacha20, aad, cipher.first(cipher.size() - EXPANSION), cipher.last(EXPANSION));
81}
82
83bool AEADChaCha20Poly1305::Decrypt(std::span<const std::byte> cipher, std::span<const std::byte> aad, Nonce96 nonce, std::span<std::byte> plain1, std::span<std::byte> plain2) noexcept
84{

Callers

nothing calls this directly

Calls 4

ComputeTagFunction · 0.85
CryptMethod · 0.80
sizeMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected