aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/prov/pkcs11/p11_randomgenerator.cpp
blob: eaf9933c6d00a3c653a732edad75d007a5adac32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* PKCS#11 Random Generator
* (C) 2016 Daniel Neus, Sirrix AG
* (C) 2016 Philipp Weber, Sirrix AG
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include <botan/p11_randomgenerator.h>

namespace Botan {

namespace PKCS11 {

PKCS11_RNG::PKCS11_RNG(Session& session)
   : m_session(session)
   {}

void PKCS11_RNG::randomize(Botan::byte output[], std::size_t length)
   {
   module()->C_GenerateRandom(m_session.get().handle(), output, length);
   }

void PKCS11_RNG::add_entropy(const Botan::byte in[], std::size_t length)
   {
   module()->C_SeedRandom(m_session.get().handle(), const_cast<Botan::byte*>(in), length);
   }

}
}