|
|
@ -387,25 +387,24 @@ bool Op::init(const mpz_class& _p, size_t maxBitSize, int _xi_a, Mode mode, size |
|
|
|
|
|
|
|
|
|
|
|
#if defined(MCL_USE_LLVM) || defined(MCL_USE_XBYAK) |
|
|
|
#if defined(MCL_USE_LLVM) || defined(MCL_USE_XBYAK) |
|
|
|
if (mode == FP_AUTO || mode == FP_LLVM || mode == FP_XBYAK) { |
|
|
|
if (mode == FP_AUTO || mode == FP_LLVM || mode == FP_XBYAK) { |
|
|
|
const char *pStr = "0xfffffffffffffffffffffffffffffffeffffffffffffffff"; |
|
|
|
const struct { |
|
|
|
bool b; |
|
|
|
PrimeMode mode; |
|
|
|
mpz_class p192; |
|
|
|
const char *str; |
|
|
|
gmp::setStr(&b, p192, pStr); |
|
|
|
} tbl[] = { |
|
|
|
if (b && mp == p192) { |
|
|
|
{ PM_NIST_P192, "0xfffffffffffffffffffffffffffffffeffffffffffffffff" }, |
|
|
|
primeMode = PM_NIST_P192; |
|
|
|
{ PM_NIST_P521, "0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, |
|
|
|
isMont = false; |
|
|
|
}; |
|
|
|
isFastMod = true; |
|
|
|
// user fastMode for special primes
|
|
|
|
} |
|
|
|
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) { |
|
|
|
} |
|
|
|
bool b; |
|
|
|
if (mode == FP_AUTO || mode == FP_LLVM || mode == FP_XBYAK) { |
|
|
|
mpz_class target; |
|
|
|
const char *pStr = "0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; |
|
|
|
gmp::setStr(&b, target, tbl[i].str); |
|
|
|
bool b; |
|
|
|
if (b && mp == target) { |
|
|
|
mpz_class p521; |
|
|
|
primeMode = tbl[i].mode; |
|
|
|
gmp::setStr(&b, p521, pStr); |
|
|
|
isMont = false; |
|
|
|
if (b && mp == p521) { |
|
|
|
isFastMod = true; |
|
|
|
primeMode = PM_NIST_P521; |
|
|
|
break; |
|
|
|
isMont = false; |
|
|
|
} |
|
|
|
isFastMod = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|