mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Add --protect-ids to obscure information in objects, bug1521.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <cstdarg>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <memory>
|
||||
#include <sys/stat.h>
|
||||
@@ -218,6 +219,18 @@ vluint64_t V3Os::rand64(vluint64_t* statep) {
|
||||
return result;
|
||||
}
|
||||
|
||||
string V3Os::trueRandom(size_t size) {
|
||||
string data; data.reserve(size);
|
||||
std::ifstream is ("/dev/urandom", std::ios::in | std::ios::binary);
|
||||
char bytes[size];
|
||||
if (!is.read(bytes, size)) {
|
||||
v3fatal("Could not open /dev/urandom, no source of randomness. Try specifing a key instead.");
|
||||
return "";
|
||||
}
|
||||
data.append(bytes, size);
|
||||
return data;
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
// METHODS (performance)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user