Subversion Repositories Kolibri OS

Rev

Rev 7698 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7698 Rev 9216
Line 1... Line 1...
1
;    libcrash -- cryptographic hash functions
1
; libcrash -- cryptographic hash (and other) functions
2
;
2
;
3
;    Copyright (C) 2012-2013,2016,2019 Ivan Baravy (dunkaist)
3
; Copyright (C) <2012-2013,2016,2019,2021> Ivan Baravy
4
;
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.
5
; SPDX-License-Identifier: GPL-2.0-or-later
9
;
6
;
10
;    This program is distributed in the hope that it will be useful,
7
; This program is free software: you can redistribute it and/or modify it under
11
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
8
; the terms of the GNU General Public License as published by the Free Software
12
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9
; Foundation, either version 2 of the License, or (at your option) any later
13
;    GNU General Public License for more details.
10
; version.
14
;
11
;
-
 
12
; This program is distributed in the hope that it will be useful, but WITHOUT
-
 
13
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-
 
14
; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
 
15
;
15
;    You should have received a copy of the GNU General Public License
16
; You should have received a copy of the GNU General Public License along with
16
;    along with this program.  If not, see .
17
; this program. If not, see .
17
 
-
 
Line 18... Line -...
18
 
-
 
19
MD5_HASH_SIZE  = 16
18
 
Line 20... Line 19...
20
MD5_BLOCK_SIZE = 64
19
MD5_BLOCK_SIZE = 64
21
 
20
 
Line 22... Line 21...
22
MD5_ALIGN      = 4
21
MD5_ALIGN      = 4
23
MD5_ALIGN_MASK = MD5_ALIGN - 1
22
MD5_ALIGN_MASK = MD5_ALIGN - 1
24
 
23
 
25
struct ctx_md5
24
struct ctx_md5
26
        hash            rb MD5_HASH_SIZE
25
        hash            rb MD5_LEN
27
        block           rb MD5_BLOCK_SIZE
26
        block           rb MD5_BLOCK_SIZE
28
        index           rd 1
27
        index           rd 1
Line 29... Line -...
29
        msglen_0        rd 1
-
 
30
        msglen_1        rd 1
28
        msglen_0        rd 1
31
ends
-
 
Line 32... Line 29...
32
 
29
        msglen_1        rd 1
33
if defined sizeof.crash_ctx
30
ends
34
  assert sizeof.crash_ctx >= sizeof.ctx_md5
31
 
35
end if
32
assert sizeof.ctx_md5 <= LIBCRASH_CTX_LEN
Line 78... Line 75...
78
        pop     b
75
        pop     b
79
        add     a, b
76
        add     a, b
80
}
77
}
Line 81... Line 78...
81
 
78
 
82
 
79
 
83
proc md5.init _ctx
80
proc md5.init uses ebx esi edi, _ctx
84
        mov     ebx, [_ctx]
81
        mov     ebx, [_ctx]
85
        lea     edi, [ebx + ctx_md5.hash]
82
        lea     edi, [ebx + ctx_md5.hash]
86
        mov     esi, md5._.hash_init
83
        mov     esi, md5._.hash_init
87
        mov     ecx, MD5_HASH_SIZE/4
84
        mov     ecx, MD5_LEN/4
88
        rep     movsd
85
        rep movsd
89
        xor     eax, eax
86
        xor     eax, eax
90
        mov     [ebx + ctx_md5.index], eax
87
        mov     [ebx + ctx_md5.index], eax
Line 178... Line 175...
178
 
175
 
179
        ret
176
        ret
Line 180... Line 177...
180
endp
177
endp
181
 
178
 
182
 
179
 
183
proc md5.update _ctx, _msg, _size
180
proc md5.update uses ebx esi edi, _ctx, _msg, _size
184
        mov     ebx, [_ctx]
181
        mov     ebx, [_ctx]
Line 234... Line 231...
234
 
231
 
235
        ret
232
        ret
Line 236... Line 233...
236
endp
233
endp
237
 
234
 
238
 
235
 
239
proc md5.final _ctx
236
proc md5.finish uses ebx esi edi, _ctx
240
        mov     ebx, [_ctx]
237
        mov     ebx, [_ctx]
241
        lea     edi, [ebx + ctx_md5.block]
238
        lea     edi, [ebx + ctx_md5.block]
Line 278... Line 275...
278
 
275
 
279
 
276
 
280
proc md5.oneshot _ctx, _data, _len
277
proc md5.oneshot _ctx, _data, _len
281
	stdcall	md5.init, [_ctx]
278
        stdcall md5.init, [_ctx]
282
	stdcall	md5.update, [_ctx], [_data], [_len]
279
        stdcall md5.update, [_ctx], [_data], [_len]
283
	stdcall	md5.final, [_ctx]
280
        stdcall md5.finish, [_ctx]
Line 284... Line 281...
284
	ret
281
        ret