| 67 | } // namespace |
| 68 | |
| 69 | void 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 | |
| 83 | bool 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 | { |
nothing calls this directly
no test coverage detected