File: blowfishopt.i586.asm

package info (click to toggle)
beecrypt 2.2.0-pre1-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,820 kB
  • ctags: 1,325
  • sloc: ansic: 12,215; sh: 9,073; asm: 2,715; makefile: 80
file content (173 lines) | stat: -rw-r--r-- 2,904 bytes parent folder | download | duplicates (3)
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
#
# blowfishopt.i586.asm
#
# Assembler optimized blowfish routines for Intel Pentium processors
#
# Compile target is Metrowerks CodeWarrior Pro 5 for Windows
#
# Copyright (c) 2000 Virtual Unlimited B.V.
#
# Author: Bob Deblier <bob@virtualunlimited.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

etworounds:	.macro p
	xor ecx,[esi+p]
	rol ecx,16
	mov al,ch
	mov bl,cl
	rol ecx,16
	mov edi,[esi+eax*4+72+0x000]
	add edi,[esi+ebx*4+72+0x400]
	mov al,ch
	mov bl,cl
	xor edi,[esi+eax*4+72+0x800]
	add edi,[esi+ebx*4+72+0xC00]
	xor edx,edi
	xor edx,[esi+p+4]
	rol edx,16
	mov al,dh
	mov bl,dl
	rol edx,16
	mov edi,[esi+eax*4+72+0x000]
	add edi,[esi+ebx*4+72+0x400]
	mov al,dh
	mov bl,dl
	xor edi,[esi+eax*4+72+0x800]
	add edi,[esi+ebx*4+72+0xC00]
	xor ecx,edi
	.endm
	
dtworounds:	.macro p
	xor ecx,[esi+p+4]
	rol ecx,16
	mov al,ch
	mov bl,cl
	rol ecx,16
	mov edi,[esi+eax*4+72+0x000]
	add edi,[esi+ebx*4+72+0x400]
	mov al,ch
	mov bl,cl
	xor edi,[esi+eax*4+72+0x800]
	add edi,[esi+ebx*4+72+0xC00]
	xor edx,edi
	xor edx,[esi+p]
	rol edx,16
	mov al,dh
	mov bl,dl
	rol edx,16
	mov edi,[esi+eax*4+72+0x000]
	add edi,[esi+ebx*4+72+0x400]
	mov al,dh
	mov bl,dl
	xor edi,[esi+eax*4+72+0x800]
	add edi,[esi+ebx*4+72+0xC00]
	xor ecx,edi
	.endm

	.text

	.align 8
	.globl _blowfishEncrypt
	
_blowfishEncrypt:
	push edi
	push esi
	push ebx

	mov esi,[esp+16]
	mov edi,[esp+24]
	
	xor eax,eax
	xor ebx,ebx
	
	mov ecx,[edi]
	mov edx,[edi+4]
	
	bswap ecx
	bswap edx
	
	etworounds 0
	etworounds 8
	etworounds 16
	etworounds 24
	etworounds 32
	etworounds 40
	etworounds 48
	etworounds 56

	mov edi,[esp+20]
	xor ecx,[esi+64]
	xor edx,[esi+68]
	
	bswap ecx
	bswap edx
	
	mov [edi+4],ecx
	mov [edi],edx
	
	xor eax,eax
	
	pop ebx
	pop esi
	pop edi
	ret

	.align 8
	.globl _blowfishDecrypt

_blowfishDecrypt:
	push edi
	push esi
	push ebx

	mov esi,[esp+16]
	mov edi,[esp+24]
	
	xor eax,eax
	xor ebx,ebx
	
	mov ecx,[edi]
	mov edx,[edi+4]
	
	bswap ecx
	bswap edx
	
	dtworounds 64
	dtworounds 56
	dtworounds 48
	dtworounds 40
	dtworounds 32
	dtworounds 24
	dtworounds 16
	dtworounds 8

	mov edi,[esp+20]
	xor ecx,[esi+4]
	xor edx,[esi]
	
	bswap ecx
	bswap edx
	
	mov [edi+4],ecx
	mov [edi],edx
	
	xor eax,eax
	
	pop ebx
	pop esi
	pop edi
	ret