Subversion Repositories Kolibri OS

Rev

Rev 3115 | Go to most recent revision | Details | Compare with Previous | 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.md5.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.md5.g b, c, d
28
{
29
	push	c  d
30
	and	b, d
31
	not	d
32
	and	c, d
33
	or	b, c
34
	pop	d  c
35
}
36
 
37
macro crash.md5.h b, c, d
38
{
39
	xor	b, c
40
	xor	b, d
41
}
42
 
43
macro crash.md5.i b, c, d
44
{
45
	push	d
46
	not	d
47
	or	b, d
48
	xor	b, c
49
	pop	d
50
}
51
 
52
macro crash.md5.round func, a, b, c, d, index, shift, ac
53
{
54
	push	b
55
	func	b, c, d
56
	lea	a, [a + b + ac]
57
	add	a, [esi + index*4]
58
	rol	a, shift
59
	pop	b
60
	add	a, b
61
}
62
 
63
 
3431 dunkaist 64
proc crash.md5 _md5, _data
3115 dunkaist 65
	mov	edi, [_md5]
66
	mov	eax, [edi + 0x0]
67
	mov	ebx, [edi + 0x4]
68
	mov	ecx, [edi + 0x8]
69
	mov	edx, [edi + 0xc]
70
 
71
	crash.md5.round		crash.md5.f, eax, ebx, ecx, edx,  0,  7, 0xd76aa478
72
	crash.md5.round		crash.md5.f, edx, eax, ebx, ecx,  1, 12, 0xe8c7b756
73
	crash.md5.round		crash.md5.f, ecx, edx, eax, ebx,  2, 17, 0x242070db
74
	crash.md5.round		crash.md5.f, ebx, ecx, edx, eax,  3, 22, 0xc1bdceee
75
	crash.md5.round		crash.md5.f, eax, ebx, ecx, edx,  4,  7, 0xf57c0faf
76
	crash.md5.round		crash.md5.f, edx, eax, ebx, ecx,  5, 12, 0x4787c62a
77
	crash.md5.round		crash.md5.f, ecx, edx, eax, ebx,  6, 17, 0xa8304613
78
	crash.md5.round		crash.md5.f, ebx, ecx, edx, eax,  7, 22, 0xfd469501
79
	crash.md5.round		crash.md5.f, eax, ebx, ecx, edx,  8,  7, 0x698098d8
80
	crash.md5.round		crash.md5.f, edx, eax, ebx, ecx,  9, 12, 0x8b44f7af
81
	crash.md5.round		crash.md5.f, ecx, edx, eax, ebx, 10, 17, 0xffff5bb1
82
	crash.md5.round		crash.md5.f, ebx, ecx, edx, eax, 11, 22, 0x895cd7be
83
	crash.md5.round		crash.md5.f, eax, ebx, ecx, edx, 12,  7, 0x6b901122
84
	crash.md5.round		crash.md5.f, edx, eax, ebx, ecx, 13, 12, 0xfd987193
85
	crash.md5.round		crash.md5.f, ecx, edx, eax, ebx, 14, 17, 0xa679438e
86
	crash.md5.round		crash.md5.f, ebx, ecx, edx, eax, 15, 22, 0x49b40821
87
 
88
	crash.md5.round		crash.md5.g, eax, ebx, ecx, edx,  1,  5, 0xf61e2562
89
	crash.md5.round		crash.md5.g, edx, eax, ebx, ecx,  6,  9, 0xc040b340
90
	crash.md5.round		crash.md5.g, ecx, edx, eax, ebx, 11, 14, 0x265e5a51
91
	crash.md5.round		crash.md5.g, ebx, ecx, edx, eax,  0, 20, 0xe9b6c7aa
92
	crash.md5.round		crash.md5.g, eax, ebx, ecx, edx,  5,  5, 0xd62f105d
93
	crash.md5.round		crash.md5.g, edx, eax, ebx, ecx, 10,  9, 0x02441453
94
	crash.md5.round		crash.md5.g, ecx, edx, eax, ebx, 15, 14, 0xd8a1e681
95
	crash.md5.round		crash.md5.g, ebx, ecx, edx, eax,  4, 20, 0xe7d3fbc8
96
	crash.md5.round		crash.md5.g, eax, ebx, ecx, edx,  9,  5, 0x21e1cde6
97
	crash.md5.round		crash.md5.g, edx, eax, ebx, ecx, 14,  9, 0xc33707d6
98
	crash.md5.round		crash.md5.g, ecx, edx, eax, ebx,  3, 14, 0xf4d50d87
99
	crash.md5.round		crash.md5.g, ebx, ecx, edx, eax,  8, 20, 0x455a14ed
