1ffe9b79 | /* Copyright (C) CJ Affiliate * * You may use, distribute and modify this code under the * terms of the GNU General Public License version 2 or * later. * * You should have received a copy of the license with this * file. If not, you will find a copy in the "LICENSE" file * at https://github.com/cjdev/dual-control. */ #ifndef _RANDOM_SOURCE_H #define _RANDOM_SOURCE_H #include <vector> #include <string> #include <memory> #include <iostream> #include "sys_unistd.h" #include "sys_pwd.h" #include "sys_fstream.h" class random_source_ifc { |
f1b86ea0 | public: |
1a0d77af | const static std::string file_path; |
f1b86ea0 | virtual std::vector<uint8_t> get_random_bytes (int length) const { return {}; |
1ffe9b79 | } }; class random_source { |
f1b86ea0 | public: |
1ffe9b79 | using delegate = std::shared_ptr<random_source_ifc>; |
f1b86ea0 | private: |
1ffe9b79 | delegate delegate_; |
f1b86ea0 | public: |
1ffe9b79 | random_source (delegate delegate) : delegate_ (delegate) {} |
f1b86ea0 | std::vector<uint8_t> get_random_bytes (int length) const { return delegate_->get_random_bytes (length); |
1ffe9b79 | } |
f1b86ea0 | |
4a6aca25 | static random_source create (const fstreams &fstreams); |
1ffe9b79 | }; #endif |
a120158c |