Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

darwin_secrandom.cpp
Go to the documentation of this file.
1 /*
2 * Darwin SecRandomCopyBytes EntropySource
3 * (C) 2015 Daniel Seither (Kullo GmbH)
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #include <botan/internal/darwin_secrandom.h>
9 #include <Security/Security.h>
10 #include <Security/SecRandom.h>
11
12 namespace Botan {
13
14 /**
15 * Gather entropy from SecRandomCopyBytes
16 */
17 size_t Darwin_SecRandom::poll(RandomNumberGenerator& rng)
18 {
19 secure_vector<uint8_t> buf(BOTAN_SYSTEM_RNG_POLL_REQUEST);
20
21 if(0 == SecRandomCopyBytes(kSecRandomDefault, buf.size(), buf.data()))
22 {
23 rng.add_entropy(buf.data(), buf.size());
24 return buf.size() * 8;
25 }
26
27 return 0;
28 }
29
30 }
Botan::RandomNumberGenerator::add_entropy
virtual void add_entropy(const uint8_t input[], size_t length)=0
Botan::RandomNumberGenerator
Definition: rng.h:25
Botan::Darwin_SecRandom::poll
size_t poll(RandomNumberGenerator &rng) override
Definition: darwin_secrandom.cpp:17
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan
Definition: alg_id.cpp:13