Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / x86 / arcfour-crypt.asm
blob89ee7c9e8bb2630a8e2579a3f914cf5dd3c9e3aa
1 C nettle, low-level cryptographics library
2 C
3 C Copyright (C) 2004, Niels Möller
4 C
5 C The nettle library is free software; you can redistribute it and/or modify
6 C it under the terms of the GNU Lesser General Public License as published by
7 C the Free Software Foundation; either version 2.1 of the License, or (at your
8 C option) any later version.
9 C
10 C The nettle library is distributed in the hope that it will be useful, but
11 C WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 C or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 C License for more details.
15 C You should have received a copy of the GNU Lesser General Public License
16 C along with the nettle library; see the file COPYING.LIB. If not, write to
17 C the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 C MA 02111-1301, USA.
20 .file "arcfour-crypt.asm"
22 C arcfour_crypt(struct arcfour_ctx *ctx,
23 C unsigned length, uint8_t *dst,
24 C const uint8_t *src)
25 .text
26 ALIGN(16)
27 PROLOGUE(nettle_arcfour_crypt)
28 C save all registers that need to be saved
29 pushl %ebx C 12(%esp)
30 pushl %ebp C 8(%esp)
31 pushl %esi C 4(%esp)
32 pushl %edi C 0(%esp)
34 C Input arguments:
35 C ctx = 20(%esp)
36 C length = 24(%esp)
37 C dst = 28(%esp)
38 C src = 32(%esp)
39 C Register usage:
40 C %ebp = ctx
41 C %esi = src
42 C %edi = dst
43 C %edx = loop counter
44 C %eax = i
45 C %ebx = j
46 C %cl = si
47 C %ch = sj
49 movl 24(%esp), %edx C length
50 movl 20(%esp), %ebp C ctx
51 movl 28(%esp), %edi C dst
52 movl 32(%esp), %esi C src
54 lea (%edx, %edi), %edi
55 lea (%edx, %esi), %esi
56 negl %edx
57 jnc .Lend
59 movzbl ARCFOUR_I (%ebp), %eax C i
60 movzbl ARCFOUR_J (%ebp), %ebx C j
62 incb %al
63 sarl $1, %edx
64 jc .Lloop_odd
66 ALIGN(16)
67 .Lloop:
68 movb (%ebp, %eax), %cl C si.
69 addb %cl, %bl
70 movb (%ebp, %ebx), %ch C sj
71 movb %ch, (%ebp, %eax) C S[i] = sj
72 incl %eax
73 movzbl %al, %eax
74 movb %cl, (%ebp, %ebx) C S[j] = si
75 addb %ch, %cl
76 movzbl %cl, %ecx C Clear, so it can be used
77 C for indexing.
78 movb (%ebp, %ecx), %cl
79 xorb (%esi, %edx, 2), %cl
80 movb %cl, (%edi, %edx, 2)
82 C FIXME: Could exchange cl and ch in the second half
83 C and try to interleave instructions better.
84 .Lloop_odd:
85 movb (%ebp, %eax), %cl C si.
86 addb %cl, %bl
87 movb (%ebp, %ebx), %ch C sj
88 movb %ch, (%ebp, %eax) C S[i] = sj
89 incl %eax
90 movzbl %al, %eax
91 movb %cl, (%ebp, %ebx) C S[j] = si
92 addb %ch, %cl
93 movzbl %cl, %ecx C Clear, so it can be used
94 C for indexing.
95 movb (%ebp, %ecx), %cl
96 xorb 1(%esi, %edx, 2), %cl
97 incl %edx
98 movb %cl, -1(%edi, %edx, 2)
100 jnz .Lloop
102 C .Lloop_done:
103 decb %al
104 movb %al, ARCFOUR_I (%ebp) C Store the new i and j.
105 movb %bl, ARCFOUR_J (%ebp)
106 .Lend:
107 popl %edi
108 popl %esi
109 popl %ebp
110 popl %ebx
112 EPILOGUE(nettle_arcfour_crypt)