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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 /*  The functions that are to be called from outside of the .s file have the
     6  *  following interfaces and array size requirements:
     7  */
    10 void conv_i32_to_d32(double *d32, unsigned int *i32, int len);
    12 /*  Converts an array of int's to an array of doubles, so that each double
    13  *  corresponds to an int.  len is the number of items converted.
    14  *  Does not allocate the output array.
    15  *  The pointers d32 and i32 should point to arrays of size at least  len
    16  *  (doubles and unsigned ints, respectively)
    17  */
    20 void conv_i32_to_d16(double *d16, unsigned int *i32, int len);
    22 /*  Converts an array of int's to an array of doubles so that each element
    23  *  of the int array is converted to a pair of doubles, the first one
    24  *  corresponding to the lower (least significant) 16 bits of the int and
    25  *  the second one corresponding to the upper (most significant) 16 bits of
    26  *  the 32-bit int. len is the number of ints converted.
    27  *  Does not allocate the output array.
    28  *  The pointer d16 should point to an array of doubles of size at least
    29  *  2*len and i32 should point an array of ints of size at least  len
    30  */
    33 void conv_i32_to_d32_and_d16(double *d32, double *d16, 
    34 			     unsigned int *i32, int len);
    36 /*  Does the above two conversions together, it is much faster than doing
    37  *  both of those in succession
    38  */
    41 void mont_mulf_noconv(unsigned int *result,
    42 		     double *dm1, double *dm2, double *dt,
    43 		     double *dn, unsigned int *nint,
    44 		     int nlen, double dn0);
    46 /*  Does the Montgomery multiplication of the numbers stored in the arrays
    47  *  pointed to by dm1 and dm2, writing the result to the array pointed to by
    48  *  result. It uses the array pointed to by dt as a temporary work area.
    49  *  nint should point to the modulus in the array-of-integers representation, 
    50  *  dn should point to its array-of-doubles as obtained as a result of the
    51  *  function call   conv_i32_to_d32(dn, nint, nlen);
    52  *  nlen is the length of the array containing the modulus.
    53  *  The representation used for dm1 is the one that is a result of the function
    54  *  call   conv_i32_to_d32(dm1, m1, nlen), the representation for dm2 is the
    55  *  result of the function call   conv_i32_to_d16(dm2, m2, nlen).
    56  *  Note that m1 and m2 should both be of length nlen, so they should be
    57  *  padded with 0's if necessary before the conversion. The result comes in 
    58  *  this form (int representation, padded with 0's).
    59  *  dn0 is the value of the 16 least significant bits of n0'.
    60  *  The function does not allocate memory for any of the arrays, so the 
    61  *  pointers should point to arrays with the following minimal sizes:
    62  *  result - nlen+1
    63  *  dm1    - nlen
    64  *  dm2    - 2*nlen+1  ( the +1 is necessary for technical reasons )
    65  *  dt     - 4*nlen+2
    66  *  dn     - nlen
    67  *  nint   - nlen
    68  *  No two arrays should point to overlapping areas of memory.
    69  */  

mercurial