~ubuntu-branches/ubuntu/trusty/xulrunner/trusty

« back to all changes in this revision

Viewing changes to security/nss-fips/lib/freebl/mpi/mpi_i86pc.s

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-25 13:04:18 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080825130418-ck1i2ms384tzb9m0
Tags: 1.8.1.16+nobinonly-0ubuntu1
* New upstream release (taken from upstream CVS), LP: #254618.
* Fix MFSA 2008-35, MFSA 2008-34, MFSA 2008-33, MFSA 2008-32, MFSA 2008-31,
  MFSA 2008-30, MFSA 2008-29, MFSA 2008-28, MFSA 2008-27, MFSA 2008-25,
  MFSA 2008-24, MFSA 2008-23, MFSA 2008-22, MFSA 2008-21, MFSA 2008-26 also
  known as CVE-2008-2933, CVE-2008-2785, CVE-2008-2811, CVE-2008-2810,
  CVE-2008-2809, CVE-2008-2808, CVE-2008-2807, CVE-2008-2806, CVE-2008-2805,
  CVE-2008-2803, CVE-2008-2802, CVE-2008-2801, CVE-2008-2800, CVE-2008-2798.
* Drop 89_bz419350_attachment_306066 patch, merged upstream.
* Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 /
 
2
 / The contents of this file are subject to the Mozilla Public
 
3
 / License Version 1.1 (the "License"); you may not use this file
 
4
 / except in compliance with the License. You may obtain a copy of
 
5
 / the License at http://www.mozilla.org/MPL/
 
6
 / 
 
7
 / Software distributed under the License is distributed on an "AS
 
8
 / IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
9
 / implied. See the License for the specific language governing
 
10
 / rights and limitations under the License.
 
11
 / 
 
12
 / The Original Code is the Netscape security libraries.
 
13
 / 
 
14
 / The Initial Developer of the Original Code is Netscape
 
15
 / Communications Corporation.  Portions created by Netscape are 
 
16
 / Copyright (C) 2001 Netscape Communications Corporation.  All
 
17
 / Rights Reserved.
 
18
 / 
 
19
 / Contributor(s):
 
20
 / 
 
21
 / Alternatively, the contents of this file may be used under the
 
22
 / terms of the GNU General Public License Version 2 or later (the
 
23
 / "GPL"), in which case the provisions of the GPL are applicable 
 
24
 / instead of those above. If you wish to allow use of your 
 
25
 / version of this file only under the terms of the GPL and not to
 
26
 / allow others to use your version of this file under the MPL,
 
27
 / indicate your decision by deleting the provisions above and
 
28
 / replace them with the notice and other provisions required by
 
29
 / the GPL.  If you do not delete the provisions above, a recipient
 
30
 / may use your version of this file under either the MPL or the
 
31
 / GPL.
 
32
 /  $Id: mpi_i86pc.s,v 1.1 2001/04/27 20:47:39 nelsonb%netscape.com Exp $
 
33
 /
 
34
 
 
35
.text
 
36
 
 
37
 /  ebp - 36:   caller's esi
 
38
 /  ebp - 32:   caller's edi
 
39
 /  ebp - 28:   
 
40
 /  ebp - 24:   
 
41
 /  ebp - 20:   
 
42
 /  ebp - 16:   
 
43
 /  ebp - 12:   
 
44
 /  ebp - 8:    
 
45
 /  ebp - 4:    
 
46
 /  ebp + 0:    caller's ebp
 
47
 /  ebp + 4:    return address
 
48
 /  ebp + 8:    a       argument
 
49
 /  ebp + 12:   a_len   argument
 
50
 /  ebp + 16:   b       argument
 
51
 /  ebp + 20:   c       argument
 
52
 /  registers:
 
53
 /      eax:
 
54
 /      ebx:    carry
 
55
 /      ecx:    a_len
 
56
 /      edx:
 
57
 /      esi:    a ptr
 
58
 /      edi:    c ptr
 
59
.globl  s_mpv_mul_d
 
60
.type   s_mpv_mul_d,@function
 
61
s_mpv_mul_d:
 
