Botan 3.13.0
Crypto and TLS for C&
jitter_rng.h
Go to the documentation of this file.
1/*
2* CPU Jitter Random Number Generator
3* (C) 2024 Planck Security S.A.
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_JITTER_RNG_H_
9#define BOTAN_JITTER_RNG_H_
10
11#include <botan/rng.h>
12#include <memory>
13#include <string>
14
15namespace Botan {
16
17class Jitter_RNG_Internal;
18
19/**
20* RNG using libjitterentropy (https://github.com/smuellerDD/jitterentropy-library)
21*/
23 public:
24 /**
25 * Create a Jitter_RNG, throwing if libjitterentropy cannot be initialized
26 */
27 Jitter_RNG();
28 ~Jitter_RNG() override;
29
30 Jitter_RNG(const Jitter_RNG& other) = delete;
31 /**
32 * Move constructor
33 */
34 Jitter_RNG(Jitter_RNG&& other) = default;
35 Jitter_RNG& operator=(const Jitter_RNG& other) = delete;
36 Jitter_RNG& operator=(Jitter_RNG&& other) = delete;
37
38 /**
39 * Return the name of this RNG type
40 * @return the name of this RNG type
41 */
42 std::string name() const override { return "JitterRNG"; }
43
44 /**
45 * Test whether this RNG has been seeded
46 * @return true if this RNG is seeded and ready for use
47 */
48 bool is_seeded() const override { return true; }
49
50 /**
51 * Test whether this RNG accepts externally provided input
52 * @return false if this RNG is known to ignore provided inputs
53 */
54 bool accepts_input() const override { return false; }
55
56 /**
57 * Clear all internally held values of this RNG
58 */
59 void clear() override;
60
61 private:
62 void fill_bytes_with_input(std::span<uint8_t> out, std::span<const uint8_t> in) override;
63
64 std::unique_ptr<Jitter_RNG_Internal> m_jitter;
65};
66
67} // namespace Botan
68
69#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
std::string name() const override
Definition jitter_rng.h:42
Jitter_RNG & operator=(const Jitter_RNG &other)=delete
Jitter_RNG(Jitter_RNG &&other)=default
bool is_seeded() const override
Definition jitter_rng.h:48
~Jitter_RNG() override
bool accepts_input() const override
Definition jitter_rng.h:54
Jitter_RNG(const Jitter_RNG &other)=delete
Jitter_RNG & operator=(Jitter_RNG &&other)=delete