]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
eccdata: Emit correct ecc_Bmodq_shifted for curve448
authorDaiki Ueno <dueno@redhat.com>
Sat, 5 Aug 2017 07:43:44 +0000 (09:43 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 9 Sep 2017 19:32:34 +0000 (21:32 +0200)
In curve448, the bit size of the order is slightly smaller than the
one of p's.  Adjust ecc_Bmodq_shifted accordingly.

Signed-off-by: Daiki Ueno <dueno@redhat.com>
eccdata.c

index 9533d7835c08997d5b7e14a1117ef6cfbf76f087..9be9afb5f65566c8c299c8c7c6ba109872e11ba8 100644 (file)
--- a/eccdata.c
+++ b/eccdata.c
@@ -1014,16 +1014,19 @@ output_curve (const struct ecc_curve *ecc, unsigned bits_per_limb)
              exit (EXIT_FAILURE);
            }
        }
+    }
+  else
+    printf ("#define ecc_Bmodp_shifted ecc_Bmodp\n");
+
+  if (bits < limb_size * bits_per_limb)
+    {
       mpz_set_ui (t, 0);
-      mpz_setbit (t, ecc->bit_size);
+      mpz_setbit (t, bits);
       mpz_sub (t, t, ecc->q);      
       output_bignum ("ecc_Bmodq_shifted", t, limb_size, bits_per_limb);      
     }
   else
-    {
-      printf ("#define ecc_Bmodp_shifted ecc_Bmodp\n");
-      printf ("#define ecc_Bmodq_shifted ecc_Bmodq\n");
-    }
+    printf ("#define ecc_Bmodq_shifted ecc_Bmodq\n");
 
   mpz_add_ui (t, ecc->p, 1);
   mpz_fdiv_q_2exp (t, t, 1);