add assert for setByCSPRNG

dev
MITSUNARI Shigeo 7 years ago
parent df468426c4
commit 4f9e9f00ce
  1. 2
      readme.md
  2. 1
      src/fp.cpp

@ -2,7 +2,7 @@
# mcl
A generic and fast pairing-based cryptography library.
A portable and fast pairing-based cryptography library.
# Abstract

@ -201,6 +201,7 @@ void getRandVal(Unit *out, RandGen& rg, const Unit *in, size_t bitSize)
if (rg.isZero()) rg = RandGen::get();
const size_t n = (bitSize + UnitBitSize - 1) / UnitBitSize;
const size_t rem = bitSize & (UnitBitSize - 1);
assert(n > 0);
for (;;) {
rg.read(out, n * sizeof(Unit));
if (rem > 0) out[n - 1] &= (Unit(1) << rem) - 1;

Loading…
Cancel
Save