Subversion Repositories Kolibri OS

Rev

Rev 3115 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3115 Rev 3431
Line -... Line 1...
-
 
1
;    libcrash -- cryptographic hash functions
-
 
2
;
-
 
3
;    Copyright (C) 2012-2013 Ivan Baravy (dunkaist)
-
 
4
;
-
 
5
;    This program is free software: you can redistribute it and/or modify
-
 
6
;    it under the terms of the GNU General Public License as published by
-
 
7
;    the Free Software Foundation, either version 3 of the License, or
-
 
8
;    (at your option) any later version.
-
 
9
;
-
 
10
;    This program is distributed in the hope that it will be useful,
-
 
11
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
-
 
12
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-
 
13
;    GNU General Public License for more details.
-
 
14
;
-
 
15
;    You should have received a copy of the GNU General Public License
-
 
16
;    along with this program.  If not, see .
-
 
17
 
1
macro crash.md5.f b, c, d
18
macro crash.md5.f b, c, d
2
{
19
{
3
	push	c
20
	push	c
4
	xor	c, d
21
	xor	c, d
5
	and	b, c
22
	and	b, c
Line 42... Line 59...
42
	pop	b
59
	pop	b
43
	add	a, b
60
	add	a, b
44
}
61
}
Line 45... Line 62...
45
 
62
 
46
 
-
 
47
proc crash.md5 _md5, _data, _len, _callback, _msglen
-
 
48
locals
-
 
49
	final	rd 1
-
 
50
endl
-
 
51
	mov	[final], 0
-
 
52
  .first:
-
 
53
	mov	eax, [_msglen]
-
 
54
	mov	ecx, [_len]
-
 
55
	add	[eax], ecx
-
 
56
	mov	esi, [_data]
-
 
57
	test	ecx, ecx
-
 
58
	jz	.callback
-
 
59
  .begin:
-
 
60
	sub	[_len], 64
-
 
61
	jnc	@f
-
 
62
	add	[_len], 64
-
 
63
	jmp	.endofblock
63
 
64
    @@:
64
proc crash.md5 _md5, _data
65
	mov	edi, [_md5]
65
	mov	edi, [_md5]
66
	mov	eax, [edi + 0x0]
66
	mov	eax, [edi + 0x0]
67
	mov	ebx, [edi + 0x4]
67
	mov	ebx, [edi + 0x4]
Line 140... Line 140...
140
	add	[edi + 0x0], eax
140
	add	[edi + 0x0], eax
141
	add	[edi + 0x4], ebx
141
	add	[edi + 0x4], ebx
142
	add	[edi + 0x8], ecx
142
	add	[edi + 0x8], ecx
143
	add	[edi + 0xc], edx
143
	add	[edi + 0xc], edx
144
	add	esi, 64
144
	add	esi, 64
145
	jmp	.begin
-
 
146
  .endofblock:
-
 
147
	cmp	[final], 1
-
 
148
	je	.quit
-
 
149
 
145
 
150
  .callback:
-
 
151
	mov	eax, [_callback]
-
 
152
	test	eax, eax
-
 
153
	jz	@f
-
 
154
	call	eax
-
 
155
	test	eax, eax
-
 
156
	jz	@f
-
 
157
	mov	[_len], eax
-
 
158
	jmp	.first
-
 
159
    @@:
-
 
160
 
-
 
161
	mov	edi, [_data]
-
 
162
	mov	ecx, [_len]
-
 
163
	rep	movsb
-
 
164
	mov	eax, [_msglen]
-
 
165
	mov	eax, [eax]
-
 
166
	and	eax, 63
-
 
167
	mov	ecx, 56
-
 
168
	sub	ecx, eax
-
 
169
	ja	@f
-
 
170
	add	ecx, 64
-
 
171
    @@:
-
 
172
	add	[_len], ecx
-
 
173
	mov	byte[edi], 0x80
-
 
174
	add	edi, 1
-
 
175
	sub	ecx, 1
-
 
176
	mov	al, 0
-
 
177
	rep	stosb
-
 
178
	mov	eax, [_msglen]
-
 
179
	mov	eax, [eax]
-
 
180
	mov	edx, 8
-
 
181
	mul	edx
-
 
182
	mov	dword[edi], eax
-
 
183
	mov	dword[edi + 4], edx
-
 
184
	add	[_len], 8
-
 
185
	mov	[final], 1
-
 
186
	jmp	.first
-
 
187
  .quit:
-
 
188
	ret
146
	ret
189
endp
147
endp