Botan 3.6.1
Crypto and TLS for C&
p11_randomgenerator.cpp
Go to the documentation of this file.
1/*
2* PKCS#11 Random Generator
3* (C) 2016 Daniel Neus, Sirrix AG
4* (C) 2016 Philipp Weber, Sirrix AG
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/p11_randomgenerator.h>
10
11namespace Botan::PKCS11 {
12
13PKCS11_RNG::PKCS11_RNG(Session& session) : m_session(session) {}
14
15void PKCS11_RNG::fill_bytes_with_input(std::span<uint8_t> output, std::span<const uint8_t> input) {
16 if(!input.empty()) {
17 module()->C_SeedRandom(m_session.get().handle(), const_cast<uint8_t*>(input.data()), Ulong(input.size()));
18 }
19
20 if(!output.empty()) {
21 module()->C_GenerateRandom(m_session.get().handle(), output.data(), Ulong(output.size()));
22 }
23}
24
25} // namespace Botan::PKCS11
bool C_GenerateRandom(SessionHandle session, Byte *random_data_ptr, Ulong random_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:657
bool C_SeedRandom(SessionHandle session, const Byte *seed_ptr, Ulong seed_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:649
PKCS11_RNG(Session &session)
Initialize the RNG with the PKCS#11 session that provides access to the cryptoki functions.
Represents a PKCS#11 session.
Definition p11_types.h:121
CK_ULONG Ulong
Definition p11.h:816