1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is interface file for SPARC Montgomery multiply functions.
*
* The Initial Developer of the Original Code is Sun Microsystems Inc.
* Portions created by Sun Microsystems Inc. are
* Copyright (C) 19992000 Sun Microsystems Inc. All Rights Reserved.
*
* Contributor(s):
* Netscape Communications Corporation
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: montmulf.h,v 1.2 2000/11/17 20:15:28 nelsonb%netscape.com Exp $
*/
/* The functions that are to be called from outside of the .s file have the
* following interfaces and array size requirements:
*/
void conv_i32_to_d32(double *d32, unsigned int *i32, int len);
/* Converts an array of int's to an array of doubles, so that each double
* corresponds to an int. len is the number of items converted.
* Does not allocate the output array.
* The pointers d32 and i32 should point to arrays of size at least len
* (doubles and unsigned ints, respectively)
*/
void conv_i32_to_d16(double *d16, unsigned int *i32, int len);
/* Converts an array of int's to an array of doubles so that each element
* of the int array is converted to a pair of doubles, the first one
* corresponding to the lower (least significant) 16 bits of the int and
* the second one corresponding to the upper (most significant) 16 bits of
* the 32bit int. len is the number of ints converted.
* Does not allocate the output array.
* The pointer d16 should point to an array of doubles of size at least
* 2*len and i32 should point an array of ints of size at least len
*/
void conv_i32_to_d32_and_d16(double *d32, double *d16,
unsigned int *i32, int len);
/* Does the above two conversions together, it is much faster than doing
* both of those in succession
*/
void mont_mulf_noconv(unsigned int *result,
double *dm1, double *dm2, double *dt,
double *dn, unsigned int *nint,
int nlen, double dn0);
/* Does the Montgomery multiplication of the numbers stored in the arrays
* pointed to by dm1 and dm2, writing the result to the array pointed to by
* result. It uses the array pointed to by dt as a temporary work area.
* nint should point to the modulus in the arrayofintegers representation,
* dn should point to its arrayofdoubles as obtained as a result of the
* function call conv_i32_to_d32(dn, nint, nlen);
* nlen is the length of the array containing the modulus.
* The representation used for dm1 is the one that is a result of the function
* call conv_i32_to_d32(dm1, m1, nlen), the representation for dm2 is the
* result of the function call conv_i32_to_d16(dm2, m2, nlen).
* Note that m1 and m2 should both be of length nlen, so they should be
* padded with 0's if necessary before the conversion. The result comes in
* this form (int representation, padded with 0's).
* dn0 is the value of the 16 least significant bits of n0'.
* The function does not allocate memory for any of the arrays, so the
* pointers should point to arrays with the following minimal sizes:
* result  nlen+1
* dm1  nlen
* dm2  2*nlen+1 ( the +1 is necessary for technical reasons )
* dt  4*nlen+2
* dn  nlen
* nint  nlen
* No two arrays should point to overlapping areas of memory.
*/