62
    push   %ebp
 
63
    mov    %esp,%ebp
 
64
    sub    $28,%esp
 
65
    push   %edi
 
66
    push   %esi
 
67
    push   %ebx
 
68
    movl   $0,%ebx              / carry = 0
 
69
    mov    12(%ebp),%ecx        / ecx = a_len
 
70
    mov    20(%ebp),%edi
 
71
    cmp    $0,%ecx
 
72
    je     L2                   / jmp if a_len == 0
 
73
    mov    8(%ebp),%esi         / esi = a
 
74
    cld
 
75
L1:
 
76
    lodsl                       / eax = [ds:esi]; esi += 4
 
77
    mov    16(%ebp),%edx        / edx = b
 
78
    mull   %edx                 / edx:eax = Phi:Plo = a_i * b
 
79
 
 
80
    add    %ebx,%eax            / add carry (%ebx) to edx:eax
 
81
    adc    $0,%edx
 
82
    mov    %edx,%ebx            / high half of product becomes next carry
 
83
 
 
84
    stosl                       / [es:edi] = ax; edi += 4;
 
85
    dec    %ecx                 / --a_len
 
86
    jnz    L1                   / jmp if a_len != 0
 
87
L2:
 
88
    mov    %ebx,0(%edi)         / *c = carry
 
89
    pop    %ebx
 
90
    pop    %esi
 
91
    pop    %edi
 
92
    leave  
 
93
    ret    
 
94
    nop
 
95
 
 
96
 /  ebp - 36:   caller's esi
 
97
 /  ebp - 32:   caller's edi
 
98
 /  ebp - 28:   
 
99
 /  ebp - 24:   
 
100
 /  ebp - 20:   
 
101
 /  ebp - 16:   
 
102
 /  ebp - 12:   
 
103
 /  ebp - 8:    
 
104
 /  ebp - 4:    
 
105
 /  ebp + 0:    caller's ebp
 
106
 /  ebp + 4:    return address
 
107
 /  ebp + 8:    a       argument
 
108
 /  ebp + 12:   a_len   argument
 
109
 /  ebp + 16:   b       argument
 
110
 /  ebp + 20:   c       argument
 
111
 /  registers:
 
112
 /      eax:
 
113
 /      ebx:    carry
 
114
 /      ecx:    a_len
 
115
 /      edx:
 
116
 /      esi:    a ptr
 
117
 /      edi:    c ptr
 
118
.globl  s_mpv_mul_d_add
 
119
.type   s_mpv_mul_d_add,@function
 
120
s_mpv_mul_d_add:
 
121
    push   %ebp
 
122
    mov    %esp,%ebp
 
123
    sub    $28,%esp
 
124
    push   %edi
 
125
    push   %esi
 
126
    push   %ebx
 
127
    movl   $0,%ebx              / carry = 0
 
128
    mov    12(%ebp),%ecx        / ecx = a_len
 
129
    mov    20(%ebp),%edi
 
130
    cmp    $0,%ecx
 
131
    je     L4                   / jmp if a_len == 0
 
132
    mov    8(%ebp),%esi         / esi = a
 
133
    cld
 
134
L3:
 
135
    lodsl                       / eax = [ds:esi]; esi += 4
 
136
    mov    16(%ebp),%edx        / edx = b
 
137
    mull   %edx                 / edx:eax = Phi:Plo = a_i * b
 
138
 
 
139
    add    %ebx,%eax            / add carry (%ebx) to edx:eax
 
140
    adc    $0,%edx
 
141
    mov    0(%edi),%ebx         / add in current word from *c
 
142
    add    %ebx,%eax            
 
143
    adc    $0,%edx
 
144
    mov    %edx,%ebx            / high half of product becomes next carry
 
145
 
 
146
    stosl                       / [es:edi] = ax; edi += 4;
 
147
    dec    %ecx                 / --a_len
 
148
    jnz    L3                   / jmp if a_len != 0
 
149
L4:
 
150
    mov    %ebx,0(%edi)         / *c = carry
 
151
    pop    %ebx
 
