Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
11 namespace Botan {
12
13 namespace PKCS11 {
14
15 PKCS11_RNG::PKCS11_RNG(Session& session)
16 : m_session(session)
17 {}
18
19 void PKCS11_RNG::randomize(uint8_t output[], std::size_t length)
20 {
21 module()->C_GenerateRandom(m_session.get().handle(), output, length);
22 }
23
24 void PKCS11_RNG::add_entropy(const uint8_t in[], std::size_t length)
25 {
26 module()->C_SeedRandom(m_session.get().handle(), const_cast<uint8_t*>(in), length);
27 }
28
29 }
30 }
31
Botan::PKCS11::PKCS11_RNG::module
Module & module() const
Definition: p11_randomgenerator.h:52
Botan::PKCS11::LowLevel::C_GenerateRandom
bool C_GenerateRandom(SessionHandle session, Byte *random_data_ptr, Ulong random_len, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:742
Botan::PKCS11::PKCS11_RNG::add_entropy
void add_entropy(const uint8_t in[], std::size_t length) override
Calls C_SeedRandom to add entropy to the random generation function of the token/middleware.
Definition: p11_randomgenerator.cpp:24
Botan::PKCS11::PKCS11_RNG::randomize
void randomize(uint8_t output[], std::size_t length) override
Calls C_GenerateRandom to generate random data.
Definition: p11_randomgenerator.cpp:19
Botan
Definition: alg_id.cpp:13
Botan::PKCS11::LowLevel::C_SeedRandom
bool C_SeedRandom(SessionHandle session, Byte *seed_ptr, Ulong seed_len, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:734
Botan::PKCS11::PKCS11_RNG::PKCS11_RNG
PKCS11_RNG(Session &session)
Initialize the RNG with the PKCS#11 session that provides access to the cryptoki functions.
Definition: p11_randomgenerator.cpp:15
Botan::PKCS11::Session
Represents a PKCS#11 session.
Definition: p11_session.h:22