cfb8: Fix decrypt path
[gd/nettle] / ecc-224.c
1 /* ecc-224.c
2
3    Compile time constant (but machine dependent) tables.
4
5    Copyright (C) 2013, 2014 Niels Möller
6
7    This file is part of GNU Nettle.
8
9    GNU Nettle is free software: you can redistribute it and/or
10    modify it under the terms of either:
11
12      * the GNU Lesser General Public License as published by the Free
13        Software Foundation; either version 3 of the License, or (at your
14        option) any later version.
15
16    or
17
18      * the GNU General Public License as published by the Free
19        Software Foundation; either version 2 of the License, or (at your
20        option) any later version.
21
22    or both in parallel, as here.
23
24    GNU Nettle is distributed in the hope that it will be useful,
25    but WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27    General Public License for more details.
28
29    You should have received copies of the GNU General Public License and
30    the GNU Lesser General Public License along with this program.  If
31    not, see http://www.gnu.org/licenses/.
32 */
33
34 /* Development of Nettle's ECC support was funded by the .SE Internet Fund. */
35
36 #if HAVE_CONFIG_H
37 # include "config.h"
38 #endif
39
40 #include "ecc.h"
41 #include "ecc-internal.h"
42
43 #if HAVE_NATIVE_ecc_224_modp
44
45 #define USE_REDC 0
46 #define ecc_224_modp nettle_ecc_224_modp
47 void
48 ecc_224_modp (const struct ecc_modulo *m, mp_limb_t *rp);
49
50 #else
51 #define USE_REDC (ECC_REDC_SIZE != 0)
52 #define ecc_224_modp ecc_mod
53 #endif
54
55 #include "ecc-224.h"
56
57 #if ECC_REDC_SIZE < 0
58 # define ecc_224_redc ecc_pm1_redc
59 #elif ECC_REDC_SIZE == 0
60 # define ecc_224_redc NULL
61 #else
62 # error Configuration error
63 #endif
64
65 const struct ecc_curve _nettle_secp_224r1 =
66 {
67   {
68     224,
69     ECC_LIMB_SIZE,    
70     ECC_BMODP_SIZE,
71     -ECC_REDC_SIZE,
72     ECC_MOD_INV_ITCH (ECC_LIMB_SIZE),
73     0,
74
75     ecc_p,
76     ecc_Bmodp,
77     ecc_Bmodp_shifted,
78     ecc_redc_ppm1,
79     ecc_pp1h,
80
81     ecc_224_modp,
82     USE_REDC ? ecc_224_redc : ecc_224_modp,
83     ecc_mod_inv,
84     NULL,
85   },
86   {
87     224,
88     ECC_LIMB_SIZE,    
89     ECC_BMODQ_SIZE,
90     0,
91     ECC_MOD_INV_ITCH (ECC_LIMB_SIZE),
92     0,
93
94     ecc_q,
95     ecc_Bmodq,
96     ecc_Bmodq_shifted,
97     NULL,
98     ecc_qp1h,
99
100     ecc_mod,
101     ecc_mod,
102     ecc_mod_inv,
103     NULL,
104   },
105   
106   USE_REDC,
107   ECC_PIPPENGER_K,
108   ECC_PIPPENGER_C,
109
110   ECC_ADD_JJJ_ITCH (ECC_LIMB_SIZE),
111   ECC_MUL_A_ITCH (ECC_LIMB_SIZE),
112   ECC_MUL_G_ITCH (ECC_LIMB_SIZE),
113   ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
114
115   ecc_add_jjj,
116   ecc_mul_a,
117   ecc_mul_g,
118   ecc_j_to_a,
119
120   ecc_b,
121   ecc_g,
122   NULL,
123   ecc_unit,
124   ecc_table
125 };
126
127 const struct ecc_curve *nettle_get_secp_224r1(void)
128 {
129   return &_nettle_secp_224r1;
130 }