| 71 | } |
| 72 | |
| 73 | void BIP324Cipher::Encrypt(std::span<const std::byte> contents, std::span<const std::byte> aad, bool ignore, std::span<std::byte> output) noexcept |
| 74 | { |
| 75 | assert(output.size() == contents.size() + EXPANSION); |
| 76 | |
| 77 | // Encrypt length. |
| 78 | std::byte len[LENGTH_LEN]; |
| 79 | len[0] = std::byte{(uint8_t)(contents.size() & 0xFF)}; |
| 80 | len[1] = std::byte{(uint8_t)((contents.size() >> 8) & 0xFF)}; |
| 81 | len[2] = std::byte{(uint8_t)((contents.size() >> 16) & 0xFF)}; |
| 82 | m_send_l_cipher->Crypt(len, output.first(LENGTH_LEN)); |
| 83 | |
| 84 | // Encrypt plaintext. |
| 85 | std::byte header[HEADER_LEN] = {ignore ? IGNORE_BIT : std::byte{0}}; |
| 86 | m_send_p_cipher->Encrypt(header, contents, aad, output.subspan(LENGTH_LEN)); |
| 87 | } |
| 88 | |
| 89 | uint32_t BIP324Cipher::DecryptLength(std::span<const std::byte> input) noexcept |
| 90 | { |
no test coverage detected