xref: /netbsd-src/crypto/external/bsd/openssl/lib/libcrypto/arch/i386/rc4-586.S (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1.file	"rc4-586.s"
2.text
3.globl	RC4
4.type	RC4,@function
5.align	16
6RC4:
7.L_RC4_begin:
8	pushl	%ebp
9	pushl	%ebx
10	pushl	%esi
11	pushl	%edi
12	movl	20(%esp),%edi
13	movl	24(%esp),%edx
14	movl	28(%esp),%esi
15	movl	32(%esp),%ebp
16	xorl	%eax,%eax
17	xorl	%ebx,%ebx
18	cmpl	$0,%edx
19	je	.L000abort
20	movb	(%edi),%al
21	movb	4(%edi),%bl
22	addl	$8,%edi
23	leal	(%esi,%edx,1),%ecx
24	subl	%esi,%ebp
25	movl	%ecx,24(%esp)
26	incb	%al
27	cmpl	$-1,256(%edi)
28	je	.L001RC4_CHAR
29	movl	(%edi,%eax,4),%ecx
30	andl	$-4,%edx
31	jz	.L002loop1
32	leal	-4(%esi,%edx,1),%edx
33	movl	%edx,28(%esp)
34	movl	%ebp,32(%esp)
35.align	16
36.L003loop4:
37	addb	%cl,%bl
38	movl	(%edi,%ebx,4),%edx
39	movl	%ecx,(%edi,%ebx,4)
40	movl	%edx,(%edi,%eax,4)
41	addl	%ecx,%edx
42	incb	%al
43	andl	$255,%edx
44	movl	(%edi,%eax,4),%ecx
45	movl	(%edi,%edx,4),%ebp
46	addb	%cl,%bl
47	movl	(%edi,%ebx,4),%edx
48	movl	%ecx,(%edi,%ebx,4)
49	movl	%edx,(%edi,%eax,4)
50	addl	%ecx,%edx
51	incb	%al
52	andl	$255,%edx
53	rorl	$8,%ebp
54	movl	(%edi,%eax,4),%ecx
55	orl	(%edi,%edx,4),%ebp
56	addb	%cl,%bl
57	movl	(%edi,%ebx,4),%edx
58	movl	%ecx,(%edi,%ebx,4)
59	movl	%edx,(%edi,%eax,4)
60	addl	%ecx,%edx
61	incb	%al
62	andl	$255,%edx
63	rorl	$8,%ebp
64	movl	(%edi,%eax,4),%ecx
65	orl	(%edi,%edx,4),%ebp
66	addb	%cl,%bl
67	movl	(%edi,%ebx,4),%edx
68	movl	%ecx,(%edi,%ebx,4)
69	movl	%edx,(%edi,%eax,4)
70	addl	%ecx,%edx
71	incb	%al
72	andl	$255,%edx
73	rorl	$8,%ebp
74	movl	32(%esp),%ecx
75	orl	(%edi,%edx,4),%ebp
76	rorl	$8,%ebp
77	xorl	(%esi),%ebp
78	cmpl	28(%esp),%esi
79	movl	%ebp,(%ecx,%esi,1)
80	leal	4(%esi),%esi
81	movl	(%edi,%eax,4),%ecx
82	jb	.L003loop4
83	cmpl	24(%esp),%esi
84	je	.L004done
85	movl	32(%esp),%ebp
86.align	16
87.L002loop1:
88	addb	%cl,%bl
89	movl	(%edi,%ebx,4),%edx
90	movl	%ecx,(%edi,%ebx,4)
91	movl	%edx,(%edi,%eax,4)
92	addl	%ecx,%edx
93	incb	%al
94	andl	$255,%edx
95	movl	(%edi,%edx,4),%edx
96	xorb	(%esi),%dl
97	leal	1(%esi),%esi
98	movl	(%edi,%eax,4),%ecx
99	cmpl	24(%esp),%esi
100	movb	%dl,-1(%ebp,%esi,1)
101	jb	.L002loop1
102	jmp	.L004done
103.align	16
104.L001RC4_CHAR:
105	movzbl	(%edi,%eax,1),%ecx
106.L005cloop1:
107	addb	%cl,%bl
108	movzbl	(%edi,%ebx,1),%edx
109	movb	%cl,(%edi,%ebx,1)
110	movb	%dl,(%edi,%eax,1)
111	addb	%cl,%dl
112	movzbl	(%edi,%edx,1),%edx
113	addb	$1,%al
114	xorb	(%esi),%dl
115	leal	1(%esi),%esi
116	movzbl	(%edi,%eax,1),%ecx
117	cmpl	24(%esp),%esi
118	movb	%dl,-1(%ebp,%esi,1)
119	jb	.L005cloop1
120.L004done:
121	decb	%al
122	movb	%bl,-4(%edi)
123	movb	%al,-8(%edi)
124.L000abort:
125	popl	%edi
126	popl	%esi
127	popl	%ebx
128	popl	%ebp
129	ret
130.size	RC4,.-.L_RC4_begin
131.globl	RC4_set_key
132.type	RC4_set_key,@function
133.align	16
134RC4_set_key:
135.L_RC4_set_key_begin:
136	pushl	%ebp
137	pushl	%ebx
138	pushl	%esi
139	pushl	%edi
140	movl	20(%esp),%edi
141	movl	24(%esp),%ebp
142	movl	28(%esp),%esi
143	call	.L006PIC_me_up
144.L006PIC_me_up:
145	popl	%edx
146	leal	_GLOBAL_OFFSET_TABLE_+[.-.L006PIC_me_up](%edx),%edx
147	movl	OPENSSL_ia32cap_P@GOT(%edx),%edx
148	leal	8(%edi),%edi
149	leal	(%esi,%ebp,1),%esi
150	negl	%ebp
151	xorl	%eax,%eax
152	movl	%ebp,-4(%edi)
153	btl	$20,(%edx)
154	jc	.L007c1stloop
155.align	16
156.L008w1stloop:
157	movl	%eax,(%edi,%eax,4)
158	addb	$1,%al
159	jnc	.L008w1stloop
160	xorl	%ecx,%ecx
161	xorl	%edx,%edx
162.align	16
163.L009w2ndloop:
164	movl	(%edi,%ecx,4),%eax
165	addb	(%esi,%ebp,1),%dl
166	addb	%al,%dl
167	addl	$1,%ebp
168	movl	(%edi,%edx,4),%ebx
169	jnz	.L010wnowrap
170	movl	-4(%edi),%ebp
171.L010wnowrap:
172	movl	%eax,(%edi,%edx,4)
173	movl	%ebx,(%edi,%ecx,4)
174	addb	$1,%cl
175	jnc	.L009w2ndloop
176	jmp	.L011exit
177.align	16
178.L007c1stloop:
179	movb	%al,(%edi,%eax,1)
180	addb	$1,%al
181	jnc	.L007c1stloop
182	xorl	%ecx,%ecx
183	xorl	%edx,%edx
184	xorl	%ebx,%ebx
185.align	16
186.L012c2ndloop:
187	movb	(%edi,%ecx,1),%al
188	addb	(%esi,%ebp,1),%dl
189	addb	%al,%dl
190	addl	$1,%ebp
191	movb	(%edi,%edx,1),%bl
192	jnz	.L013cnowrap
193	movl	-4(%edi),%ebp
194.L013cnowrap:
195	movb	%al,(%edi,%edx,1)
196	movb	%bl,(%edi,%ecx,1)
197	addb	$1,%cl
198	jnc	.L012c2ndloop
199	movl	$-1,256(%edi)
200.L011exit:
201	xorl	%eax,%eax
202	movl	%eax,-8(%edi)
203	movl	%eax,-4(%edi)
204	popl	%edi
205	popl	%esi
206	popl	%ebx
207	popl	%ebp
208	ret
209.size	RC4_set_key,.-.L_RC4_set_key_begin
210.globl	RC4_options
211.type	RC4_options,@function
212.align	16
213RC4_options:
214.L_RC4_options_begin:
215	call	.L014pic_point
216.L014pic_point:
217	popl	%eax
218	leal	.L015opts-.L014pic_point(%eax),%eax
219	call	.L016PIC_me_up
220.L016PIC_me_up:
221	popl	%edx
222	leal	_GLOBAL_OFFSET_TABLE_+[.-.L016PIC_me_up](%edx),%edx
223	movl	OPENSSL_ia32cap_P@GOT(%edx),%edx
224	btl	$20,(%edx)
225	jnc	.L017skip
226	addl	$12,%eax
227.L017skip:
228	ret
229.align	64
230.L015opts:
231.byte	114,99,52,40,52,120,44,105,110,116,41,0
232.byte	114,99,52,40,49,120,44,99,104,97,114,41,0
233.byte	82,67,52,32,102,111,114,32,120,56,54,44,32,67,82,89
234.byte	80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114
235.byte	111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
236.align	64
237.size	RC4_options,.-.L_RC4_options_begin
238.comm	OPENSSL_ia32cap_P,4,4
239