Subversion Repositories Kolibri OS

Rev

Rev 6465 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6465 Rev 7698
Line 1... Line 1...
1
;    libcrash -- cryptographic hash functions
1
;    libcrash -- cryptographic hash functions
2
;
2
;
3
;    Copyright (C) 2012-2014,2016 Ivan Baravy (dunkaist)
3
;    Copyright (C) 2012-2014,2016,2019 Ivan Baravy (dunkaist)
4
;
4
;
5
;    This program is free software: you can redistribute it and/or modify
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
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
7
;    the Free Software Foundation, either version 3 of the License, or
8
;    (at your option) any later version.
8
;    (at your option) any later version.
Line 33... Line 33...
33
 
33
 
34
struct crash_item
34
struct crash_item
35
        init    dd ?
35
        init    dd ?
36
        update  dd ?
36
        update  dd ?
-
 
37
        final   dd ?
37
        final   dd ?
38
        oneshot dd ?
38
        len_out dd ?
39
        len_out dd ?
Line 39... Line -...
39
ends
-
 
40
 
-
 
41
; CRC32
-
 
42
 
-
 
43
CRC32_HASH_SIZE = 4
-
 
44
CRC32_ALIGN = 4
-
 
45
CRC32_ALIGN_MASK = CRC32_ALIGN - 1
40
ends
46
 
41
 
47
struct ctx_crc32
42
struct crash_ctx
Line 48... Line -...
48
        hash    rd 1
-
 
Line 49... Line -...
49
ends
-
 
50
 
43
        hash rb 1024    ; context starts with hash data
51
; MD4
44
ends
52
 
-
 
53
MD4_BLOCK_SIZE = 64
-
 
54
MD4_HASH_SIZE  = 16
-
 
55
MD4_ALIGN      = 4
-
 
56
MD4_ALIGN_MASK = MD4_ALIGN - 1
-
 
57
 
-
 
58
struct ctx_md4
-
 
59
        hash            rb MD4_HASH_SIZE
-
 
60
        block           rb MD4_BLOCK_SIZE
-
 
Line -... Line 45...
-
 
45
 
61
        index           rd 1
46
 
Line 62... Line -...
62
        msglen_0        rd 1
-
 
63
        msglen_1        rd 1
47
CRC32_HASH_SIZE     = 4
64
ends
48
CRC32_BLOCK_SIZE    = 1
65
 
-
 
66
; MD5
-
 
67
 
-
 
68
MD5_BLOCK_SIZE = 64
-
 
69
MD5_HASH_SIZE  = 16
-
 
70
MD5_ALIGN      = 4
-
 
71
MD5_ALIGN_MASK = MD5_ALIGN - 1
-
 
72
 
-
 
73
struct ctx_md5
-
 
74
        hash            rb MD5_HASH_SIZE
-
 
75
        block           rb MD5_BLOCK_SIZE
-
 
Line 76... Line -...
76
        index           rd 1
-
 
77
        msglen_0        rd 1
49
 
78
        msglen_1        rd 1
50
MD4_HASH_SIZE       = 16
79
ends
-
 
80
 
-
 
81
; SHA1
-
 
82
 
-
 
83
SHA1_BLOCK_SIZE = 64
-
 
84
SHA1_HASH_SIZE  = 20
-
 
85
SHA1_ALIGN      = 4
-
 
86
SHA1_ALIGN_MASK = SHA1_ALIGN - 1
-
 
87
 
-
 
88
struct ctx_sha1
-
 
89
        hash            rb SHA1_HASH_SIZE
-
 
Line 90... Line -...
90
        block           rb SHA1_BLOCK_SIZE
-
 
91
        index           rd 1
-
 
92
        msglen_0        rd 1
51
MD4_BLOCK_SIZE      = 64
93
        msglen_1        rd 1
52
 
94
ends
-
 
95
 
-
 
Line 96... Line -...
96
; SHA2
-
 
97
 
-
 
98
SHA224256_BLOCK_SIZE = 64
-
 
99
SHA224256_INIT_SIZE  = 32
-
 
100
SHA224_HASH_SIZE     = 28
-
 
101
SHA256_HASH_SIZE     = 32
-
 
102
SHA224256_ALIGN      = 4
-
 
103
SHA224256_ALIGN_MASK = SHA224256_ALIGN - 1
-
 
104
 
53
MD5_HASH_SIZE       = 16
105
struct ctx_sha224256
54
MD5_BLOCK_SIZE      = 64
Line 106... Line 55...
106
        hash            rb SHA224256_INIT_SIZE
55
 
107
        block           rb SHA224256_BLOCK_SIZE
56
SHA1_HASH_SIZE      = 20
Line 108... Line 57...
108
        index           rd 1
57
SHA1_BLOCK_SIZE     = 64
109
        msglen_0        rd 1
58
 
Line 110... Line -...
110
        msglen_1        rd 1
-
 
111
ends
-
 
112
 
-
 
113
SHA384512_BLOCK_SIZE = 128
-
 
114
SHA384512_INIT_SIZE  = 64
59
SHA224_HASH_SIZE    = 28
115
 
60
SHA224_BLOCK_SIZE   = 64
116
SHA384_HASH_SIZE     = 48
-
 
117
SHA512_HASH_SIZE     = 64
-
 
118
 
-
 
119
SHA384512_ALIGN      = 16
-
 
120
SHA384512_ALIGN_MASK = SHA384512_ALIGN - 1
-
 
121
 
-
 
122
struct ctx_sha384512
-
 
123
        hash            rb SHA384512_INIT_SIZE
-
 
124
        block           rb SHA384512_BLOCK_SIZE
-
 
125
        index           rd 1
-
 
126
        msglen_0        rd 1
-
 
127
        msglen_1        rd 1
-
 
128
        msglen_2        rd 1
-
 
129
        msglen_3        rd 1
-
 
130
                        rd 3    ; align
-
 
Line 131... Line 61...
131
        ; tmp vars
61
 
-
 
62
SHA256_HASH_SIZE    = 32
Line 132... Line 63...
132
        w               rq 80
63
SHA256_BLOCK_SIZE   = 64
133
        A               rq 1
-
 
134
        B               rq 1
64
 
135
        C               rq 1
-
 
136
        D               rq 1
-
 
137
        E               rq 1
-
 
138
        F               rq 1
-
 
139
        G               rq 1
-
 
140
        H               rq 1
-
 
141
        temp            rq 1
-
 
142
ends
-
 
143
 
-
 
144
; SHA3
-
 
145
 
-
 
146
SHA3224_BLOCK_SIZE      = 144
-
 
147
SHA3256_BLOCK_SIZE      = 136
-
 
148
SHA3384_BLOCK_SIZE      = 104
-
 
149
SHA3512_BLOCK_SIZE      = 72
-
 
150
SHA3MAX_BLOCK_SIZE      = SHA3224_BLOCK_SIZE
-
 
151
 
-
 
152
SHA3_INIT_SIZE          = 200
-
 
153
 
-
 
154
SHA3224_HASH_SIZE       = 28
-
 
155
SHA3256_HASH_SIZE       = 32
-
 
156
SHA3384_HASH_SIZE       = 48
-
 
157
SHA3512_HASH_SIZE       = 64
-
 
158
 
-
 
159
SHA3_ALIGN              = 16
-
 
160
SHA3_ALIGN_MASK         = SHA3_ALIGN-1
-
 
Line -... Line 65...
-
 
65
SHA384_HASH_SIZE    = 48
-
 
66
SHA384_BLOCK_SIZE   = 128