libcrash: add sha3 (keccak) hashes of length 224, 256, 384, 512; update crashtest example

git-svn-id: svn://kolibrios.org@3532 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
2013-05-24 15:27:40 +00:00
parent 55496cc735
commit f3454dcf95
4 changed files with 524 additions and 123 deletions

View File

@@ -7,9 +7,9 @@ include '../../../../proc32.inc'
include '../../../../macros.inc'
include '../../../../dll.inc'
;include '../../../../debug.inc'
include '../../../../develop/libraries/libs-dev/libio/libio.inc'
include 'libcrash.inc'
BUFFER_SIZE = 8192
BUFFER_SIZE = 4096
start:
@@ -19,38 +19,6 @@ start:
or eax, eax
jnz quit
invoke file.open, this_file_name, O_READ
or eax, eax
jz quit
mov [fh], eax
invoke file.size, this_file_name
mov [file_len], ebx
stdcall mem.Alloc, ebx
or eax, eax
jz quit
mov [file_data], eax
invoke file.read, [fh], eax, [file_len]
cmp eax, -1
je quit
cmp eax, [file_len]
jne quit
invoke file.close, [fh]
inc eax
jz quit
stdcall mem.Free, [file_data]
test eax, eax
jz quit
invoke crash.hash, LIBCRASH_SHA512, hash, data_buffer, 0, update_data_buffer, msglen
invoke crash.bin2hex, hash, hex, LIBCRASH_SHA512
still:
mcall 10
dec eax
@@ -67,9 +35,33 @@ button:
redraw:
mcall 12, 1
mcall 0, <0,800>, <0,100>, 0x34000000, 0x80000000, window_title
mcall 0, <0,900>, <0,150>, 0x34000000, 0x80000000, window_title
mcall 4, 0, 0x40ffffff, hex, 128, 0
mcall 4, < 0, 0>, 0xc0ffffff, message, , 0
mov [hid], 0
mov [text_pos_y], 10
mov [hash_name], hash_strings
.next_hash:
mov dword[f70_buf + 4], 0
mov dword[msglen], 0
mov edi, hex
xor eax, eax
mov ecx, 1024/4
rep stosd
invoke crash.hash, [hid], hash, data_buffer, 0, update_data_buffer, msglen
invoke crash.bin2hex, hash, hex, [hid]
mov ebx, [text_pos_y]
mcall 4, , 0xc0ffffff, [hash_name], , 0
mov ebx, [text_pos_y]
add ebx, 66 SHL 16
mcall 4, , 0x40ffffff, hex, 128, 0
add [text_pos_y], 10
add [hash_name], 12 ; lenght of hash_strings item
inc [hid]
cmp [hid], LIBCRASH_SHA3_512
jng .next_hash
mcall 12, 2
jmp still
@@ -83,23 +75,40 @@ quit:
mcall -1
proc update_data_buffer
proc update_data_buffer _left
mov eax, data_buffer
add eax, [_left]
mov dword[f70_buf + 16], eax
mov eax, BUFFER_SIZE
sub eax, [_left]
mov dword[f70_buf + 12], eax
mcall 70, f70_buf
mov eax, ebx
cmp eax, -1
jne @f
inc eax
@@:
add dword[f70_buf + 4], BUFFER_SIZE
add dword[f70_buf + 4], eax
ret
endp
szZ window_title ,'libcrash example'
szZ window_title ,'libcrash example'
sz msg_few_args , '2 arguments required',0x0a
sz msg_bad_hash_type , 'invalid hash type',0x0a
sz msg_file_not_found , 'file not found: '
szZ message , 'hash sums of this file'
hash_strings:
md4 db 'md4 : ',0
md5 db 'md5 : ',0
sha1 db 'sha1 : ',0
sha224 db 'sha224 : ',0
sha256 db 'sha256 : ',0
sha384 db 'sha384 : ',0
sha512 db 'sha512 : ',0
sha3_224 db 'sha3-224 : ',0
sha3_256 db 'sha3-256 : ',0
sha3_384 db 'sha3-384 : ',0
sha3_512 db 'sha3-512 : ',0
f70_buf:
funcnum dd 0
@@ -110,37 +119,27 @@ f70_buf:
res2 db 0
fname dd this_file_name
align 4
@IMPORT:
library \
libio , 'libio.obj' , \
libcrash, 'libcrash.obj'
import libio , \
libio.init , 'lib_init' , \
file.size , 'file_size' , \
file.open , 'file_open' , \
file.read , 'file_read' , \
file.close , 'file_close'
import libcrash , \
libcrash.init , 'lib_init' , \
crash.hash , 'crash_hash' , \
crash.bin2hex , 'crash_bin2hex'
i_end:
hash rd 16
hash_name rd 1
text_pos_y rd 1
hash rd 50
hid rd 1 ; hash id
msglen rd 1
fd rd 1
fh rd 1
data_length rd 1
hex rb 1024
data_buffer rb BUFFER_SIZE
file_data rd 1
file_len rd 1
this_file_name rb 4096
rb 0x400 ;stack
rb 0x800 ;stack
e_end: