aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-05-29 04:42:25 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-05-29 04:55:18 +0800
commit8d0b526c881878f72a542181d6f53a7ee8e07a5e (patch)
tree0f6f645f60e57a93e981a3aafde544b54b0b5372
parent4914d4ce293508c0224c0f62eb1c0efad492f75a (diff)
downloadtangerine-mcl-8d0b526c881878f72a542181d6f53a7ee8e07a5e.tar.gz
tangerine-mcl-8d0b526c881878f72a542181d6f53a7ee8e07a5e.tar.zst
tangerine-mcl-8d0b526c881878f72a542181d6f53a7ee8e07a5e.zip
NoRandomGenerator is removed
-rw-r--r--include/mcl/randgen.hpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/include/mcl/randgen.hpp b/include/mcl/randgen.hpp
index bd1aaca..3c4a442 100644
--- a/include/mcl/randgen.hpp
+++ b/include/mcl/randgen.hpp
@@ -7,16 +7,8 @@
http://opensource.org/licenses/BSD-3-Clause
*/
#ifdef MCL_DONT_USE_RANDOM
-#include <stdlib.h>
-namespace mcl {
-struct NoRandomGenerator {
- void read(void *, size_t)
- {
- exit(1);
- }
-};
-} // mcl
+// nothing
#elif defined(MCL_USE_WEB_CRYPTO_API)
#include <emscripten.h>
@@ -99,17 +91,22 @@ public:
{
readFunc_(self_, out, static_cast<uint32_t>(byteSize));
}
+#ifdef MCL_DONT_USE_RANDOM
+ bool isZero() const { return false; }
+#else
bool isZero() const { return self_ == 0 && readFunc_ == 0; }
+#endif
static RandGen& get()
{
#ifdef MCL_DONT_USE_RANDOM
- static mcl::NoRandomGenerator rg;
+ static RandGen wrg;
#elif defined(MCL_USE_WEB_CRYPTO_API)
static mcl::RandomGeneratorJS rg;
+ static RandGen wrg(rg);
#else
static cybozu::RandomGenerator rg;
-#endif
static RandGen wrg(rg);
+#endif
return wrg;
}
/*