100
	crash.md5.round		crash.md5.g, eax, ebx, ecx, edx, 13,  5, 0xa9e3e905
101
	crash.md5.round		crash.md5.g, edx, eax, ebx, ecx,  2,  9, 0xfcefa3f8
102
	crash.md5.round		crash.md5.g, ecx, edx, eax, ebx,  7, 14, 0x676f02d9
103
	crash.md5.round		crash.md5.g, ebx, ecx, edx, eax, 12, 20, 0x8d2a4c8a
104
 
105
	crash.md5.round		crash.md5.h, eax, ebx, ecx, edx,  5,  4, 0xfffa3942
106
	crash.md5.round		crash.md5.h, edx, eax, ebx, ecx,  8, 11, 0x8771f681
107
	crash.md5.round		crash.md5.h, ecx, edx, eax, ebx, 11, 16, 0x6d9d6122
108
	crash.md5.round		crash.md5.h, ebx, ecx, edx, eax, 14, 23, 0xfde5380c
109
	crash.md5.round		crash.md5.h, eax, ebx, ecx, edx,  1,  4, 0xa4beea44
110
	crash.md5.round		crash.md5.h, edx, eax, ebx, ecx,  4, 11, 0x4bdecfa9
111
	crash.md5.round		crash.md5.h, ecx, edx, eax, ebx,  7, 16, 0xf6bb4b60
112
	crash.md5.round		crash.md5.h, ebx, ecx, edx, eax, 10, 23, 0xbebfbc70
113
	crash.md5.round		crash.md5.h, eax, ebx, ecx, edx, 13,  4, 0x289b7ec6
114
	crash.md5.round		crash.md5.h, edx, eax, ebx, ecx,  0, 11, 0xeaa127fa
115
	crash.md5.round		crash.md5.h, ecx, edx, eax, ebx,  3, 16, 0xd4ef3085
116
	crash.md5.round		crash.md5.h, ebx, ecx, edx, eax,  6, 23, 0x04881d05
117
	crash.md5.round		crash.md5.h, eax, ebx, ecx, edx,  9,  4, 0xd9d4d039
118
	crash.md5.round		crash.md5.h, edx, eax, ebx, ecx, 12, 11, 0xe6db99e5
119
	crash.md5.round		crash.md5.h, ecx, edx, eax, ebx, 15, 16, 0x1fa27cf8
120
	crash.md5.round		crash.md5.h, ebx, ecx, edx, eax,  2, 23, 0xc4ac5665
121
 
122
	crash.md5.round		crash.md5.i, eax, ebx, ecx, edx,  0,  6, 0xf4292244
123
	crash.md5.round		crash.md5.i, edx, eax, ebx, ecx,  7, 10, 0x432aff97
124
	crash.md5.round		crash.md5.i, ecx, edx, eax, ebx, 14, 15, 0xab9423a7
125
	crash.md5.round		crash.md5.i, ebx, ecx, edx, eax,  5, 21, 0xfc93a039
126
	crash.md5.round		crash.md5.i, eax, ebx, ecx, edx, 12,  6, 0x655b59c3
127
	crash.md5.round		crash.md5.i, edx, eax, ebx, ecx,  3, 10, 0x8f0ccc92
128
	crash.md5.round		crash.md5.i, ecx, edx, eax, ebx, 10, 15, 0xffeff47d
129
	crash.md5.round		crash.md5.i, ebx, ecx, edx, eax,  1, 21, 0x85845dd1
130
	crash.md5.round		crash.md5.i, eax, ebx, ecx, edx,  8,  6, 0x6fa87e4f
131
	crash.md5.round		crash.md5.i, edx, eax, ebx, ecx, 15, 10, 0xfe2ce6e0
132
	crash.md5.round		crash.md5.i, ecx, edx, eax, ebx,  6, 15, 0xa3014314
133
	crash.md5.round		crash.md5.i, ebx, ecx, edx, eax, 13, 21, 0x4e0811a1
134
	crash.md5.round		crash.md5.i, eax, ebx, ecx, edx,  4,  6, 0xf7537e82
135
	crash.md5.round		crash.md5.i, edx, eax, ebx, ecx, 11, 10, 0xbd3af235
136
	crash.md5.round		crash.md5.i, ecx, edx, eax, ebx,  2, 15, 0x2ad7d2bb
137
	crash.md5.round		crash.md5.i, ebx, ecx, edx, eax,  9, 21, 0xeb86d391
138
 
139
	mov	edi, [_md5]
140
	add	[edi + 0x0], eax
141
	add	[edi + 0x4], ebx
142
	add	[edi + 0x8], ecx
143
	add	[edi + 0xc], edx
144
	add	esi, 64
145
 
146
	ret
147
endp
148