Botan 3.6.1
Crypto and TLS for C&
aes_crystals_xof.h
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#ifndef BOTAN_AES_CRYSTALS_XOF_H_
10#define BOTAN_AES_CRYSTALS_XOF_H_
11
12#include <botan/secmem.h>
13#include <botan/xof.h>
14
15namespace Botan {
16
17class StreamCipher;
18
19/**
20 * XOF implementation for Kyber/Dilithium 90s-modes based on
21 * AES-256 in counter mode.
22 *
23 * This is an internal class that is not meant for consumption
24 * by library users. It is therefore not registered in XOF::create().
25 */
27 public:
29 ~AES_256_CTR_XOF() override;
30
31 void reset() override;
32
33 std::string name() const override { return "CTR-BE(AES-256)"; }
34
35 /**
36 * Checks that the given @p iv_length is compatible with this XOF
37 */
38 bool valid_salt_length(size_t iv_length) const override;
39 Key_Length_Specification key_spec() const override;
40
41 size_t block_size() const override { return 16; }
42
43 std::unique_ptr<XOF> copy_state() const override;
44
45 std::unique_ptr<XOF> new_object() const override { return std::make_unique<AES_256_CTR_XOF>(); }
46
47 bool accepts_input() const override { return false; }
48
49 private:
50 /**
51 * Sets the @p IV and @p key of the underlying AES-256/CTR object.
52 * Do not call AES_256_CTR_XOF::update(), on this object!
53 */
54 void start_msg(std::span<const uint8_t> iv = {}, std::span<const uint8_t> key = {}) override;
55
56 /**
57 * @throws Not_Implemented, use XOF::start() instead of XOF::update()
58 */
59 void add_data(std::span<const uint8_t>) override;
60
61 void generate_bytes(std::span<uint8_t> output) override;
62
63 private:
64 std::unique_ptr<StreamCipher> m_stream_cipher;
65};
66
67} // namespace Botan
68
69#endif
std::unique_ptr< XOF > new_object() const override
~AES_256_CTR_XOF() override
std::string name() const override
bool accepts_input() const override
size_t block_size() const override
int(* final)(unsigned char *, CTX *)
#define BOTAN_TEST_API
Definition compiler.h:51