esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
urandom.hpp
Go to the documentation of this file.
1#ifndef NDNPH_PORT_RANDOM_URANDOM_HPP
2#define NDNPH_PORT_RANDOM_URANDOM_HPP
3
4#include "../../core/common.hpp"
5
6namespace ndnph {
7namespace port_random_urandom {
8
11public:
12 RandomSource() = delete;
13
18 static bool generate(uint8_t* output, size_t count) {
19 static FILE* fd = std::fopen("/dev/urandom", "r");
20 return fd != nullptr && std::fread(output, 1, count, fd) == count;
21 }
22};
23
24} // namespace port_random_urandom
25
26#ifdef NDNPH_PORT_RANDOM_URANDOM
27namespace port {
28using RandomSource = port_random_urandom::RandomSource;
29} // namespace port
30#endif
31
32} // namespace ndnph
33
34#endif // NDNPH_PORT_RANDOM_URANDOM_HPP
Generate random bytes by reading from urandom device.
Definition urandom.hpp:10
static bool generate(uint8_t *output, size_t count)
Fill output[0:count] with random bytes.
Definition urandom.hpp:18
esp8266ndn::ndnph_port::RandomSource RandomSource
Definition random.hpp:28
Definition fs.hpp:33