ecc: Fix ECDH of Curve25519.
authorNIIBE Yutaka <gniibe@fsij.org>
Tue, 2 Feb 2016 04:58:48 +0000 (13:58 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Tue, 2 Feb 2016 04:58:48 +0000 (13:58 +0900)
commita2f9afcd7fcdafd5951498b07f34957f9766dce9
treea9881b14d01cd7165f3f2826e6e0bb9b13d84a70
parent57b60bb1718b4f2c2500bb447ebd1d4562a5aa9b
ecc: Fix ECDH of Curve25519.

* cipher/ecc-misc.c (_gcry_ecc_mont_decodepoint): Fix calc of NBITS
and prefix detection.
* cipher/ecc.c (ecc_generate): Use NBITS instead of CTX->NBITS.
(ecc_encrypt_raw): Use NBITS from curve instead of from P.
Fix rawmpilen calculation.
(ecc_decrypt_raw): Likewise.  Add debug output.
--

This fixes the commit dd3d06e7.  NBITS is defined 256 in ecc-curves.c,
thus, ecc_get_nbits returns 256.  But CTX->NBITS has 255 for Montgomery
curve.
cipher/ecc-misc.c
cipher/ecc.c