Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. proc crash.sha1.f
  2.         push    ebx ecx edx
  3.         xor     ecx, edx
  4.         and     ebx, ecx
  5.         xor     ebx, edx
  6.         mov     esi, ebx
  7.         pop     edx ecx ebx
  8.         ret
  9. endp
  10.  
  11. proc crash.sha1.g
  12.         push    ebx ecx edx
  13.         xor     ebx, ecx
  14.         xor     ebx, edx
  15.         mov     esi, ebx
  16.         pop     edx ecx ebx
  17.         ret
  18. endp
  19.  
  20. proc crash.sha1.h
  21.         push    ebx ecx edx
  22.         mov     esi, ebx
  23.         and     ebx, ecx
  24.         and     ecx, edx
  25.         and     esi, edx
  26.         or      ebx, ecx
  27.         or      esi, ebx
  28.         pop     edx ecx ebx
  29.         ret
  30. endp
  31.  
  32.  
  33. proc crash.sha1 _sha1, _data, _len, _callback, _msglen
  34. locals
  35.         final   rd 1
  36.         temp    rd 1
  37.         counter rd 1
  38.         summand rd 1
  39.         shafunc rd 1
  40.         w       rd 80
  41. endl
  42.         mov     [final], 0
  43.   .first:
  44.         mov     eax, [_msglen]
  45.         mov     ecx, [_len]
  46.         add     [eax], ecx
  47.         mov     esi, [_data]
  48.         test    ecx, ecx
  49.         jz      .callback
  50.   .begin:
  51.         sub     [_len], 64
  52.         jnc     @f
  53.         add     [_len], 64
  54.         jmp     .endofblock
  55.     @@:
  56.         lea     edi, [w]
  57.         xor     ecx, ecx
  58.     @@:
  59.         mov     eax, [esi]
  60.         add     esi, 4
  61.         bswap   eax
  62.         mov     [edi], eax
  63.         add     edi, 4
  64.         add     ecx, 1
  65.         cmp     ecx, 16
  66.         jne     @b
  67.     @@:
  68.         mov     eax, [w + (ecx -  3)*4]
  69.         xor     eax, [w + (ecx -  8)*4]
  70.         xor     eax, [w + (ecx - 14)*4]
  71.         xor     eax, [w + (ecx - 16)*4]
  72.         rol     eax, 1
  73.         mov     [w + ecx*4], eax
  74.         add     ecx, 1
  75.         cmp     ecx, 80
  76.         jne     @b
  77.  
  78.         mov     edi, [_sha1]
  79.         mov     eax, [edi + 0x00]
  80.         mov     ebx, [edi + 0x04]
  81.         mov     ecx, [edi + 0x08]
  82.         mov     edx, [edi + 0x0c]
  83.         mov     edi, [edi + 0x10]
  84.  
  85.         push    esi
  86.  
  87.         mov     [counter], 0
  88.         mov     [summand], 0x5a827999
  89.         mov     [shafunc], crash.sha1.f
  90.     @@:
  91.         mov     esi, eax
  92.         rol     esi, 5
  93.         mov     [temp], esi
  94.         call    [shafunc]
  95.  
  96.         add     esi, edi
  97.         add     [temp], esi
  98.         mov     esi, [counter]
  99.         mov     esi, [w + esi*4]
  100.         add     esi, [summand]
  101.         add     [temp], esi
  102.  
  103.         mov     edi, edx
  104.         mov     edx, ecx
  105.         mov     ecx, ebx
  106.         rol     ecx, 30
  107.         mov     ebx, eax
  108.         mov     eax, [temp]
  109.  
  110.         add     [counter], 1
  111.         cmp     [counter], 20
  112.         jne     @b
  113.  
  114.         mov     [summand], 0x6ed9eba1
  115.         mov     [shafunc], crash.sha1.g
  116.     @@:
  117.         mov     esi, eax
  118.         rol     esi, 5
  119.         mov     [temp], esi
  120.         call    dword[shafunc]
  121.  
  122.         add     esi, edi
  123.         add     [temp], esi
  124.         mov     esi, [counter]
  125.         mov     esi, [w + esi*4]
  126.         add     esi, [summand]
  127.         add     [temp], esi
  128.  
  129.         mov     edi, edx
  130.         mov     edx, ecx
  131.         mov     ecx, ebx
  132.         rol     ecx, 30
  133.         mov     ebx, eax
  134.         mov     eax, [temp]
  135.  
  136.         add     [counter], 1
  137.         cmp     [counter], 40
  138.         jne     @b
  139.  
  140.         mov     [summand], 0x8f1bbcdc
  141.         mov     [shafunc], crash.sha1.h
  142.     @@:
  143.         mov     esi, eax
  144.         rol     esi, 5
  145.         mov     [temp], esi
  146.         call    dword[shafunc]
  147.  
  148.         add     esi, edi
  149.         add     [temp], esi
  150.         mov     esi, [counter]
  151.         mov     esi, [w + esi*4]
  152.         add     esi, [summand]
  153.         add     [temp], esi
  154.  
  155.         mov     edi, edx
  156.         mov     edx, ecx
  157.         mov     ecx, ebx
  158.         rol     ecx, 30
  159.         mov     ebx, eax
  160.         mov     eax, [temp]
  161.  
  162.         add     [counter], 1
  163.         cmp     [counter], 60
  164.         jne     @b
  165.  
  166.         mov     [summand], 0xca62c1d6
  167.         mov     [shafunc], crash.sha1.g
  168.     @@:
  169.         mov     esi, eax
  170.         rol     esi, 5
  171.         mov     [temp], esi
  172.         call    dword[shafunc]
  173.  
  174.         add     esi, edi
  175.         add     [temp], esi
  176.         mov     esi, [counter]
  177.         mov     esi, [w + esi*4]
  178.         add     esi, [summand]
  179.         add     [temp], esi
  180.  
  181.         mov     edi, edx
  182.         mov     edx, ecx
  183.         mov     ecx, ebx
  184.         rol     ecx, 30
  185.         mov     ebx, eax
  186.         mov     eax, [temp]
  187.  
  188.         add     [counter], 1
  189.         cmp     [counter], 80
  190.         jne     @b
  191.  
  192.         pop     esi
  193.  
  194.         mov     [temp], edi
  195.         mov     edi, [_sha1]
  196.         add     [edi + 0x00], eax
  197.         add     [edi + 0x04], ebx
  198.         add     [edi + 0x08], ecx
  199.         add     [edi + 0x0c], edx
  200.         mov     eax, [temp]
  201.         add     [edi + 0x10], eax
  202.         jmp     .begin
  203.   .endofblock:
  204.         cmp     [final], 1
  205.         je      .quit
  206.  
  207.   .callback:
  208.         mov     eax, [_callback]
  209.         test    eax, eax
  210.         jz      @f
  211.         call    eax
  212.         test    eax, eax
  213.         jz      @f
  214.         mov     [_len], eax
  215.         jmp     .first
  216.     @@:
  217.  
  218.         mov     edi, [_data]
  219.         mov     ecx, [_len]
  220.         rep     movsb
  221.         mov     eax, [_msglen]
  222.         mov     eax, [eax]
  223.         and     eax, 63
  224.         mov     ecx, 56
  225.         sub     ecx, eax
  226.         ja      @f
  227.         add     ecx, 64
  228.     @@:
  229.         add     [_len], ecx
  230.         mov     byte[edi], 0x80
  231.         add     edi, 1
  232.         sub     ecx, 1
  233.         mov     al, 0
  234.         rep     stosb
  235.         mov     eax, [_msglen]
  236.         mov     eax, [eax]
  237.         mov     edx, 8
  238.         mul     edx
  239.         bswap   eax
  240.         bswap   edx
  241.         mov     dword[edi], edx
  242.         mov     dword[edi + 4], eax
  243.         add     [_len], 8
  244.         mov     [final], 1
  245.         jmp     .first
  246.   .quit:
  247.         mov     esi, [_sha1]
  248.         mov     edi, esi
  249.         mov     ecx, 5
  250.     @@:
  251.         lodsd
  252.         bswap   eax
  253.         stosd
  254.         sub     ecx, 1
  255.         jnz     @b
  256.         ret
  257. endp
  258.  
  259.