Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: nss/lib/freebl/ecl/ecl_mult.c

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 #include "mpi.h" 5 #include "mpi.h"
6 #include "mplogic.h" 6 #include "mplogic.h"
7 #include "ecl.h" 7 #include "ecl.h"
8 #include "ecl-priv.h" 8 #include "ecl-priv.h"
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 * Hankerson, Lopez, Menezes. Software Implementation of the NIST 122 * Hankerson, Lopez, Menezes. Software Implementation of the NIST
123 * Elliptic Curves over Prime Fields. */ 123 * Elliptic Curves over Prime Fields. */
124 mp_err 124 mp_err
125 ec_pts_mul_simul_w2(const mp_int *k1, const mp_int *k2, const mp_int *px, 125 ec_pts_mul_simul_w2(const mp_int *k1, const mp_int *k2, const mp_int *px,
126 const mp_int *py, mp_int *rx, mp_int *ry , 126 const mp_int *py, mp_int *rx, mp_int *ry ,
127 const ECGroup *group) 127 const ECGroup *group)
128 { 128 {
129 mp_err res = MP_OKAY; 129 mp_err res = MP_OKAY;
130 mp_int precomp[4][4][2]; 130 mp_int precomp[4][4][2];
131 const mp_int *a, *b; 131 const mp_int *a, *b;
132 » int i, j; 132 unsigned int i, j;
133 int ai, bi, d; 133 int ai, bi, d;
134 134
135 ARGCHK(group != NULL, MP_BADARG); 135 ARGCHK(group != NULL, MP_BADARG);
136 ARGCHK(!((k1 == NULL) 136 ARGCHK(!((k1 == NULL)
137 && ((k2 == NULL) || (px == NULL) 137 && ((k2 == NULL) || (px == NULL)
138 || (py == NULL))), MP_BADARG); 138 || (py == NULL))), MP_BADARG);
139 139
140 /* if some arguments are not defined used ECPoint_mul */ 140 /* if some arguments are not defined used ECPoint_mul */
141 if (k1 == NULL) { 141 if (k1 == NULL) {
142 return ECPoint_mul(group, k2, px, py, rx, ry); 142 return ECPoint_mul(group, k2, px, py, rx, ry);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 &precomp[i][0][0], &pre comp[i][0][1], 229 &precomp[i][0][0], &pre comp[i][0][1],
230 &precomp[i][3][0], &pre comp[i][3][1], group)); 230 &precomp[i][3][0], &pre comp[i][3][1], group));
231 } 231 }
232 232
233 d = (mpl_significant_bits(a) + 1) / 2; 233 d = (mpl_significant_bits(a) + 1) / 2;
234 234
235 /* R = inf */ 235 /* R = inf */
236 mp_zero(rx); 236 mp_zero(rx);
237 mp_zero(ry); 237 mp_zero(ry);
238 238
239 » for (i = d - 1; i >= 0; i--) { 239 for (i = d; i-- > 0;) {
240 ai = MP_GET_BIT(a, 2 * i + 1); 240 ai = MP_GET_BIT(a, 2 * i + 1);
241 ai <<= 1; 241 ai <<= 1;
242 ai |= MP_GET_BIT(a, 2 * i); 242 ai |= MP_GET_BIT(a, 2 * i);
243 bi = MP_GET_BIT(b, 2 * i + 1); 243 bi = MP_GET_BIT(b, 2 * i + 1);
244 bi <<= 1; 244 bi <<= 1;
245 bi |= MP_GET_BIT(b, 2 * i); 245 bi |= MP_GET_BIT(b, 2 * i);
246 /* R = 2^2 * R */ 246 /* R = 2^2 * R */
247 MP_CHECKOK(group->point_dbl(rx, ry, rx, ry, group)); 247 MP_CHECKOK(group->point_dbl(rx, ry, rx, ry, group));
248 MP_CHECKOK(group->point_dbl(rx, ry, rx, ry, group)); 248 MP_CHECKOK(group->point_dbl(rx, ry, rx, ry, group));
249 /* R = R + (ai * A + bi * B) */ 249 /* R = R + (ai * A + bi * B) */
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 res = group->points_mul(k1p, k2p, px, py, rx, ry, group); 313 res = group->points_mul(k1p, k2p, px, py, rx, ry, group);
314 } else { 314 } else {
315 res = ec_pts_mul_simul_w2(k1p, k2p, px, py, rx, ry, group); 315 res = ec_pts_mul_simul_w2(k1p, k2p, px, py, rx, ry, group);
316 } 316 }
317 317
318 CLEANUP: 318 CLEANUP:
319 mp_clear(&k1t); 319 mp_clear(&k1t);
320 mp_clear(&k2t); 320 mp_clear(&k2t);
321 return res; 321 return res;
322 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698