152
    pop    %esi
 
153
    pop    %edi
 
154
    leave  
 
155
    ret    
 
156
    nop
 
157
 
 
158
 /  ebp - 36:   caller's esi
 
159
 /  ebp - 32:   caller's edi
 
160
 /  ebp - 28:   
 
161
 /  ebp - 24:   
 
162
 /  ebp - 20:   
 
163
 /  ebp - 16:   
 
164
 /  ebp - 12:   
 
165
 /  ebp - 8:    
 
166
 /  ebp - 4:    
 
167
 /  ebp + 0:    caller's ebp
 
168
 /  ebp + 4:    return address
 
169
 /  ebp + 8:    a       argument
 
170
 /  ebp + 12:   a_len   argument
 
171
 /  ebp + 16:   b       argument
 
172
 /  ebp + 20:   c       argument
 
173
 /  registers:
 
174
 /      eax:
 
175
 /      ebx:    carry
 
176
 /      ecx:    a_len
 
177
 /      edx:
 
178
 /      esi:    a ptr
 
179
 /      edi:    c ptr
 
180
.globl  s_mpv_mul_d_add_prop
 
181
.type   s_mpv_mul_d_add_prop,@function
 
182
s_mpv_mul_d_add_prop:
 
183
    push   %ebp
 
184
    mov    %esp,%ebp
 
185
    sub    $28,%esp
 
186
    push   %edi
 
187
    push   %esi
 
188
    push   %ebx
 
189
    movl   $0,%ebx              / carry = 0
 
190
    mov    12(%ebp),%ecx        / ecx = a_len
 
191
    mov    20(%ebp),%edi
 
192
    cmp    $0,%ecx
 
193
    je     L6                   / jmp if a_len == 0
 
194
    cld
 
195
    mov    8(%ebp),%esi         / esi = a
 
196
L5:
 
197
    lodsl                       / eax = [ds:esi]; esi += 4
 
198
    mov    16(%ebp),%edx        / edx = b
 
199
    mull   %edx                 / edx:eax = Phi:Plo = a_i * b
 
200
 
 
201
    add    %ebx,%eax            / add carry (%ebx) to edx:eax
 
202
    adc    $0,%edx
 
203
    mov    0(%edi),%ebx         / add in current word from *c
 
204
    add    %ebx,%eax            
 
205
    adc    $0,%edx
 
206
    mov    %edx,%ebx            / high half of product becomes next carry
 
207
 
 
208
    stosl                       / [es:edi] = ax; edi += 4;
 
209
    dec    %ecx                 / --a_len
 
210
    jnz    L5                   / jmp if a_len != 0
 
211
L6:
 
212
    cmp    $0,%ebx              / is carry zero?
 
213
    jz     L8
 
214
    mov    0(%edi),%eax         / add in current word from *c
 
215
    add    %ebx,%eax
 
216
    stosl                       / [es:edi] = ax; edi += 4;
 
217
    jnc    L8
 
218
L7:
 
219
    mov    0(%edi),%eax         / add in current word from *c
 
220
    adc    $0,%eax
 
221
    stosl                       / [es:edi] = ax; edi += 4;
 
222
    jc     L7
 
223
L8:
 
224
    pop    %ebx
 
225
    pop    %esi
 
226
    pop    %edi
 
227
    leave  
 
228
    ret    
 
229
    nop
 
230
 
 
231
 /  ebp - 20:   caller's esi
 
232
 /  ebp - 16:   caller's edi
 
233
 /  ebp - 12:   
 
234
 /  ebp - 8:    carry
 
235
 /  ebp - 4:    a_len   local
 
236
 /  ebp + 0:    caller's ebp
 
237
 /  ebp + 4:    return address
 
238
 /  ebp + 8:    pa      argument
 
239
 /  ebp + 12:   a_len   argument
 
240
 /  ebp + 16:   ps      argument
 
241
 /  ebp + 20:   
 
242
 /  registers:
 
243
 /      eax:
 
244
 /      ebx:    carry
 
245
 /      ecx:    a_len
 
246
 /      edx:
 
