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

Side by Side Diff: nss/lib/freebl/mpi/mpmontg.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 /* This file implements moduluar exponentiation using Montgomery's 5 /* This file implements moduluar exponentiation using Montgomery's
6 * method for modular reduction. This file implements the method 6 * method for modular reduction. This file implements the method
7 * described as "Improvement 2" in the paper "A Cryptogrpahic Library for 7 * described as "Improvement 2" in the paper "A Cryptogrpahic Library for
8 * the Motorola DSP56000" by Stephen R. Dusse' and Burton S. Kaliski Jr. 8 * the Motorola DSP56000" by Stephen R. Dusse' and Burton S. Kaliski Jr.
9 * published in "Advances in Cryptology: Proceedings of EUROCRYPT '90" 9 * published in "Advances in Cryptology: Proceedings of EUROCRYPT '90"
10 * "Lecture Notes in Computer Science" volume 473, 1991, pg 230-244, 10 * "Lecture Notes in Computer Science" volume 473, 1991, pg 230-244,
(...skipping 29 matching lines...) Expand all
40 mp_err s_mp_redc(mp_int *T, mp_mont_modulus *mmm) 40 mp_err s_mp_redc(mp_int *T, mp_mont_modulus *mmm)
41 { 41 {
42 mp_err res; 42 mp_err res;
43 mp_size i; 43 mp_size i;
44 44
45 i = (MP_USED(&mmm->N) << 1) + 1; 45 i = (MP_USED(&mmm->N) << 1) + 1;
46 MP_CHECKOK( s_mp_pad(T, i) ); 46 MP_CHECKOK( s_mp_pad(T, i) );
47 for (i = 0; i < MP_USED(&mmm->N); ++i ) { 47 for (i = 0; i < MP_USED(&mmm->N); ++i ) {
48 mp_digit m_i = MP_DIGIT(T, i) * mmm->n0prime; 48 mp_digit m_i = MP_DIGIT(T, i) * mmm->n0prime;
49 /* T += N * m_i * (MP_RADIX ** i); */ 49 /* T += N * m_i * (MP_RADIX ** i); */
50 MP_CHECKOK( s_mp_mul_d_add_offset(&mmm->N, m_i, T, i) ); 50 s_mp_mul_d_add_offset(&mmm->N, m_i, T, i);
51 } 51 }
52 s_mp_clamp(T); 52 s_mp_clamp(T);
53 53
54 /* T /= R */ 54 /* T /= R */
55 s_mp_rshd( T, MP_USED(&mmm->N) ); 55 s_mp_rshd( T, MP_USED(&mmm->N) );
56 56
57 if ((res = s_mp_cmp(T, &mmm->N)) >= 0) { 57 if ((res = s_mp_cmp(T, &mmm->N)) >= 0) {
58 /* T = T - N */ 58 /* T = T - N */
59 MP_CHECKOK( s_mp_sub(T, &mmm->N) ); 59 MP_CHECKOK( s_mp_sub(T, &mmm->N) );
60 #ifdef DEBUG 60 #ifdef DEBUG
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 1169
1170 CLEANUP: 1170 CLEANUP:
1171 mp_clear(&montBase); 1171 mp_clear(&montBase);
1172 mp_clear(&goodBase); 1172 mp_clear(&goodBase);
1173 /* Don't mp_clear mmm.N because it is merely a copy of modulus. 1173 /* Don't mp_clear mmm.N because it is merely a copy of modulus.
1174 ** Just zap it. 1174 ** Just zap it.
1175 */ 1175 */
1176 memset(&mmm, 0, sizeof mmm); 1176 memset(&mmm, 0, sizeof mmm);
1177 return res; 1177 return res;
1178 } 1178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698