Lines Matching +defs:val +defs:to

10  * The contents of this file are subject to the Mozilla Public License Version
35 * of those above. If you wish to allow use of your version of this file only
36 * under the terms of either the GPL or the LGPL, and not to allow others to
47 * Oracle elects to use this software under the MPL license.
66 This table is used to compute output lengths for the mp_toradix()
92 /* Value to digit maps for radix conversion */
205 /* {{{ mp_copy(from, to) */
208 mp_copy(from, to)
210 Copies the mp_int 'from' to the mp_int 'to'. It is presumed that
211 'to' has already been initialized (if not, use mp_init_copy()
212 instead). If 'from' and 'to' are identical, nothing happens.
215 mp_err mp_copy(const mp_int *from, mp_int *to)
217 ARGCHK(from != NULL && to != NULL, MP_BADARG);
219 if(from == to)
227 If the allocated buffer in 'to' already has enough space to hold
228 all the used digits of 'from', we'll re-use it to avoid hitting
230 to grow anyway, so we just allocate a hunk and make the copy as
233 if(ALLOC(to) >= USED(from)) {
234 s_mp_setz(DIGITS(to) + USED(from), ALLOC(to) - USED(from));
235 s_mp_copy(DIGITS(from), DIGITS(to), USED(from));
243 if(DIGITS(to) != NULL) {
245 s_mp_setz(DIGITS(to), ALLOC(to));
247 s_mp_free(DIGITS(to), ALLOC(to));
250 DIGITS(to) = tmp;
251 ALLOC(to) = ALLOC(from);
255 USED(to) = USED(from);
256 SIGN(to) = SIGN(from);
257 FLAG(to) = FLAG(from);
326 Set mp to zero. Does not change the allocated size of the structure,
824 * converts an mp_int with 32-bit "digits" to an array
934 const mp_int *xch = b; /* switch a and b, to do fewer outer loops */
1158 /* now add the squares of the digits of a to sqr. */
1227 /* r was set to a above. */
1300 Compute c = a ** b, that is, raise a to the b power. Uses a
1406 If |a| > m, we need to divide to get the remainder and take the
1409 If |a| < m, we don't need to do any division, just copy and adjust
1412 If |a| == m, we can simply set the result to zero.
1414 This order is intended to minimize the average path length of the
1489 approximation technique to determine this value; the result has the
1495 It is a range error to pass a negative value.
1549 /* Copy result to output parameter */
1902 This just converts z to an mp_int, and uses the existing comparison
1903 routines. This is sort of inefficient, but it's not clear to me how
1961 binary algorithm due to Josef Stein in 1961 (via Knuth).
2194 /* copy results to output */
2350 ** Compute x = (a ** -1) mod p. This is similar to Montgomery reduction.
2468 mp_int t0, t1, val, tmp, two2k;
2484 MP_DIGITS(&val) = 0;
2487 MP_CHECKOK( mp_init_copy(&val, a) );
2488 s_mp_mod_2d(&val, k);
2489 MP_CHECKOK( mp_init_copy(&t0, &val) );
2495 MP_CHECKOK( mp_mul(&val, &t1, &tmp) );
2515 mp_clear(&val);
2526 mp_int oddPart, evenPart; /* parts to combine via CRT. */
2561 /* Use Chinese Remainer theorem to compute a**-1 mod m. */
2601 This is equivalent to the question of whether (a, m) = 1. If not,
2742 Read an integer from the given string, and set mp to the resulting
2743 value. The input is presumed to be in base 10. Leading non-digit
2750 int ix = 0, val = 0;
2775 while((val = s_mp_tovalue(str[ix], radix)) >= 0) {
2778 if((res = s_mp_add_d(mp, val)) != MP_OKAY)
2892 /* Add trailing NUL to end the string */
2934 not attempt to modify or free the memory associated with this
2961 /* Make sure there are at least 'min' digits allocated to mp */
2967 /* Set min to next nearest default precision block size */
2997 /* Make sure there is room to increase precision */
3018 /* Set 'count' digits pointed to by dp to be zeroes */
3038 /* Copy 'count' digits from sp to dp */
3058 /* Allocate ni records of nb bytes each, and return a pointer to that */
3076 /* Free the memory pointed to by ptr */
3131 alternative to multiplication by powers of the radix
3132 The value of USED(mp) must already have been set to the value for
3171 amounts to a bitwise shift of the value.
3183 /* bits to be shifted out of the top word */
3225 /* Shortcut when all digits are to be shifted off */
3255 /* Divide by two -- take advantage of radix properties to do it fast */
3303 amounts to a bitwise AND of the value, and does not require the full
3333 amounts to a bitwise shift of the value, and does not require the
3365 leading digit of b to be at least half the radix, which we
3405 /* Add d to |mp| in place */
3684 Add up all digits up to the precision of b. If b had initially
3687 less precision, we'll have to make sure the carry out is duly
3729 allocator unless we're sure we have to?
3777 Add up all digits up to the precision of b. If b had initially
3780 less precision, we'll have to make sure the carry out is duly
3817 allocator unless we're sure we have to?
3860 Add up all digits up to the precision of b. If b had initially
3863 less precision, we'll have to make sure the carry out is duly
3900 allocator unless we're sure we have to?
3938 Subtract and propagate borrow. Up to the precision of b, this
3940 carries get to the right place. This saves having to pad b out to
3941 the precision of a just to make the loops work right...
4012 Subtract and propagate borrow. Up to the precision of b, this
4014 carries get to the right place. This saves having to pad b out to
4015 the precision of a just to make the loops work right...
4241 /* Add the squares of the digits of a to the digits of b. */
4294 /* now add to ps */
4419 /* Normalize to optimize guessing */
4472 /* See what that multiplies out to */
4477 If it's too big, back it off. We should not have to do this
4479 method by which this could be reduced to a maximum of once, but
4481 * When using s_mpv_div_2dx1d, we may have to do this 3 times.
4499 have to check for failures here
4550 can nearly halve the time required to do modular exponentiation,
4551 as compared to using the full integer divide to reduce.
4581 /* If x < 0, add b^(k+1) to it */
4767 Convert the given character to its digit value, in the given radix.
4772 expected to know what you're up to.
4776 int val, xch;
4784 val = xch - '0';
4786 val = xch - 'A' + 10;
4788 val = xch - 'a' + 36;
4790 val = 62;
4792 val = 63;
4796 if(val < 0 || val >= r)
4799 return val;
4805 /* {{{ s_mp_todigit(val, r, low) */
4808 Convert val to a radix-r digit, if possible. If val is out of range
4813 expected to know what you're doing.
4816 char s_mp_todigit(mp_digit val, int r, int low)
4820 if(val >= r)
4823 ch = s_dmap_1[val];
4837 Return an estimate for how long a string is needed to hold a radix
4985 if (x & 0x80) { /* add one leading zero to make output positive. */