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...
18
 
18
 
Line 19... Line 19...
19
CRC32_HASH_SIZE = 4
19
CRC32_BLOCK_SIZE = 1
20
 
20
 
Line 21... Line 21...
21
CRC32_ALIGN = 4
21
CRC32_ALIGN = 4
22
CRC32_ALIGN_MASK = CRC32_ALIGN - 1
22
CRC32_ALIGN_MASK = CRC32_ALIGN - 1
23
 
23
 
Line 24... Line -...
24
struct ctx_crc32
-
 
25
        hash    rd 1
24
struct ctx_crc32
26
ends
-
 
Line 27... Line 25...
27
 
25
        hash    rd 1
28
if defined sizeof.crash_ctx
26
ends
29
  assert sizeof.crash_ctx >= sizeof.ctx_crc32
27
 
30
end if
28
assert sizeof.ctx_crc32 <= LIBCRASH_CTX_LEN
31
 
29
 
32
proc crc32.init _ctx
30
proc crc32.init uses ebx esi edi, _ctx
33
        mov     ebx, [_ctx]
31
        mov     ebx, [_ctx]
34
        lea     edi, [ebx + ctx_crc32.hash]
32
        lea     edi, [ebx + ctx_crc32.hash]
Line 35... Line 33...
35
        mov     esi, crc32._.hash_init
33
        mov     esi, crc32._.hash_init
36
        mov     ecx, 1
34
        mov     ecx, 1
37
        rep     movsd
35
        rep movsd
38
        ret
36
        ret
39
endp
37
endp
40
 
38
 
Line 60... Line 58...
60
  .quit:
58
.quit:
61
        ret
59
        ret
62
endp
60
endp
Line 63... Line 61...
63
 
61
 
64
 
62
 
65
proc crc32.final _ctx
63
proc crc32.finish uses ebx esi edi, _ctx
66
        mov     ebx, [_ctx]
64
        mov     ebx, [_ctx]
67
        lea     esi, [ebx + ctx_crc32.hash]
65
        lea     esi, [ebx + ctx_crc32.hash]
68
        mov     edi, esi
66
        mov     edi, esi
Line 75... Line 73...
75
 
73
 
76
 
74
 
77
proc crc32.oneshot _ctx, _data, _len
75
proc crc32.oneshot _ctx, _data, _len
78
	stdcall	crc32.init, [_ctx]
76
        stdcall crc32.init, [_ctx]
79
	stdcall	crc32.update, [_ctx], [_data], [_len]
77
        stdcall crc32.update, [_ctx], [_data], [_len]
80
	stdcall	crc32.final, [_ctx]
78
        stdcall crc32.finish, [_ctx]
Line 81... Line 79...
81
	ret
79
        ret