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-2014,2016,2019 Ivan Baravy (dunkaist)
3
; Copyright (C) <2012-2014,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 .
Line -... Line 18...
-
 
18
 
Line -... Line 19...
-
 
19
LIBCRASH_ALIGN = 16     ; align your data for speed
17
 
20
 
18
 
-
 
19
LIBCRASH_CRC32          = 0
21
; hash IDs
20
LIBCRASH_MD4            = 1
22
LIBCRASH_CRC32          = 0
21
LIBCRASH_MD5            = 2
23
LIBCRASH_MD5            = 1
22
LIBCRASH_SHA1           = 3
24
LIBCRASH_SHA1           = 2
23
LIBCRASH_SHA224         = 4
25
LIBCRASH_SHA2_224       = 3
24
LIBCRASH_SHA256         = 5
26
LIBCRASH_SHA2_256       = 4
25
LIBCRASH_SHA384         = 6
27
LIBCRASH_SHA2_384       = 5
26
LIBCRASH_SHA512         = 7
28
LIBCRASH_SHA2_512       = 6
27
LIBCRASH_SHA3_224       = 8
29
LIBCRASH_SHA3_224       = 7
28
LIBCRASH_SHA3_256       = 9
30
LIBCRASH_SHA3_256       = 8
29
LIBCRASH_SHA3_384       = 10
-
 
30
LIBCRASH_SHA3_512       = 11
-
 
31
LIBCRASH_LAST           = 11
31
LIBCRASH_SHA3_384       = 9
32
 
32
LIBCRASH_SHA3_512       = 10
33
 
33
 
34
struct crash_item
-
 
35
        init    dd ?
-
 
36
        update  dd ?
34
; mac IDs
37
        final   dd ?
35
LIBCRASH_POLY1305       = 0
38
        oneshot dd ?
-
 
39
        len_out dd ?
36
LIBCRASH_HMAC_SHA2_256  = 1
40
ends
37
LIBCRASH_HMAC_SHA2_512  = 2
41
 
38
 
42
struct crash_ctx
-
 
43
        hash rb 1024    ; context starts with hash data
-
 
44
ends
-
 
45
 
39
; cipher IDs
46
 
40
LIBCRASH_CHACHA20       = 0
47
CRC32_HASH_SIZE     = 4
41
LIBCRASH_AES_256_CTR    = 1
48
CRC32_BLOCK_SIZE    = 1
42
LIBCRASH_AES_256_CBC    = 2
49
 
43
 
50
MD4_HASH_SIZE       = 16
-
 
51
MD4_BLOCK_SIZE      = 64
44
; cipher flags for crash_crypt
52
 
45
LIBCRASH_CIPHER_ENCRYPT = 0000b
53
MD5_HASH_SIZE       = 16
46
LIBCRASH_CIPHER_DECRYPT = 0001b
-
 
47
LIBCRASH_CIPHER_PADDING = 0010b ; PKCS#5
54
MD5_BLOCK_SIZE      = 64
48
 
55
 
49
; cipher output can be larger than input, e.g. for CBC mode with padding
56
SHA1_HASH_SIZE      = 20
50
CBC128_MAX_PAD_LEN = 128/8
57
SHA1_BLOCK_SIZE     = 64
51
LIBCRASH_MAX_PAD_LEN = CBC128_MAX_PAD_LEN
58
 
52
 
59
SHA224_HASH_SIZE    = 28
-
 
60
SHA224_BLOCK_SIZE   = 64
53
CRC32_LEN    = 4
61
 
54
MD5_LEN      = 16
62
SHA256_HASH_SIZE    = 32
-
 
63
SHA256_BLOCK_SIZE   = 64
55
SHA1_LEN     = 20
64
 
56
SHA2_224_LEN = 28
65
SHA384_HASH_SIZE    = 48
-
 
66
SHA384_BLOCK_SIZE   = 128
57
SHA2_256_LEN = 32
67
 
58
SHA2_384_LEN = 48
68
SHA512_HASH_SIZE    = 64
-
 
69
SHA512_BLOCK_SIZE   = 128
59
SHA2_512_LEN = 64
70
 
60
SHA3_224_LEN = 28
71
SHA3_224_HASH_SIZE  = 28
-
 
72
SHA3_224_BLOCK_SIZE = 144
61
SHA3_256_LEN = 32
73
 
62
SHA3_384_LEN = 48
74
SHA3_256_HASH_SIZE  = 32
63
SHA3_512_LEN = 64
75
SHA3_256_BLOCK_SIZE = 136
64
MAX_HASH_LEN = SHA3_512_LEN
-
 
65
 
76
 
66
POLY1305_LEN = 16
Line 77... Line 67...
77
SHA3_384_HASH_SIZE  = 48
67
HMAC_SHA2_256_LEN = SHA2_256_LEN
78
SHA3_384_BLOCK_SIZE = 104
-