Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3431 dunkaist 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
 
3115 dunkaist 18
macro crash.md4.f b, c, d
19
{
20
	push	c
21
	xor	c, d
22
	and	b, c
23
	xor	b, d
24
	pop	c
25
}
26
 
27
macro crash.md4.g b, c, d
28
{
29
	push	c  d
30
	mov	edi, b
31
	and	b, c
32
	and	c, d
33
	and	d, edi
34
	or	b, c
35
	or	b, d
36
	pop	d  c
37
}
38
 
39
macro crash.md4.h b, c, d
40
{
41
	xor	b, c
42
	xor	b, d
43
}
44
 
45
macro crash.md4.round func, a, b, c, d, index, shift, ac
46
{
47
	push	b
48
	func	b, c, d
49
	lea	a, [a + b + ac]
50
	add	a, [esi + index*4]
51
	rol	a, shift
52
	pop	b
53
}
54
 
55
 
3431 dunkaist 56
proc crash.md4 _md4, _data
3115 dunkaist 57
	mov	edi, [_md4]
58
	mov	eax, [edi + 0x0]
59
	mov	ebx, [edi + 0x4]
60
	mov	ecx, [edi + 0x8]
61
	mov	edx, [edi + 0xc]
62
 
63
	crash.md4.round		crash.md4.f, eax, ebx, ecx, edx,  0,  3, 0x00000000
64
	crash.md4.round		crash.md4.f, edx, eax, ebx, ecx,  1,  7, 0x00000000
65
	crash.md4.round		crash.md4.f, ecx, edx, eax, ebx,  2, 11, 0x00000000
66
	crash.md4.round		crash.md4.f, ebx, ecx, edx, eax,  3, 19, 0x00000000
67
	crash.md4.round		crash.md4.f, eax, ebx, ecx, edx,  4,  3, 0x00000000
68
	crash.md4.round		crash.md4.f, edx, eax, ebx, ecx,  5,  7, 0x00000000
69
	crash.md4.round		crash.md4.f, ecx, edx, eax, ebx,  6, 11, 0x00000000
70
	crash.md4.round		crash.md4.f, ebx, ecx, edx, eax,  7, 19, 0x00000000
71
	crash.md4.round		crash.md4.f, eax, ebx, ecx, edx,  8,  3, 0x00000000
72
	crash.md4.round		crash.md4.f, edx, eax, ebx, ecx,  9,  7, 0x00000000
73
	crash.md4.round		crash.md4.f, ecx, edx, eax, ebx, 10, 11, 0x00000000
74
	crash.md4.round		crash.md4.f, ebx, ecx, edx, eax, 11, 19, 0x00000000
75
	crash.md4.round		crash.md4.f, eax, ebx, ecx, edx, 12,  3, 0x00000000
76
	crash.md4.round		crash.md4.f, edx, eax, ebx, ecx, 13,  7, 0x00000000
77
	crash.md4.round		crash.md4.f, ecx, edx, eax, ebx, 14, 11, 0x00000000
78
	crash.md4.round		crash.md4.f, ebx, ecx, edx, eax, 15, 19, 0x00000000
79
 
80
	crash.md4.round		crash.md4.g, eax, ebx, ecx, edx,  0,  3, 0x5a827999
81
	crash.md4.round		crash.md4.g, edx, eax, ebx, ecx,  4,  5, 0x5a827999
82
	crash.md4.round		crash.md4.g, ecx, edx, eax, ebx,  8,  9, 0x5a827999
83
	crash.md4.round		crash.md4.g, ebx, ecx, edx, eax, 12, 13, 0x5a827999
84
	crash.md4.round		crash.md4.g, eax, ebx, ecx, edx,  1,  3, 0x5a827999
85
	crash.md4.round		crash.md4.g, edx, eax, ebx, ecx,  5,  5, 0x5a827999
86
	crash.md4.round		crash.md4.g, ecx, edx, eax, ebx,  9,  9, 0x5a827999
87
	crash.md4.round		crash.md4.g, ebx, ecx, edx, eax, 13, 13, 0x5a827999
88
	crash.md4.round		crash.md4.g, eax, ebx, ecx, edx,  2,  3, 0x5a827999
89
	crash.md4.round		crash.md4.g, edx, eax, ebx, ecx,  6,  5, 0x5a827999
90
	crash.md4.round		crash.md4.g, ecx, edx, eax, ebx, 10,  9, 0x5a827999
91
	crash.md4.round		crash.md4.g, ebx, ecx, edx, eax, 14, 13, 0x5a827999
92
	crash.md4.round		crash.md4.g, eax, ebx, ecx, edx,  3,  3, 0x5a827999
93
	crash.md4.round		crash.md4.g, edx, eax, ebx, ecx,  7,  5, 0x5a827999
94
	crash.md4.round		crash.md4.g, ecx, edx, eax, ebx, 11,  9, 0x5a827999
95
	crash.md4.round		crash.md4.g, ebx, ecx, edx, eax, 15, 13, 0x5a827999
96
 
97
	crash.md4.round		crash.md4.h, eax, ebx, ecx, edx,  0,  3, 0x6ed9eba1
98
	crash.md4.round		crash.md4.h, edx, eax, ebx, ecx,  8,  9, 0x6ed9eba1
99
	crash.md4.round		crash.md4.h, ecx, edx, eax, ebx,  4, 11, 0x6ed9eba1
100
	crash.md4.round		crash.md4.h, ebx, ecx, edx, eax, 12, 15, 0x6ed9eba1
101
	crash.md4.round		crash.md4.h, eax, ebx, ecx, edx,  2,  3, 0x6ed9eba1
102
	crash.md4.round		crash.md4.h, edx, eax, ebx, ecx, 10,  9, 0x6ed9eba1
103
	crash.md4.round		crash.md4.h, ecx, edx, eax, ebx,  6, 11, 0x6ed9eba1
104
	crash.md4.round		crash.md4.h, ebx, ecx, edx, eax, 14, 15, 0x6ed9eba1
105
	crash.md4.round		crash.md4.h, eax, ebx, ecx, edx,  1,  3, 0x6ed9eba1
106
	crash.md4.round		crash.md4.h, edx, eax, ebx, ecx,  9,  9, 0x6ed9eba1
107
	crash.md4.round		crash.md4.h, ecx, edx, eax, ebx,  5, 11, 0x6ed9eba1
108
	crash.md4.round		crash.md4.h, ebx, ecx, edx, eax, 13, 15, 0x6ed9eba1
109
	crash.md4.round		crash.md4.h, eax, ebx, ecx, edx,  3,  3, 0x6ed9eba1
110
	crash.md4.round		crash.md4.h, edx, eax, ebx, ecx, 11,  9, 0x6ed9eba1
111
	crash.md4.round		crash.md4.h, ecx, edx, eax, ebx,  7, 11, 0x6ed9eba1
112
	crash.md4.round		crash.md4.h, ebx, ecx, edx, eax, 15, 15, 0x6ed9eba1
113
 
114
	mov	edi, [_md4]
115
	add	[edi + 0x0], eax
116
	add	[edi + 0x4], ebx
117
	add	[edi + 0x8], ecx
118
	add	[edi + 0xc], edx
119
	add	esi, 64
120
 
121
	ret
122
endp
123