OEMCrypto v16.1 -- update ODK
This CL updates the ODK library to address review comments.
This commit is contained in:
@@ -14,9 +14,18 @@ namespace wvcdm {
|
||||
// It's purpose is to simplified interface for C++11's <random> library.
|
||||
// Some of the methods use a "device specific" random seed, if the
|
||||
// compiler/device does not support device specific randomizers, then the
|
||||
// actual value supplied may not be random.
|
||||
// actual value supplied may not be random. The generator is designed to
|
||||
// meet the C++ named requirement UniformRandomBitGenerator to allow it to
|
||||
// be used with standard library functions / class which are designed to
|
||||
// work with the standard library generators.
|
||||
class CdmRandomGenerator {
|
||||
public:
|
||||
// Result type of operator().
|
||||
using result_type = unsigned int;
|
||||
// Inclusive boundaries of operator().
|
||||
static constexpr unsigned int min() { return 0; }
|
||||
static constexpr unsigned int max() { return RAND_MAX; }
|
||||
|
||||
// The maximum number of bytes that can be generated at once for
|
||||
// `RandomData()`.
|
||||
static constexpr size_t kMaxRandomDataLength = 8192; // 8 kB
|
||||
@@ -44,12 +53,11 @@ class CdmRandomGenerator {
|
||||
|
||||
// Returns a pseudo-random integer.
|
||||
// This is similar to `rand()` from the C standard library. The integer
|
||||
// returned is in the range of [0, RAND_MAX].
|
||||
int Rand();
|
||||
// returned is in the range of [min(), max()].
|
||||
unsigned int Rand();
|
||||
|
||||
// Allows for RNG to be callable, this is to make it similar to the
|
||||
// C++11 generator interfaces.
|
||||
int operator()() { return Rand(); }
|
||||
// Allows for RNG to be callable.
|
||||
unsigned int operator()() { return Rand(); }
|
||||
|
||||
// Returns a pseudo-random integer within the provided inclusive range.
|
||||
uint64_t RandomInRange(uint64_t lower, uint64_t upper);
|
||||
@@ -79,7 +87,7 @@ class CdmRandomGenerator {
|
||||
// CdmRandomGenerator.
|
||||
class CdmRandom {
|
||||
public:
|
||||
static int Rand() { return GetInstance()->Rand(); }
|
||||
static unsigned int Rand() { return GetInstance()->Rand(); }
|
||||
static uint64_t RandomInRange(uint64_t lower, uint64_t upper) {
|
||||
return GetInstance()->RandomInRange(lower, upper);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user