247
 /      esi:    a ptr
 
248
 /      edi:    c ptr
 
249
 
 
250
.globl  s_mpv_sqr_add_prop
 
251
.type   s_mpv_sqr_add_prop,@function
 
252
s_mpv_sqr_add_prop:
 
253
     push   %ebp
 
254
     mov    %esp,%ebp
 
255
     sub    $12,%esp
 
256
     push   %edi
 
257
     push   %esi
 
258
     push   %ebx
 
259
     movl   $0,%ebx             / carry = 0
 
260
     mov    12(%ebp),%ecx       / a_len
 
261
     mov    16(%ebp),%edi       / edi = ps
 
262
     cmp    $0,%ecx
 
263
     je     L11                 / jump if a_len == 0
 
264
     cld
 
265
     mov    8(%ebp),%esi        / esi = pa
 
266
L10:
 
267
     lodsl                      / %eax = [ds:si]; si += 4;
 
268
     mull   %eax
 
269
 
 
270
     add    %ebx,%eax           / add "carry"
 
271
     adc    $0,%edx
 
272
     mov    0(%edi),%ebx
 
273
     add    %ebx,%eax           / add low word from result
 
274
     mov    4(%edi),%ebx
 
275
     stosl                      / [es:di] = %eax; di += 4;
 
276
     adc    %ebx,%edx           / add high word from result
 
277
     movl   $0,%ebx
 
278
     mov    %edx,%eax
 
279
     adc    $0,%ebx
 
280
     stosl                      / [es:di] = %eax; di += 4;
 
281
     dec    %ecx                / --a_len
 
282
     jnz    L10                 / jmp if a_len != 0
 
283
L11:
 
284
    cmp    $0,%ebx              / is carry zero?
 
285
    jz     L14
 
286
    mov    0(%edi),%eax         / add in current word from *c
 
287
    add    %ebx,%eax
 
288
    stosl                       / [es:edi] = ax; edi += 4;
 
289
    jnc    L14
 
290
L12:
 
291
    mov    0(%edi),%eax         / add in current word from *c
 
292
    adc    $0,%eax
 
293
    stosl                       / [es:edi] = ax; edi += 4;
 
294
    jc     L12
 
295
L14:
 
296
    pop    %ebx
 
297
    pop    %esi
 
298
    pop    %edi
 
299
    leave  
 
300
    ret    
 
301
    nop
 
302
 
 
303
 /
 
304
 / Divide 64-bit (Nhi,Nlo) by 32-bit divisor, which must be normalized
 
305
 / so its high bit is 1.   This code is from NSPR.
 
306
 /
 
307
 / mp_err s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, mp_digit divisor,
 
308
 /                        mp_digit *qp, mp_digit *rp)
 
309
 
 
310
 /  esp +  0:   Caller's ebx
 
311
 /  esp +  4:   return address
 
312
 /  esp +  8:   Nhi     argument
 
313
 /  esp + 12:   Nlo     argument
 
314
 /  esp + 16:   divisor argument
 
315
 /  esp + 20:   qp      argument
 
316
 /  esp + 24:   rp      argument
 
317
 /  registers:
 
318
 /      eax:
 
319
 /      ebx:    carry
 
320
 /      ecx:    a_len
 
321
 /      edx:
 
322
 /      esi:    a ptr
 
323
 /      edi:    c ptr
 
324
 / 
 
325
 
 
326
.globl  s_mpv_div_2dx1d
 
327
.type   s_mpv_div_2dx1d,@function
 
328
s_mpv_div_2dx1d:
 
329
       push   %ebx
 
330
       mov    8(%esp),%edx
 
331
       mov    12(%esp),%eax
 
332
       mov    16(%esp),%ebx
 
333
       div    %ebx
 
334
       mov    20(%esp),%ebx
 
335
       mov    %eax,0(%ebx)
 
336
       mov    24(%esp),%ebx
 
337
       mov    %edx,0(%ebx)
 
338
       xor    %eax,%eax         / return zero
 
339
       pop    %ebx
 
340
       ret    
 
341
       nop
 
342