Subversion Repositories Kolibri OS

Rev

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

  1. macro crash.md4.f b, c, d
  2. {
  3.         push    c
  4.         xor     c, d
  5.         and     b, c
  6.         xor     b, d
  7.         pop     c
  8. }
  9.  
  10. macro crash.md4.g b, c, d
  11. {
  12.         push    c  d
  13.         mov     edi, b
  14.         and     b, c
  15.         and     c, d
  16.         and     d, edi
  17.         or      b, c
  18.         or      b, d
  19.         pop     d  c
  20. }
  21.  
  22. macro crash.md4.h b, c, d
  23. {
  24.         xor     b, c
  25.         xor     b, d
  26. }
  27.  
  28. macro crash.md4.round func, a, b, c, d, index, shift, ac
  29. {
  30.         push    b
  31.         func    b, c, d
  32.         lea     a, [a + b + ac]
  33.         add     a, [esi + index*4]
  34.         rol     a, shift
  35.         pop     b
  36. }
  37.  
  38.  
  39. proc crash.md4 _md4, _data, _len, _callback, _msglen
  40. locals
  41.         final   rd 1
  42. endl
  43.         mov     [final], 0
  44.   .first:
  45.         mov     eax, [_msglen]
  46.         mov     ecx, [_len]
  47.         add     [eax], ecx
  48.         mov     esi, [_data]
  49.         test    ecx, ecx
  50.         jz      .callback
  51.   .begin:
  52.         sub     [_len], 64
  53.         jnc     @f
  54.         add     [_len], 64
  55.         jmp     .endofblock
  56.     @@:
  57.         mov     edi, [_md4]
  58.         mov     eax, [edi + 0x0]
  59.         mov     ebx, [edi + 0x4]
  60.         mov     ecx, [edi + 0x8]
  61.         mov     edx, [edi + 0xc]
  62.  
  63.         crash.md4.round         crash.md4.f, eax, ebx, ecx, edx,  0,  3, 0x00000000
  64.         crash.md4.round         crash.md4.f, edx, eax, ebx, ecx,  1,  7, 0x00000000
  65.         crash.md4.round         crash.md4.f, ecx, edx, eax, ebx,  2, 11, 0x00000000
  66.         crash.md4.round         crash.md4.f, ebx, ecx, edx, eax,  3, 19, 0x00000000
  67.         crash.md4.round         crash.md4.f, eax, ebx, ecx, edx,  4,  3, 0x00000000
  68.         crash.md4.round         crash.md4.f, edx, eax, ebx, ecx,  5,  7, 0x00000000
  69.         crash.md4.round         crash.md4.f, ecx, edx, eax, ebx,  6, 11, 0x00000000
  70.         crash.md4.round         crash.md4.f, ebx, ecx, edx, eax,  7, 19, 0x00000000
  71.         crash.md4.round         crash.md4.f, eax, ebx, ecx, edx,  8,  3, 0x00000000
  72.         crash.md4.round         crash.md4.f, edx, eax, ebx, ecx,  9,  7, 0x00000000
  73.         crash.md4.round         crash.md4.f, ecx, edx, eax, ebx, 10, 11, 0x00000000
  74.         crash.md4.round         crash.md4.f, ebx, ecx, edx, eax, 11, 19, 0x00000000
  75.         crash.md4.round         crash.md4.f, eax, ebx, ecx, edx, 12,  3, 0x00000000
  76.         crash.md4.round         crash.md4.f, edx, eax, ebx, ecx, 13,  7, 0x00000000
  77.         crash.md4.round         crash.md4.f, ecx, edx, eax, ebx, 14, 11, 0x00000000
  78.         crash.md4.round         crash.md4.f, ebx, ecx, edx, eax, 15, 19, 0x00000000
  79.  
  80.         crash.md4.round         crash.md4.g, eax, ebx, ecx, edx,  0,  3, 0x5a827999
  81.         crash.md4.round         crash.md4.g, edx, eax, ebx, ecx,  4,  5, 0x5a827999
  82.         crash.md4.round         crash.md4.g, ecx, edx, eax, ebx,  8,  9, 0x5a827999
  83.         crash.md4.round         crash.md4.g, ebx, ecx, edx, eax, 12, 13, 0x5a827999
  84.         crash.md4.round         crash.md4.g, eax, ebx, ecx, edx,  1,  3, 0x5a827999
  85.         crash.md4.round         crash.md4.g, edx, eax, ebx, ecx,  5,  5, 0x5a827999
  86.         crash.md4.round         crash.md4.g, ecx, edx, eax, ebx,  9,  9, 0x5a827999
  87.         crash.md4.round         crash.md4.g, ebx, ecx, edx, eax, 13, 13, 0x5a827999
  88.         crash.md4.round         crash.md4.g, eax, ebx, ecx, edx,  2,  3, 0x5a827999
  89.         crash.md4.round         crash.md4.g, edx, eax, ebx, ecx,  6,  5, 0x5a827999
  90.         crash.md4.round         crash.md4.g, ecx, edx, eax, ebx, 10,  9, 0x5a827999
  91.         crash.md4.round         crash.md4.g, ebx, ecx, edx, eax, 14, 13, 0x5a827999
  92.         crash.md4.round         crash.md4.g, eax, ebx, ecx, edx,  3,  3, 0x5a827999
  93.         crash.md4.round         crash.md4.g, edx, eax, ebx, ecx,  7,  5, 0x5a827999
  94.         crash.md4.round         crash.md4.g, ecx, edx, eax, ebx, 11,  9, 0x5a827999
  95.         crash.md4.round         crash.md4.g, ebx, ecx, edx, eax, 15, 13, 0x5a827999
  96.  
  97.         crash.md4.round         crash.md4.h, eax, ebx, ecx, edx,  0,  3, 0x6ed9eba1
  98.         crash.md4.round         crash.md4.h, edx, eax, ebx, ecx,  8,  9, 0x6ed9eba1
  99.         crash.md4.round         crash.md4.h, ecx, edx, eax, ebx,  4, 11, 0x6ed9eba1
  100.         crash.md4.round         crash.md4.h, ebx, ecx, edx, eax, 12, 15, 0x6ed9eba1
  101.         crash.md4.round         crash.md4.h, eax, ebx, ecx, edx,  2,  3, 0x6ed9eba1
  102.         crash.md4.round         crash.md4.h, edx, eax, ebx, ecx, 10,  9, 0x6ed9eba1
  103.         crash.md4.round         crash.md4.h, ecx, edx, eax, ebx,  6, 11, 0x6ed9eba1
  104.         crash.md4.round         crash.md4.h, ebx, ecx, edx, eax, 14, 15, 0x6ed9eba1
  105.         crash.md4.round         crash.md4.h, eax, ebx, ecx, edx,  1,  3, 0x6ed9eba1
  106.         crash.md4.round         crash.md4.h, edx, eax, ebx, ecx,  9,  9, 0x6ed9eba1
  107.         crash.md4.round         crash.md4.h, ecx, edx, eax, ebx,  5, 11, 0x6ed9eba1
  108.         crash.md4.round         crash.md4.h, ebx, ecx, edx, eax, 13, 15, 0x6ed9eba1
  109.         crash.md4.round         crash.md4.h, eax, ebx, ecx, edx,  3,  3, 0x6ed9eba1
  110.         crash.md4.round         crash.md4.h, edx, eax, ebx, ecx, 11,  9, 0x6ed9eba1
  111.         crash.md4.round         crash.md4.h, ecx, edx, eax, ebx,  7, 11, 0x6ed9eba1
  112.         crash.md4.round         crash.md4.h, ebx, ecx, edx, eax, 15, 15, 0x6ed9eba1
  113.  
  114.         mov     edi, [_md4]
  115.         add     [edi + 0x0], eax
  116.         add     [edi + 0x4], ebx
  117.         add     [edi + 0x8], ecx
  118.         add     [edi + 0xc], edx
  119.         add     esi, 64
  120.         jmp     .begin
  121.   .endofblock:
  122.         cmp     [final], 1
  123.         je      .quit
  124.  
  125.   .callback:
  126.         mov     eax, [_callback]
  127.         test    eax, eax
  128.         jz      @f
  129.         call    eax
  130.         test    eax, eax
  131.         jz      @f
  132.         mov     [_len], eax
  133.         jmp     .first
  134.     @@:
  135.  
  136.         mov     edi, [_data]
  137.         mov     ecx, [_len]
  138.         rep     movsb
  139.         mov     eax, [_msglen]
  140.         mov     eax, [eax]
  141.         and     eax, 63
  142.         mov     ecx, 56
  143.         sub     ecx, eax
  144.         ja      @f
  145.         add     ecx, 64
  146.     @@:
  147.         add     [_len], ecx
  148.         mov     byte[edi], 0x80
  149.         add     edi, 1
  150.         sub     ecx, 1
  151.         mov     al, 0
  152.         rep     stosb
  153.         mov     eax, [_msglen]
  154.         mov     eax, [eax]
  155.         mov     edx, 8
  156.         mul     edx
  157.         mov     dword[edi], eax
  158.         mov     dword[edi + 4], edx
  159.         add     [_len], 8
  160.         mov     [final], 1
  161.         jmp     .first
  162.   .quit:
  163.         ret
  164. endp
  165.  
  166.