From d7b819267fccc817ff0005790aed04f75162f1f4 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 10 Dec 2019 10:53:39 -0500 Subject: [PATCH] check a for 0 in Legendre --- libi2pd/Elligator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libi2pd/Elligator.cpp b/libi2pd/Elligator.cpp index 07711ae0..febece03 100644 --- a/libi2pd/Elligator.cpp +++ b/libi2pd/Elligator.cpp @@ -160,7 +160,8 @@ namespace crypto int Elligator2::Legendre (const BIGNUM * a, BN_CTX * ctx) const { - // assume a < p, so don't check for a % p = 0 + // assume a < p, so don't check for a % p = 0, but a = 0 only + if (BN_is_zero(a)) return 0; BIGNUM * r = BN_CTX_get (ctx); BN_mod_exp (r, a, p12, p, ctx); // r = a^((p-1)/2) mod p if (BN_is_word(r, 1))