OLD | NEW |
1 /* | 1 /* |
2 * mpi-priv.h - Private header file for MPI | 2 * mpi-priv.h - Private header file for MPI |
3 * Arbitrary precision integer arithmetic library | 3 * Arbitrary precision integer arithmetic library |
4 * | 4 * |
5 * NOTE WELL: the content of this header file is NOT part of the "public" | 5 * NOTE WELL: the content of this header file is NOT part of the "public" |
6 * API for the MPI library, and may change at any time. | 6 * API for the MPI library, and may change at any time. |
7 * Application programs that use libmpi should NOT include this header file. | 7 * Application programs that use libmpi should NOT include this header file. |
8 * | 8 * |
9 * This Source Code Form is subject to the terms of the Mozilla Public | 9 * This Source Code Form is subject to the terms of the Mozilla Public |
10 * License, v. 2.0. If a copy of the MPL was not distributed with this | 10 * License, v. 2.0. If a copy of the MPL was not distributed with this |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 mp_size a_len, mp_digit b, | 247 mp_size a_len, mp_digit b, |
248 mp_digit *c); | 248 mp_digit *c); |
249 void MPI_ASM_DECL s_mpv_sqr_add_prop(const mp_digit *a, | 249 void MPI_ASM_DECL s_mpv_sqr_add_prop(const mp_digit *a, |
250 mp_size a_len, | 250 mp_size a_len, |
251 mp_digit *sqrs); | 251 mp_digit *sqrs); |
252 | 252 |
253 mp_err MPI_ASM_DECL s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, | 253 mp_err MPI_ASM_DECL s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, |
254 mp_digit divisor, mp_digit *quot, mp_digit *rem); | 254 mp_digit divisor, mp_digit *quot, mp_digit *rem); |
255 | 255 |
256 /* c += a * b * (MP_RADIX ** offset); */ | 256 /* c += a * b * (MP_RADIX ** offset); */ |
| 257 /* Callers of this macro should be aware that the return type might vary; |
| 258 * it should be treated as a void function. */ |
257 #define s_mp_mul_d_add_offset(a, b, c, off) \ | 259 #define s_mp_mul_d_add_offset(a, b, c, off) \ |
258 (s_mpv_mul_d_add_prop(MP_DIGITS(a), MP_USED(a), b, MP_DIGITS(c) + off), MP_OKAY) | 260 s_mpv_mul_d_add_prop(MP_DIGITS(a), MP_USED(a), b, MP_DIGITS(c) + off) |
259 | 261 |
260 typedef struct { | 262 typedef struct { |
261 mp_int N; /* modulus N */ | 263 mp_int N; /* modulus N */ |
262 mp_digit n0prime; /* n0' = - (n0 ** -1) mod MP_RADIX */ | 264 mp_digit n0prime; /* n0' = - (n0 ** -1) mod MP_RADIX */ |
263 } mp_mont_modulus; | 265 } mp_mont_modulus; |
264 | 266 |
265 mp_err s_mp_mul_mont(const mp_int *a, const mp_int *b, mp_int *c, | 267 mp_err s_mp_mul_mont(const mp_int *a, const mp_int *b, mp_int *c, |
266 mp_mont_modulus *mmm); | 268 mp_mont_modulus *mmm); |
267 mp_err s_mp_redc(mp_int *T, mp_mont_modulus *mmm); | 269 mp_err s_mp_redc(mp_int *T, mp_mont_modulus *mmm); |
268 | 270 |
269 /* | 271 /* |
270 * s_mpi_getProcessorLineSize() returns the size in bytes of the cache line | 272 * s_mpi_getProcessorLineSize() returns the size in bytes of the cache line |
271 * if a cache exists, or zero if there is no cache. If more than one | 273 * if a cache exists, or zero if there is no cache. If more than one |
272 * cache line exists, it should return the smallest line size (which is | 274 * cache line exists, it should return the smallest line size (which is |
273 * usually the L1 cache). | 275 * usually the L1 cache). |
274 * | 276 * |
275 * mp_modexp uses this information to make sure that private key information | 277 * mp_modexp uses this information to make sure that private key information |
276 * isn't being leaked through the cache. | 278 * isn't being leaked through the cache. |
277 * | 279 * |
278 * see mpcpucache.c for the implementation. | 280 * see mpcpucache.c for the implementation. |
279 */ | 281 */ |
280 unsigned long s_mpi_getProcessorLineSize(); | 282 unsigned long s_mpi_getProcessorLineSize(); |
281 | 283 |
282 /* }}} */ | 284 /* }}} */ |
283 #endif | 285 #endif |
284 | 286 |
OLD | NEW |