Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3430 → Rev 3431

/programs/develop/libraries/libcrash/trunk/sha224_256.asm
1,3 → 1,20
; libcrash -- cryptographic hash functions
;
; Copyright (C) 2012-2013 Ivan Baravy (dunkaist)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
 
macro chn x, y, z
{
mov eax, [y]
120,9 → 137,8
}
 
 
proc crash.sha256 _sha256, _data, _len, _callback, _msglen
proc crash.sha256 _sha256, _data
locals
final rd 1
w rd 64
A rd 1
B rd 1
133,20 → 149,6
G rd 1
H rd 1
endl
mov [final], 0
.first:
mov eax, [_msglen]
mov ecx, [_len]
add [eax], ecx
mov esi, [_data]
test ecx, ecx
jz .callback
.begin:
sub [_len], 64
jnc @f
add [_len], 64
jmp .endofblock
@@:
mov edi, [_sha256]
mov eax, [edi + 0x00]
mov [A], eax
219,60 → 221,7
mov eax, [H]
add [edi + 0x1c], eax
add esi, 64
jmp .begin
.endofblock:
cmp [final], 1
je .quit
 
.callback:
mov eax, [_callback]
test eax, eax
jz @f
call eax
test eax, eax
jz @f
mov [_len], eax
jmp .first
@@:
 
mov edi, [_data]
mov ecx, [_len]
rep movsb
mov eax, [_msglen]
mov eax, [eax]
and eax, 63
mov ecx, 56
sub ecx, eax
ja @f
add ecx, 64
@@:
add [_len], ecx
mov byte[edi], 0x80
add edi, 1
sub ecx, 1
mov al, 0
rep stosb
mov eax, [_msglen]
mov eax, [eax]
mov edx, 8
mul edx
bswap eax
bswap edx
mov dword[edi], edx
mov dword[edi + 4], eax
add [_len], 8
mov [final], 1
jmp .first
.quit:
mov esi, [_sha256]
mov edi, esi
mov ecx, 8
@@:
lodsd
bswap eax
stosd
sub ecx, 1
jnz @b
ret
endp