From: Rohan McLure Date: Fri, 25 Nov 2022 03:42:12 +0000 (+1100) Subject: Fix accumulated index comments in felem_inv for p521 X-Git-Tag: openssl-3.2.0-alpha1~1658 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=055d029610712a281aed0c23ddd3c8f4dbf40f80;p=thirdparty%2Fopenssl.git Fix accumulated index comments in felem_inv for p521 Comments in felem_inv refer to the logarithm with respect to in of the element that has just been computed. The last two such annotations are incorrect. By Fermat's last theorem, we hope to compute in^(p-2) in GF(2^521-1), as such we expect the final index we reach to be 2^521-3. CLA: Trivial Reviewed-by: Hugo Landau Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/19765) --- diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index 484c42eac9e..cc2243a8b33 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -843,9 +843,9 @@ static void felem_inv(felem out, const felem in) felem_reduce(ftmp3, tmp); /* 2^521 - 2^9 */ } felem_mul(tmp, ftmp3, ftmp4); - felem_reduce(ftmp3, tmp); /* 2^512 - 2^2 */ + felem_reduce(ftmp3, tmp); /* 2^521 - 2^2 */ felem_mul(tmp, ftmp3, in); - felem_reduce(out, tmp); /* 2^512 - 3 */ + felem_reduce(out, tmp); /* 2^521 - 3 */ } /* This is 2^521-1, expressed as an felem */