summaryrefslogtreecommitdiff
path: root/deps/openssl/asm/x86-macosx-gas/rc5/rc5-586.s
blob: ed7f7dc76253f0c7cfc9cba46d63b291137d584b (plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
.file	"rc5-586.s"
.text
.globl	_RC5_32_encrypt
.align	4
_RC5_32_encrypt:
L_RC5_32_encrypt_begin:

	pushl	%ebp
	pushl	%esi
	pushl	%edi
	movl	16(%esp),%edx
	movl	20(%esp),%ebp
	# Load the 2 words

	movl	(%edx),%edi
	movl	4(%edx),%esi
	pushl	%ebx
	movl	(%ebp),%ebx
	addl	4(%ebp),%edi
	addl	8(%ebp),%esi
	xorl	%esi,%edi
	movl	12(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	16(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	20(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	24(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	28(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	32(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	36(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	40(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	44(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	48(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	52(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	56(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	60(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	64(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	68(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	72(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	cmpl	$8,%ebx
	je	L000rc5_exit
	xorl	%esi,%edi
	movl	76(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	80(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	84(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	88(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	92(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	96(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	100(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	104(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	cmpl	$12,%ebx
	je	L000rc5_exit
	xorl	%esi,%edi
	movl	108(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	112(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	116(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	120(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	124(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	128(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
	xorl	%esi,%edi
	movl	132(%ebp),%eax
	movl	%esi,%ecx
	roll	%cl,%edi
	addl	%eax,%edi
	xorl	%edi,%esi
	movl	136(%ebp),%eax
	movl	%edi,%ecx
	roll	%cl,%esi
	addl	%eax,%esi
L000rc5_exit:
	movl	%edi,(%edx)
	movl	%esi,4(%edx)
	popl	%ebx
	popl	%edi
	popl	%esi
	popl	%ebp
	ret
.globl	_RC5_32_decrypt
.align	4
_RC5_32_decrypt:
L_RC5_32_decrypt_begin:

	pushl	%ebp
	pushl	%esi
	pushl	%edi
	movl	16(%esp),%edx
	movl	20(%esp),%ebp
	# Load the 2 words

	movl	(%edx),%edi
	movl	4(%edx),%esi
	pushl	%ebx
	movl	(%ebp),%ebx
	cmpl	$12,%ebx
	je	L001rc5_dec_12
	cmpl	$8,%ebx
	je	L002rc5_dec_8
	movl	136(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	132(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	128(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	124(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	120(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	116(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	112(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	108(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
L001rc5_dec_12:
	movl	104(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	100(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	96(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	92(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	88(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	84(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	80(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	76(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
L002rc5_dec_8:
	movl	72(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	68(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	64(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	60(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	56(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	52(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	48(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	44(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	40(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	36(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	32(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	28(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	24(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	20(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	movl	16(%ebp),%eax
	subl	%eax,%esi
	movl	%edi,%ecx
	rorl	%cl,%esi
	xorl	%edi,%esi
	movl	12(%ebp),%eax
	subl	%eax,%edi
	movl	%esi,%ecx
	rorl	%cl,%edi
	xorl	%esi,%edi
	subl	8(%ebp),%esi
	subl	4(%ebp),%edi
L003rc5_exit:
	movl	%edi,(%edx)
	movl	%esi,4(%edx)
	popl	%ebx
	popl	%edi
	popl	%esi
	popl	%ebp
	ret
.globl	_RC5_32_cbc_encrypt
.align	4
_RC5_32_cbc_encrypt:
L_RC5_32_cbc_encrypt_begin:

	pushl	%ebp
	pushl	%ebx
	pushl	%esi
	pushl	%edi
	movl	28(%esp),%ebp
	# getting iv ptr from parameter 4

	movl	36(%esp),%ebx
	movl	(%ebx),%esi
	movl	4(%ebx),%edi
	pushl	%edi
	pushl	%esi
	pushl	%edi
	pushl	%esi
	movl	%esp,%ebx
	movl	36(%esp),%esi
	movl	40(%esp),%edi
	# getting encrypt flag from parameter 5

	movl	56(%esp),%ecx
	# get and push parameter 3

	movl	48(%esp),%eax
	pushl	%eax
	pushl	%ebx
	cmpl	$0,%ecx
	jz	L004decrypt
	andl	$4294967288,%ebp
	movl	8(%esp),%eax
	movl	12(%esp),%ebx
	jz	L005encrypt_finish
L006encrypt_loop:
	movl	(%esi),%ecx
	movl	4(%esi),%edx
	xorl	%ecx,%eax
	xorl	%edx,%ebx
	movl	%eax,8(%esp)
	movl	%ebx,12(%esp)
	call	L_RC5_32_encrypt_begin
	movl	8(%esp),%eax
	movl	12(%esp),%ebx
	movl	%eax,(%edi)
	movl	%ebx,4(%edi)
	addl	$8,%esi
	addl	$8,%edi
	subl	$8,%ebp
	jnz	L006encrypt_loop
L005encrypt_finish:
	movl	52(%esp),%ebp
	andl	$7,%ebp
	jz	L007finish
	call	L008PIC_point
L008PIC_point:
	popl	%edx
	leal	L009cbc_enc_jmp_table-L008PIC_point(%edx),%ecx
	movl	(%ecx,%ebp,4),%ebp
	addl	%edx,%ebp
	xorl	%ecx,%ecx
	xorl	%edx,%edx
	jmp	*%ebp
L010ej7:
	movb	6(%esi),%dh
	shll	$8,%edx
L011ej6:
	movb	5(%esi),%dh
L012ej5:
	movb	4(%esi),%dl
L013ej4:
	movl	(%esi),%ecx
	jmp	L014ejend
L015ej3:
	movb	2(%esi),%ch
	shll	$8,%ecx
L016ej2:
	movb	1(%esi),%ch
L017ej1:
	movb	(%esi),%cl
L014ejend:
	xorl	%ecx,%eax
	xorl	%edx,%ebx
	movl	%eax,8(%esp)
	movl	%ebx,12(%esp)
	call	L_RC5_32_encrypt_begin
	movl	8(%esp),%eax
	movl	12(%esp),%ebx
	movl	%eax,(%edi)
	movl	%ebx,4(%edi)
	jmp	L007finish
L004decrypt:
	andl	$4294967288,%ebp
	movl	16(%esp),%eax
	movl	20(%esp),%ebx
	jz	L018decrypt_finish
L019decrypt_loop:
	movl	(%esi),%eax
	movl	4(%esi),%ebx
	movl	%eax,8(%esp)
	movl	%ebx,12(%esp)
	call	L_RC5_32_decrypt_begin
	movl	8(%esp),%eax
	movl	12(%esp),%ebx
	movl	16(%esp),%ecx
	movl	20(%esp),%edx
	xorl	%eax,%ecx
	xorl	%ebx,%edx
	movl	(%esi),%eax
	movl	4(%esi),%ebx
	movl	%ecx,(%edi)
	movl	%edx,4(%edi)
	movl	%eax,16(%esp)
	movl	%ebx,20(%esp)
	addl	$8,%esi
	addl	$8,%edi
	subl	$8,%ebp
	jnz	L019decrypt_loop
L018decrypt_finish:
	movl	52(%esp),%ebp
	andl	$7,%ebp
	jz	L007finish
	movl	(%esi),%eax
	movl	4(%esi),%ebx
	movl	%eax,8(%esp)
	movl	%ebx,12(%esp)
	call	L_RC5_32_decrypt_begin
	movl	8(%esp),%eax
	movl	12(%esp),%ebx
	movl	16(%esp),%ecx
	movl	20(%esp),%edx
	xorl	%eax,%ecx
	xorl	%ebx,%edx
	movl	(%esi),%eax
	movl	4(%esi),%ebx
L020dj7:
	rorl	$16,%edx
	movb	%dl,6(%edi)
	shrl	$16,%edx
L021dj6:
	movb	%dh,5(%edi)
L022dj5:
	movb	%dl,4(%edi)
L023dj4:
	movl	%ecx,(%edi)
	jmp	L024djend
L025dj3:
	rorl	$16,%ecx
	movb	%cl,2(%edi)
	shll	$16,%ecx
L026dj2:
	movb	%ch,1(%esi)
L027dj1:
	movb	%cl,(%esi)
L024djend:
	jmp	L007finish
L007finish:
	movl	60(%esp),%ecx
	addl	$24,%esp
	movl	%eax,(%ecx)
	movl	%ebx,4(%ecx)
	popl	%edi
	popl	%esi
	popl	%ebx
	popl	%ebp
	ret
.align	6,0x90
L009cbc_enc_jmp_table:
.long	0
.long	L017ej1-L008PIC_point
.long	L016ej2-L008PIC_point
.long	L015ej3-L008PIC_point
.long	L013ej4-L008PIC_point
.long	L012ej5-L008PIC_point
.long	L011ej6-L008PIC_point
.long	L010ej7-L008PIC_point
.align	6,0x90