Botan 3.5.0
Crypto and TLS for C&
aes_crystals_xof.cpp
Go to the documentation of this file.
1/*
2 * XOF based on AES-256/CTR for CRYSTALS Kyber/Dilithium 90s-modes
3 * (C) 2023 Jack Lloyd
4 * 2023 René Meusel - Rohde & Schwarz Cybersecurity
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9#include <botan/internal/aes_crystals_xof.h>
10
11#include <botan/exceptn.h>
12#include <botan/stream_cipher.h>
13#include <botan/internal/fmt.h>
14
15namespace Botan {
16
17AES_256_CTR_XOF::AES_256_CTR_XOF() : m_stream_cipher(StreamCipher::create_or_throw(name())) {}
18
20
22 m_stream_cipher->clear();
23}
24
25void AES_256_CTR_XOF::start_msg(std::span<const uint8_t> iv, std::span<const uint8_t> key) {
26 m_stream_cipher->set_key(key);
27 m_stream_cipher->set_iv(iv);
28}
29
30bool AES_256_CTR_XOF::valid_salt_length(size_t iv_length) const {
31 return m_stream_cipher->valid_iv_length(iv_length);
32}
33
35 return m_stream_cipher->key_spec();
36}
37
38std::unique_ptr<XOF> AES_256_CTR_XOF::copy_state() const {
39 throw Not_Implemented(fmt("Copying the state of XOF {} is not implemented", name()));
40}
41
42void AES_256_CTR_XOF::add_data(std::span<const uint8_t> input) {
43 if(!input.empty()) {
44 throw Not_Implemented(fmt("XOF {} does not support data input", name()));
45 }
46}
47
48void AES_256_CTR_XOF::generate_bytes(std::span<uint8_t> output) {
49 m_stream_cipher->write_keystream(output);
50}
51
52} // namespace Botan
std::unique_ptr< XOF > copy_state() const override
Key_Length_Specification key_spec() const override
~AES_256_CTR_XOF() override
std::string name() const override
bool valid_salt_length(size_t iv_length) const override
T output(size_t bytes)
Definition xof.h:155
std::string name
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53