diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-06-24 08:19:29 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-06-24 08:19:29 +0800 |
commit | de999563776d76ecba808ecdaffa506f129e3236 (patch) | |
tree | 90dbfef2382c270982a2db70b8270522a7d89837 | |
parent | 524aee984073eba487d86f203440c77b943b3f72 (diff) | |
download | dexon-mcl-de999563776d76ecba808ecdaffa506f129e3236.tar.gz dexon-mcl-de999563776d76ecba808ecdaffa506f129e3236.tar.zst dexon-mcl-de999563776d76ecba808ecdaffa506f129e3236.zip |
check the value of MCL_MAX_BIT_SIZE
-rw-r--r-- | include/mcl/op.hpp | 2 | ||||
-rw-r--r-- | src/fp.cpp | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index c6411a8..b2660dc 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -286,7 +286,7 @@ struct Op { */ fp_mul(y, x, R2, p); } - void init(const std::string& mstr, size_t maxBitSize, Mode mode); + void init(const std::string& mstr, size_t maxBitSize, Mode mode, size_t mclMaxBitSize = MCL_MAX_BIT_SIZE); void initFp2(int xi_a); static FpGenerator* createFpGenerator(); static void destroyFpGenerator(FpGenerator *fg); @@ -380,8 +380,11 @@ static void initForMont(Op& op, const Unit *p, Mode mode) #endif } -void Op::init(const std::string& mstr, size_t maxBitSize, Mode mode) +void Op::init(const std::string& mstr, size_t maxBitSize, Mode mode, size_t mclMaxBitSize) { + if (mclMaxBitSize != MCL_MAX_BIT_SIZE) { + throw cybozu::Exception("Op:init:mismatch between header and library of MCL_MAX_BIT_SIZE") << mclMaxBitSize << MCL_MAX_BIT_SIZE; + } assert(sizeof(mp_limb_t) == sizeof(Unit)); clear(); if (maxBitSize > MCL_MAX_BIT_SIZE) { |