/* * XOF based on AES-256/CTR for CRYSTALS Kyber/Dilithium 90s-modes * (C) 2023 Jack Lloyd * 2023 René Meusel - Rohde & Schwarz Cybersecurity * * Botan is released under the Simplified BSD License (see license.txt) */ #ifndef BOTAN_AES_CRYSTALS_XOF_H_ #define BOTAN_AES_CRYSTALS_XOF_H_ #include #include namespace Botan { class StreamCipher; /** * XOF implementation for Kyber/Dilithium 90s-modes based on * AES-256 in counter mode. * * This is an internal class that is not meant for consumption * by library users. It is therefore not registered in XOF::create(). */ class BOTAN_TEST_API AES_256_CTR_XOF final : public XOF /* NOLINT(*-special-member-functions) */ { public: AES_256_CTR_XOF(); ~AES_256_CTR_XOF() override; void reset() override; std::string name() const override { return "CTR-BE(AES-256)"; } /** * Checks that the given @p iv_length is compatible with this XOF */ bool valid_salt_length(size_t iv_length) const override; Key_Length_Specification key_spec() const override; size_t block_size() const override { return 16; } std::unique_ptr copy_state() const override; std::unique_ptr new_object() const override { return std::make_unique(); } bool accepts_input() const override { return false; } private: /** * Sets the @p IV and @p key of the underlying AES-256/CTR object. * Do not call AES_256_CTR_XOF::update(), on this object! */ void start_msg(std::span iv = {}, std::span key = {}) override; /** * @throws Not_Implemented, use XOF::start() instead of XOF::update() */ void add_data(std::span input) override; void generate_bytes(std::span output) override; private: std::unique_ptr m_stream_cipher; }; } // namespace Botan #endif