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-2013,2016 Ivan Baravy (dunkaist)
3
;    Copyright (C) 2012-2013,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 14... Line 14...
14
;
14
;
15
;    You should have received a copy of the GNU General Public License
15
;    You should have received a copy of the GNU General Public License
16
;    along with this program.  If not, see .
16
;    along with this program.  If not, see .
Line -... Line 17...
-
 
17
 
-
 
18
 
-
 
19
SHA224256_BLOCK_SIZE = 64
-
 
20
SHA224_BLOCK_SIZE    = SHA224256_BLOCK_SIZE
-
 
21
SHA256_BLOCK_SIZE    = SHA224256_BLOCK_SIZE
-
 
22
SHA224_HASH_SIZE     = 28
-
 
23
SHA256_HASH_SIZE     = 32
-
 
24
 
-
 
25
SHA224256_INIT_SIZE  = 32
-
 
26
SHA224256_ALIGN      = 4
-
 
27
SHA224256_ALIGN_MASK = SHA224256_ALIGN - 1
-
 
28
 
-
 
29
struct ctx_sha224256
-
 
30
        hash            rb SHA224256_INIT_SIZE
-
 
31
        block           rb SHA224256_BLOCK_SIZE
-
 
32
        index           rd 1
-
 
33
        msglen_0        rd 1
-
 
34
        msglen_1        rd 1
-
 
35
ends
-
 
36
 
-
 
37
if defined sizeof.crash_ctx
-
 
38
  assert sizeof.crash_ctx >= sizeof.ctx_sha224256
-
 
39
end if
17
 
40
 
18
 
41
 
19
macro sha224256._.chn x, y, z
42
macro sha224256._.chn x, y, z
20
{
43
{
21
        mov     eax, [y]
44
        mov     eax, [y]
Line 251... Line 274...
251
        add     [edi + 0x1c], eax
274
        add     [edi + 0x1c], eax
Line 252... Line 275...
252
 
275
 
253
        ret
276
        ret
Line -... Line 277...
-
 
277
endp
-
 
278
 
254
endp
279
 
255
 
280
sha224.update = sha224256.update
256
sha256.update = sha224.update
281
sha256.update = sha224256.update
257
proc sha224.update _ctx, _msg, _size
282
proc sha224256.update _ctx, _msg, _size
258
        mov     ebx, [_ctx]
283
        mov     ebx, [_ctx]
259
        mov     ecx, [_size]
284
        mov     ecx, [_size]
Line 308... Line 333...
308
 
333
 
309
        ret
334
        ret
Line -... Line 335...
-
 
335
endp
310
endp
336
 
311
 
337
 
312
 
338
sha224.final = sha224256.final
313
sha256.final = sha224.final
339
sha256.final = sha224256.final
314
proc sha224.final _ctx
340
proc sha224256.final _ctx
315
        mov     ebx, [_ctx]
341
        mov     ebx, [_ctx]
316
        lea     edi, [ebx + ctx_sha224256.block]
342
        lea     edi, [ebx + ctx_sha224256.block]
Line 370... Line 396...
370
        jnz     @b
396
        jnz     @b
371
        ret
397
        ret
372
endp
398
endp
Line -... Line 399...
-
 
399
 
373
 
400
 
-
 
401
proc sha224.oneshot _ctx, _data, _len
-
 
402
	stdcall	sha224.init, [_ctx]
-
 
403
	stdcall	sha224.update, [_ctx], [_data], [_len]
-
 
404
	stdcall	sha224.final, [_ctx]
-
 
405
	ret
Line -... Line 406...
-
 
406
endp
-
 
407
 
-
 
408
 
-
 
409
proc sha256.oneshot _ctx, _data, _len
-
 
410
	stdcall	sha256.init, [_ctx]
-
 
411
	stdcall	sha256.update, [_ctx], [_data], [_len]
-
 
412
	stdcall	sha256.final, [_ctx]
-
 
413
	ret
-
 
414
endp
-
 
415
 
374
 
416
 
375
align SHA224256_ALIGN
417
iglobal
Line 376... Line 418...
376
 
418
align SHA224256_ALIGN
377
sha224._.hash_init      dd 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,\
419
sha224._.hash_init      dd 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,\
Line 394... Line 436...
394
                           0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\
436
                           0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\
395
                           0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,\
437
                           0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,\
396
                           0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\
438
                           0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\
397
                           0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\
439
                           0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\
398
                           0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
440
                           0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
399
441
endg