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.md4.f b, c, d
18
macro crash.md4.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 34... Line 51...
34
	rol	a, shift
51
	rol	a, shift
35
	pop	b
52
	pop	b
36
}
53
}
Line 37... Line 54...
37
 
54
 
38
 
-
 
39
proc crash.md4 _md4, _data, _len, _callback, _msglen
-
 
40
locals
-
 
41
	final	rd 1
-
 
42
endl
-
 
43
	mov	[final], 0
-
 
44
  .first:
-
 
45
	mov	eax, [_msglen]
-
 
46
	mov	ecx, [_len]
-
 
47
	add	[eax], ecx
-
 
48
	mov	esi, [_data]
-
 
49
	test	ecx, ecx
-
 
50
	jz	.callback
-
 
51
  .begin:
-
 
52
	sub	[_len], 64
-
 
53
	jnc	@f
-
 
54
	add	[_len], 64
-
 
55
	jmp	.endofblock
55
 
56
    @@:
56
proc crash.md4 _md4, _data
57
	mov	edi, [_md4]
57
	mov	edi, [_md4]
58
	mov	eax, [edi + 0x0]
58
	mov	eax, [edi + 0x0]
59
	mov	ebx, [edi + 0x4]
59
	mov	ebx, [edi + 0x4]
Line 115... Line 115...
115
	add	[edi + 0x0], eax
115
	add	[edi + 0x0], eax
116
	add	[edi + 0x4], ebx
116
	add	[edi + 0x4], ebx
117
	add	[edi + 0x8], ecx
117
	add	[edi + 0x8], ecx
118
	add	[edi + 0xc], edx
118
	add	[edi + 0xc], edx
119
	add	esi, 64
119
	add	esi, 64
120
	jmp	.begin
-
 
121
  .endofblock:
-
 
122
	cmp	[final], 1
-
 
123
	je	.quit
-
 
124
 
120
 
125
  .callback:
-
 
126
	mov	eax, [_callback]
-
 
127
	test	eax, eax
-
 
128
	jz	@f
-
 
129
	call	eax
-
 
130
	test	eax, eax
-
 
131
	jz	@f
-
 
132
	mov	[_len], eax
-
 
133
	jmp	.first
-
 
134
    @@:
-
 
135
 
-
 
136
	mov	edi, [_data]
-
 
137
	mov	ecx, [_len]
-
 
138
	rep	movsb
-
 
139
	mov	eax, [_msglen]
-
 
140
	mov	eax, [eax]
-
 
141
	and	eax, 63
-
 
142
	mov	ecx, 56
-
 
143
	sub	ecx, eax
-
 
144
	ja	@f
-
 
145
	add	ecx, 64
-
 
146
    @@:
-
 
147
	add	[_len], ecx
-
 
148
	mov	byte[edi], 0x80
-
 
149
	add	edi, 1
-
 
150
	sub	ecx, 1
-
 
151
	mov	al, 0
-
 
152
	rep	stosb
-
 
153
	mov	eax, [_msglen]
-
 
154
	mov	eax, [eax]
-
 
155
	mov	edx, 8
-
 
156
	mul	edx
-
 
157
	mov	dword[edi], eax
-
 
158
	mov	dword[edi + 4], edx
-
 
159
	add	[_len], 8
-
 
160
	mov	[final], 1
-
 
161
	jmp	.first
-
 
162
  .quit:
-
 
163
	ret
121
	ret
164
endp
122
endp