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
SHA384512_BLOCK_SIZE = 128
-
 
20
SHA384_BLOCK_SIZE    = SHA384512_BLOCK_SIZE
-
 
21
SHA512_BLOCK_SIZE    = SHA384512_BLOCK_SIZE
-
 
22
SHA384_HASH_SIZE     = 48
-
 
23
SHA512_HASH_SIZE     = 64
-
 
24
 
-
 
25
SHA384512_INIT_SIZE  = 64
-
 
26
SHA384512_ALIGN      = 16
-
 
27
SHA384512_ALIGN_MASK = SHA384512_ALIGN - 1
-
 
28
 
-
 
29
struct ctx_sha384512
-
 
30
        hash            rb SHA384512_INIT_SIZE
-
 
31
        block           rb SHA384512_BLOCK_SIZE
-
 
32
        index           rd 1
-
 
33
        msglen_0        rd 1
-
 
34
        msglen_1        rd 1
-
 
35
        msglen_2        rd 1
-
 
36
        msglen_3        rd 1
-
 
37
                        rd 3    ; align
-
 
38
        ; tmp vars
-
 
39
        w               rq 80
-
 
40
        A               rq 1
-
 
41
        B               rq 1
-
 
42
        C               rq 1
-
 
43
        D               rq 1
-
 
44
        E               rq 1
-
 
45
        F               rq 1
-
 
46
        G               rq 1
-
 
47
        H               rq 1
-
 
48
        temp            rq 1
-
 
49
ends
-
 
50
 
-
 
51
if defined sizeof.crash_ctx
-
 
52
  assert sizeof.crash_ctx >= sizeof.ctx_sha384512
17
 
53
end if
18
 
54
 
19
macro sha384512._.chn x, y, z
55
macro sha384512._.chn x, y, z
20
{
56
{
21
        movq    mm0, [y]
57
        movq    mm0, [y]
Line 316... Line 352...
316
 
352
 
317
        ret
353
        ret
318
restore w,A,B,C,D,E,F,G,H,temp
354
restore w,A,B,C,D,E,F,G,H,temp
Line -... Line 355...
-
 
355
endp
-
 
356
 
319
endp
357
 
320
 
358
sha384.update = sha384512.update
321
sha512.update = sha384.update
359
sha512.update = sha384512.update
322
proc sha384.update _ctx, _msg, _size
360
proc sha384512.update _ctx, _msg, _size
323
        mov     ebx, [_ctx]
361
        mov     ebx, [_ctx]
324
        mov     ecx, [_size]
362
        mov     ecx, [_size]
325
        add     [ebx + ctx_sha384512.msglen_0], ecx
363
        add     [ebx + ctx_sha384512.msglen_0], ecx
Line 375... Line 413...
375
 
413
 
376
        ret
414
        ret
Line -... Line 415...
-
 
415
endp
377
endp
416
 
378
 
417
 
379
 
418
sha384.final = sha384512.final
380
sha512.final = sha384.final
419
sha512.final = sha384512.final
381
proc sha384.final _ctx
420
proc sha384512.final _ctx
382
        mov     ebx, [_ctx]
421
        mov     ebx, [_ctx]
383
        lea     edi, [ebx + ctx_sha384512.block]
422
        lea     edi, [ebx + ctx_sha384512.block]
Line 454... Line 493...
454
        emms
493
        emms
455
        ret
494
        ret
456
endp
495
endp
Line -... Line 496...
-
 
496
 
457
 
497
 
-
 
498
proc sha384.oneshot _ctx, _data, _len
-
 
499
	stdcall	sha384.init, [_ctx]
-
 
500
	stdcall	sha384.update, [_ctx], [_data], [_len]
-
 
501
	stdcall	sha384.final, [_ctx]
-
 
502
	ret
Line -... Line 503...
-
 
503
endp
-
 
504
 
-
 
505
 
-
 
506
proc sha512.oneshot _ctx, _data, _len
-
 
507
	stdcall	sha512.init, [_ctx]
-
 
508
	stdcall	sha512.update, [_ctx], [_data], [_len]
-
 
509
	stdcall	sha512.final, [_ctx]
-
 
510
	ret
-
 
511
endp
-
 
512
 
458
 
513
 
459
align SHA384512_ALIGN
514
iglobal
460
 
515
align SHA384512_ALIGN
461
sha384._.hash_init      dq 0xcbbb9d5dc1059ed8, 0x629a292a367cd507,\
516
sha384._.hash_init      dq 0xcbbb9d5dc1059ed8, 0x629a292a367cd507,\
Line 506... Line 561...
506
                           0x113f9804bef90dae, 0x1b710b35131c471b,\
561
                           0x113f9804bef90dae, 0x1b710b35131c471b,\
507
                           0x28db77f523047d84, 0x32caab7b40c72493,\
562
                           0x28db77f523047d84, 0x32caab7b40c72493,\
508
                           0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c,\
563
                           0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c,\
509
                           0x4cc5d4becb3e42b6, 0x597f299cfc657e2a,\
564
                           0x4cc5d4becb3e42b6, 0x597f299cfc657e2a,\
510
                           0x5fcb6fab3ad6faec, 0x6c44198c4a475817
565
                           0x5fcb6fab3ad6faec, 0x6c44198c4a475817
511
566
endg