Subversion Repositories Kolibri OS

Rev

Rev 6465 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. use32
  2.     org 0x0
  3.     db  'MENUET01'
  4.     dd  0x01,start,i_end,e_end,e_end,0,this_file_name
  5.  
  6. include 'proc32.inc'
  7. include 'macros.inc'
  8. include 'dll.inc'
  9. ;include 'debug-fdo.inc'
  10. include 'libcrash.inc'
  11.  
  12. BUFFER_SIZE     = 0x1000
  13.  
  14.  
  15. start:
  16.         pushfd
  17.         pop     eax
  18. ;        or      eax, 1 SHL 18   ; Alignment Check flag, FIXME in libcrash
  19.         push    eax
  20.         popfd
  21.  
  22.         mcall   68, 11
  23.  
  24.         stdcall dll.Load, @IMPORT
  25.         or      eax, eax
  26.         jnz     quit
  27.  
  28. still:
  29.         mcall   10
  30.         dec     eax
  31.         jz      redraw
  32.         dec     eax
  33.         jz      key
  34.  
  35. button:
  36.         mcall   17
  37.         shr     eax, 8
  38.  
  39.         cmp     eax, 1
  40.         je      quit
  41.  
  42. redraw:
  43.         mcall   12, 1
  44.         mcall   0, <0,900>, <0,160>, 0x34000000, 0x80000000, window_title
  45.  
  46.         mov     [f70_buf.src], 0
  47.         invoke  crash.hash, LIBCRASH_SHA2_256, read_data, 0, bin
  48.         stdcall bin2hex, bin, SHA2_256_LEN, hex
  49.         mcall   4, <0,0>, 0xc0ffffff, hex, 0, 0
  50.  
  51.         invoke  crash.hash_oneshot, LIBCRASH_SHA2_256, ctx, 0, i_end
  52.         stdcall bin2hex, ctx, SHA2_256_LEN, hex
  53.         mcall   4, <0,10>, 0xc0ffffff, hex, 0, 0
  54.  
  55.         invoke  sha2_256.oneshot, ctx, 0, i_end
  56.         stdcall bin2hex, ctx, SHA2_256_LEN, hex
  57.         mcall   4, <0,20>, 0xc0ffffff, hex, 0, 0
  58.  
  59.         invoke  sha2_256.init, ctx
  60.         invoke  sha2_256.update, ctx, 0, 42
  61.         invoke  sha2_256.update, ctx, 42, i_end-42
  62.         invoke  sha2_256.finish, ctx
  63.         stdcall bin2hex, ctx, SHA2_256_LEN, hex
  64.         mcall   4, <0,30>, 0xc0ffffff, hex, 0, 0
  65.  
  66.         mcall   12, 2
  67.         jmp     still
  68.  
  69. key:
  70.         mcall   2
  71.         jmp     still
  72.  
  73.  
  74. quit:
  75.         mcall   -1
  76.  
  77.  
  78. proc bin2hex uses esi edi, _bin, _len, _hex
  79.         mov     esi, [_bin]
  80.         mov     edi, [_hex]
  81.         mov     ecx, [_len]
  82. .next_byte:
  83.         movzx   eax, byte[esi]
  84.         shr     al, 4
  85.         cmp     al, 10
  86.         sbb     al, 0x69
  87.         das
  88.         stosb
  89.         lodsb
  90.         and     al, 0x0f
  91.         cmp     al, 10
  92.         sbb     al, 0x69
  93.         das
  94.         stosb
  95.         loop    .next_byte
  96.         mov     byte[edi], 0
  97.         ret
  98. endp
  99.  
  100.  
  101. proc read_data uses ebx, _user, _buf, _len
  102.         mov     eax, [_buf]
  103.         mov     [f70_buf.dst], eax
  104.         mov     eax, [_len]
  105.         mov     [f70_buf.count], eax
  106.         mcall   70, f70_buf
  107.         mov     eax, ebx
  108.         cmp     eax, -1
  109.         jnz     @f
  110.         inc     eax
  111.     @@:
  112.         add     [f70_buf.src], eax
  113.         ret
  114. endp
  115.  
  116.  
  117. sz window_title,  'libcrash example',0
  118.  
  119. f70_buf:
  120.         .funcnum dd 0
  121.         .src     dd 0
  122.                  dd 0
  123.         .count   dd BUFFER_SIZE
  124.         .dst     dd data_buffer
  125.                  db 0
  126.         .fname   dd this_file_name
  127.  
  128.  
  129. align 4
  130. @IMPORT:
  131.  
  132. library                           \
  133.         libcrash, 'libcrash.obj'
  134.  
  135. import  libcrash, \
  136.         libcrash.init,         'lib_init', \
  137.         crash.hash,            'crash_hash', \
  138.         crash.hash_oneshot,    'crash_hash_oneshot', \
  139.         crash.mac,             'crash_mac', \
  140.         crash.mac_oneshot,     'crash_mac_oneshot', \
  141.         crash.crypt,           'crash_crypt', \
  142.         crash.crypt_oneshot,   'crash_crypt_oneshot', \
  143.         sha2_256.init,         'sha2_256_init', \
  144.         sha2_256.update,       'sha2_256_update', \
  145.         sha2_256.finish,       'sha2_256_finish', \
  146.         sha2_256.oneshot,      'sha2_256_oneshot', \
  147.         hmac_sha2_256.init,    'hmac_sha2_256_init', \
  148.         hmac_sha2_256.update,  'hmac_sha2_256_update', \
  149.         hmac_sha2_256.finish,  'hmac_sha2_256_finish', \
  150.         hmac_sha2_256.oneshot, 'hmac_sha2_256_oneshot', \
  151.         aes256ctr.init,        'aes256ctr_init', \
  152.         aes256ctr.update,      'aes256ctr_update', \
  153.         aes256ctr.finish,      'aes256ctr_finish', \
  154.         aes256ctr.oneshot,     'aes256ctr_oneshot'
  155.  
  156. i_end:
  157. bin             rb MAX_HASH_LEN
  158. hex             rb MAX_HASH_LEN*2+1
  159. data_buffer     rb BUFFER_SIZE
  160. this_file_name  rb 0x1000
  161. align LIBCRASH_ALIGN
  162. ctx             rb LIBCRASH_CTX_LEN
  163. rb 0x1000       ;stack
  164. e_end:
  165.