📄 dechash.inc
字号:
{Copyright: Hagen Reddmann HaReddmann at T-Online dot de
Author: Hagen Reddmann
Remarks: freeware, but this Copyright must be included
known Problems: none
Version: 5.1, Part I from Delphi Encryption Compendium ( DEC Part I)
Delphi 5
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}
{$IFDEF THash_MD2_asm}
procedure THash_MD2.DoTransform(Buffer: PLongArray);
asm
push ebx
push esi
push edi
push ebp
lea esi, [eax].THash_MD2.FDigest
// copying incoming buffer into work buffer
mov eax, [edx]
mov ecx, [edx + 4]
mov ebx, [edx + 8]
mov edi, [edx + 12]
mov [esi + 16], eax
mov [esi + 16 + 4], ecx
mov [esi + 16 + 8], ebx
mov [esi + 16 + 12], edi
// recalculating message checksum
// loop unrolled to 4 iterations,
// combined with
// xor first 16 bytes with second 16 and move res to third
mov ecx, dword ptr [esi + 60]
mov edi, -16
shr ecx, 24
@checksumloop:
mov edx, dword ptr [esi + edi + 16] // digest
mov ebp, dword ptr [esi + edi + 16 + 16] // source data
mov ebx, dword ptr [esi + edi + 16 + 48] // checksum
xor ecx, ebp
xor edx, ebp
and ecx, 0ffh
xor eax, eax
mov ecx, dword ptr MD2_PiSubst[ecx*4]
shr ebp, 8
xor ecx, ebx
mov dword ptr [esi + edi + 16 + 32], edx
and ecx, 0ffh
shr ebx, 8
or eax, ecx
shl eax, 24
xor ecx, ebp
and ecx, 0ffh
shr ebp, 8
mov ecx, dword ptr MD2_PiSubst[ecx*4]
xor ecx, ebx
and ecx, 0ffh
shr ebx, 8
or eax, ecx
ror eax, 8
xor ecx, ebp
and ecx, 0ffh
shr ebp, 8
mov ecx, dword ptr MD2_PiSubst[ecx*4]
xor ecx, ebx
and ecx, 0ffh
shr ebx, 8
or eax, ecx
ror eax, 8
xor ecx, ebp
and ecx, 0ffh
mov ecx, dword ptr MD2_PiSubst[ecx*4]
xor ecx, ebx
or eax, ecx
ror eax, 8
mov dword ptr [esi + edi + 16 + 48], eax
add edi, 4
jnz @checksumloop
// do 18 rounds of transformation
// internal loop unrolled
lea edi, MD2_PiSubst // MD2 permutation array pointer
xor ecx, ecx // T variable
xor ebp, ebp // external 18 rounds loop
mov ebx, 0ffh // mask constant
@roundsloop:
// part 1
mov edx, dword ptr [esi]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
or eax, ecx
ror eax, 8
mov dword ptr [esi], eax
// part 2
mov edx, dword ptr [esi + 4]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
or eax, ecx
ror eax, 8
mov dword ptr [esi + 4], eax
// part 3
mov edx, dword ptr [esi + 8]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
or eax, ecx
ror eax, 8
mov dword ptr [esi + 8], eax
// part 4
mov edx, dword ptr [esi + 12]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
or eax, ecx
ror eax, 8
mov dword ptr [esi + 12], eax
// part 5
mov edx, dword ptr [esi + 16]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
or eax, ecx
ror eax, 8
mov dword ptr [esi + 16], eax
// part 6
mov edx, dword ptr [esi + 20]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
or eax, ecx
ror eax, 8
mov dword ptr [esi + 20], eax
// part 7
mov edx, dword ptr [esi + 24]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
or eax, ecx
ror eax, 8
mov dword ptr [esi + 24], eax
// part 8
mov edx, dword ptr [esi + 28]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
or eax, ecx
ror eax, 8
mov dword ptr [esi + 28], eax
// part 9
mov edx, dword ptr [esi + 32]
mov ecx, dword ptr [edi + ecx*4]
xor eax, eax
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
shl eax, 24
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
ror eax, 8
xor ecx, edx
shr edx, 8
and ecx, ebx
or eax, ecx
mov ecx, dword ptr [edi + ecx*4]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -