security/nss/lib/freebl/mpi/montmulf.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/mpi/montmulf.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/*  The functions that are to be called from outside of the .s file have the
     1.9 + *  following interfaces and array size requirements:
    1.10 + */
    1.11 +
    1.12 +
    1.13 +void conv_i32_to_d32(double *d32, unsigned int *i32, int len);
    1.14 +
    1.15 +/*  Converts an array of int's to an array of doubles, so that each double
    1.16 + *  corresponds to an int.  len is the number of items converted.
    1.17 + *  Does not allocate the output array.
    1.18 + *  The pointers d32 and i32 should point to arrays of size at least  len
    1.19 + *  (doubles and unsigned ints, respectively)
    1.20 + */
    1.21 +
    1.22 +
    1.23 +void conv_i32_to_d16(double *d16, unsigned int *i32, int len);
    1.24 +
    1.25 +/*  Converts an array of int's to an array of doubles so that each element
    1.26 + *  of the int array is converted to a pair of doubles, the first one
    1.27 + *  corresponding to the lower (least significant) 16 bits of the int and
    1.28 + *  the second one corresponding to the upper (most significant) 16 bits of
    1.29 + *  the 32-bit int. len is the number of ints converted.
    1.30 + *  Does not allocate the output array.
    1.31 + *  The pointer d16 should point to an array of doubles of size at least
    1.32 + *  2*len and i32 should point an array of ints of size at least  len
    1.33 + */
    1.34 +
    1.35 +
    1.36 +void conv_i32_to_d32_and_d16(double *d32, double *d16, 
    1.37 +			     unsigned int *i32, int len);
    1.38 +
    1.39 +/*  Does the above two conversions together, it is much faster than doing
    1.40 + *  both of those in succession
    1.41 + */
    1.42 +
    1.43 +
    1.44 +void mont_mulf_noconv(unsigned int *result,
    1.45 +		     double *dm1, double *dm2, double *dt,
    1.46 +		     double *dn, unsigned int *nint,
    1.47 +		     int nlen, double dn0);
    1.48 +
    1.49 +/*  Does the Montgomery multiplication of the numbers stored in the arrays
    1.50 + *  pointed to by dm1 and dm2, writing the result to the array pointed to by
    1.51 + *  result. It uses the array pointed to by dt as a temporary work area.
    1.52 + *  nint should point to the modulus in the array-of-integers representation, 
    1.53 + *  dn should point to its array-of-doubles as obtained as a result of the
    1.54 + *  function call   conv_i32_to_d32(dn, nint, nlen);
    1.55 + *  nlen is the length of the array containing the modulus.
    1.56 + *  The representation used for dm1 is the one that is a result of the function
    1.57 + *  call   conv_i32_to_d32(dm1, m1, nlen), the representation for dm2 is the
    1.58 + *  result of the function call   conv_i32_to_d16(dm2, m2, nlen).
    1.59 + *  Note that m1 and m2 should both be of length nlen, so they should be
    1.60 + *  padded with 0's if necessary before the conversion. The result comes in 
    1.61 + *  this form (int representation, padded with 0's).
    1.62 + *  dn0 is the value of the 16 least significant bits of n0'.
    1.63 + *  The function does not allocate memory for any of the arrays, so the 
    1.64 + *  pointers should point to arrays with the following minimal sizes:
    1.65 + *  result - nlen+1
    1.66 + *  dm1    - nlen
    1.67 + *  dm2    - 2*nlen+1  ( the +1 is necessary for technical reasons )
    1.68 + *  dt     - 4*nlen+2
    1.69 + *  dn     - nlen
    1.70 + *  nint   - nlen
    1.71 + *  No two arrays should point to overlapping areas of memory.
    1.72 + */  

mercurial