diff options
author | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
---|---|---|
committer | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
commit | 58964a492275ca9a59a0cd9c8155cb2491b4b909 (patch) | |
tree | c7b16876a5789463bbbb468ef4829c8129b3d718 /crypto/rc5/asm | |
parent | d02b48c63a58ea4367a0e905979f140b7d090f86 (diff) | |
download | openssl-new-58964a492275ca9a59a0cd9c8155cb2491b4b909.tar.gz |
Import of old SSLeay release: SSLeay 0.9.0b
Diffstat (limited to 'crypto/rc5/asm')
-rw-r--r-- | crypto/rc5/asm/r5-win32.asm | 574 | ||||
-rw-r--r-- | crypto/rc5/asm/r586unix.cpp | 628 | ||||
-rw-r--r-- | crypto/rc5/asm/rc5-586.pl | 109 |
3 files changed, 1311 insertions, 0 deletions
diff --git a/crypto/rc5/asm/r5-win32.asm b/crypto/rc5/asm/r5-win32.asm new file mode 100644 index 0000000000..f43d3711f0 --- /dev/null +++ b/crypto/rc5/asm/r5-win32.asm @@ -0,0 +1,574 @@ + ; Don't even think of reading this code + ; It was automatically generated by rc5-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric <eay@cryptsoft.com> + ; + TITLE rc5-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _RC5_32_encrypt + +_RC5_32_encrypt PROC NEAR + ; + push ebp + push esi + push edi + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 20[esp] + ; Load the 2 words + mov edi, DWORD PTR [edx] + mov esi, DWORD PTR 4[edx] + push ebx + mov ebx, DWORD PTR [ebp] + add edi, DWORD PTR 4[ebp] + add esi, DWORD PTR 8[ebp] + xor edi, esi + mov eax, DWORD PTR 12[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 16[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 20[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 24[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 28[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 32[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 36[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 40[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 44[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 48[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 52[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 56[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 60[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 64[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 68[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 72[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + cmp ebx, 8 + je $L000rc5_exit + xor edi, esi + mov eax, DWORD PTR 76[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 80[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 84[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 88[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 92[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 96[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 100[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 104[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + cmp ebx, 12 + je $L000rc5_exit + xor edi, esi + mov eax, DWORD PTR 108[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 112[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 116[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 120[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 124[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 128[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 132[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 136[ebp] + mov ecx, edi + rol esi, cl + add esi, eax +$L000rc5_exit: + mov DWORD PTR [edx],edi + mov DWORD PTR 4[edx],esi + pop ebx + pop edi + pop esi + pop ebp + ret +_RC5_32_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _RC5_32_decrypt + +_RC5_32_decrypt PROC NEAR + ; + push ebp + push esi + push edi + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 20[esp] + ; Load the 2 words + mov edi, DWORD PTR [edx] + mov esi, DWORD PTR 4[edx] + push ebx + mov ebx, DWORD PTR [ebp] + cmp ebx, 12 + je $L001rc5_dec_12 + cmp ebx, 8 + je $L002rc5_dec_8 + mov eax, DWORD PTR 136[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 132[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 128[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 124[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 120[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 116[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 112[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 108[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi +$L001rc5_dec_12: + mov eax, DWORD PTR 104[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 100[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 96[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 92[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 88[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 84[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 80[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 76[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi +$L002rc5_dec_8: + mov eax, DWORD PTR 72[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 68[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 64[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 60[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 56[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 52[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 48[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 44[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 40[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 36[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 32[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 28[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 24[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 20[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 16[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 12[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + sub esi, DWORD PTR 8[ebp] + sub edi, DWORD PTR 4[ebp] +L003rc5_exit: + mov DWORD PTR [edx],edi + mov DWORD PTR 4[edx],esi + pop ebx + pop edi + pop esi + pop ebp + ret +_RC5_32_decrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _RC5_32_cbc_encrypt + +_RC5_32_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 3 + mov eax, DWORD PTR 48[esp] + push eax + push ebx + cmp ecx, 0 + jz $L004decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + jz $L005encrypt_finish +L006encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L006encrypt_loop +$L005encrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L007finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4] + jmp ebp +L009ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L010ej6: + mov dh, BYTE PTR 5[esi] +L011ej5: + mov dl, BYTE PTR 4[esi] +L012ej4: + mov ecx, DWORD PTR [esi] + jmp $L013ejend +L014ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L015ej2: + mov ch, BYTE PTR 1[esi] +L016ej1: + mov cl, BYTE PTR [esi] +$L013ejend: + xor eax, ecx + xor ebx, edx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L007finish +$L004decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L017decrypt_finish +L018decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L018decrypt_loop +$L017decrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L007finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L019dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L020dj6: + mov BYTE PTR 5[edi],dh +L021dj5: + mov BYTE PTR 4[edi],dl +L022dj4: + mov DWORD PTR [edi],ecx + jmp $L023djend +L024dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L025dj2: + mov BYTE PTR 1[esi],ch +L026dj1: + mov BYTE PTR [esi], cl +$L023djend: + jmp $L007finish +$L007finish: + mov ecx, DWORD PTR 60[esp] + add esp, 24 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L008cbc_enc_jmp_table: + DD 0 + DD L016ej1 + DD L015ej2 + DD L014ej3 + DD L012ej4 + DD L011ej5 + DD L010ej6 + DD L009ej7 +L027cbc_dec_jmp_table: + DD 0 + DD L026dj1 + DD L025dj2 + DD L024dj3 + DD L022dj4 + DD L021dj5 + DD L020dj6 + DD L019dj7 +_RC5_32_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/crypto/rc5/asm/r586unix.cpp b/crypto/rc5/asm/r586unix.cpp new file mode 100644 index 0000000000..a25dd5a9a4 --- /dev/null +++ b/crypto/rc5/asm/r586unix.cpp @@ -0,0 +1,628 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define RC5_32_encrypt _RC5_32_encrypt +#define RC5_32_decrypt _RC5_32_decrypt +#define RC5_32_cbc_encrypt _RC5_32_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by rc5-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric <eay@cryptsoft.com> */ + + .file "rc5-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl RC5_32_encrypt + TYPE(RC5_32_encrypt,@function) +RC5_32_encrypt: + + pushl %ebp + pushl %esi + pushl %edi + movl 16(%esp), %edx + movl 20(%esp), %ebp + /* Load the 2 words */ + movl (%edx), %edi + movl 4(%edx), %esi + pushl %ebx + movl (%ebp), %ebx + addl 4(%ebp), %edi + addl 8(%ebp), %esi + xorl %esi, %edi + movl 12(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 16(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 20(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 24(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 28(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 32(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 36(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 40(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 44(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 48(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 52(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 56(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 60(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 64(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 68(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 72(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + cmpl $8, %ebx + je .L000rc5_exit + xorl %esi, %edi + movl 76(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 80(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 84(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 88(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 92(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 96(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 100(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 104(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + cmpl $12, %ebx + je .L000rc5_exit + xorl %esi, %edi + movl 108(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 112(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 116(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 120(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 124(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 128(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 132(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 136(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi +.L000rc5_exit: + movl %edi, (%edx) + movl %esi, 4(%edx) + popl %ebx + popl %edi + popl %esi + popl %ebp + ret +.RC5_32_encrypt_end: + SIZE(RC5_32_encrypt,.RC5_32_encrypt_end-RC5_32_encrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl RC5_32_decrypt + TYPE(RC5_32_decrypt,@function) +RC5_32_decrypt: + + pushl %ebp + pushl %esi + pushl %edi + movl 16(%esp), %edx + movl 20(%esp), %ebp + /* Load the 2 words */ + movl (%edx), %edi + movl 4(%edx), %esi + pushl %ebx + movl (%ebp), %ebx + cmpl $12, %ebx + je .L001rc5_dec_12 + cmpl $8, %ebx + je .L002rc5_dec_8 + movl 136(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 132(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 128(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 124(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 120(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 116(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 112(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 108(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi +.L001rc5_dec_12: + movl 104(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 100(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 96(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 92(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 88(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 84(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 80(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 76(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi +.L002rc5_dec_8: + movl 72(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 68(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 64(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 60(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 56(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 52(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 48(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 44(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 40(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 36(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 32(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 28(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 24(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 20(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 16(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 12(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + subl 8(%ebp), %esi + subl 4(%ebp), %edi +.L003rc5_exit: + movl %edi, (%edx) + movl %esi, 4(%edx) + popl %ebx + popl %edi + popl %esi + popl %ebp + ret +.RC5_32_decrypt_end: + SIZE(RC5_32_decrypt,.RC5_32_decrypt_end-RC5_32_decrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl RC5_32_cbc_encrypt + TYPE(RC5_32_cbc_encrypt,@function) +RC5_32_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 3 */ + movl 48(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L004decrypt + andl $4294967288, %ebp + movl 8(%esp), %eax + movl 12(%esp), %ebx + jz .L005encrypt_finish +.L006encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L006encrypt_loop +.L005encrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L007finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L009ej7: + movb 6(%esi), %dh + sall $8, %edx +.L010ej6: + movb 5(%esi), %dh +.L011ej5: + movb 4(%esi), %dl +.L012ej4: + movl (%esi), %ecx + jmp .L013ejend +.L014ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L015ej2: + movb 1(%esi), %ch +.L016ej1: + movb (%esi), %cl +.L013ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L007finish +.align ALIGN +.L004decrypt: + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L017decrypt_finish +.L018decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L018decrypt_loop +.L017decrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L007finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L019dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L020dj6: + movb %dh, 5(%edi) +.L021dj5: + movb %dl, 4(%edi) +.L022dj4: + movl %ecx, (%edi) + jmp .L023djend +.L024dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L025dj2: + movb %ch, 1(%esi) +.L026dj1: + movb %cl, (%esi) +.L023djend: + jmp .L007finish +.align ALIGN +.L007finish: + movl 60(%esp), %ecx + addl $24, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L008cbc_enc_jmp_table: + .long 0 + .long .L016ej1 + .long .L015ej2 + .long .L014ej3 + .long .L012ej4 + .long .L011ej5 + .long .L010ej6 + .long .L009ej7 +.align ALIGN +.L027cbc_dec_jmp_table: + .long 0 + .long .L026dj1 + .long .L025dj2 + .long .L024dj3 + .long .L022dj4 + .long .L021dj5 + .long .L020dj6 + .long .L019dj7 +.RC5_32_cbc_encrypt_end: + SIZE(RC5_32_cbc_encrypt,.RC5_32_cbc_encrypt_end-RC5_32_cbc_encrypt) +.ident "desasm.pl" diff --git a/crypto/rc5/asm/rc5-586.pl b/crypto/rc5/asm/rc5-586.pl new file mode 100644 index 0000000000..edff1d1e64 --- /dev/null +++ b/crypto/rc5/asm/rc5-586.pl @@ -0,0 +1,109 @@ +#!/usr/local/bin/perl + +push(@INC,"perlasm","../../perlasm"); +require "x86asm.pl"; +require "cbc.pl"; + +&asm_init($ARGV[0],"rc5-586.pl"); + +$RC5_MAX_ROUNDS=16; +$RC5_32_OFF=($RC5_MAX_ROUNDS+2)*4; +$A="edi"; +$B="esi"; +$S="ebp"; +$tmp1="eax"; +$r="ebx"; +$tmpc="ecx"; +$tmp4="edx"; + +&RC5_32_encrypt("RC5_32_encrypt",1); +&RC5_32_encrypt("RC5_32_decrypt",0); +&cbc("RC5_32_cbc_encrypt","RC5_32_encrypt","RC5_32_decrypt",0,4,5,3,-1,-1); +&asm_finish(); + +sub RC5_32_encrypt + { + local($name,$enc)=@_; + + &function_begin_B($name,""); + + &comment(""); + + &push("ebp"); + &push("esi"); + &push("edi"); + &mov($tmp4,&wparam(0)); + &mov($S,&wparam(1)); + + &comment("Load the 2 words"); + &mov($A,&DWP(0,$tmp4,"",0)); + &mov($B,&DWP(4,$tmp4,"",0)); + + &push($r); + &mov($r, &DWP(0,$S,"",0)); + + # encrypting part + + if ($enc) + { + &add($A, &DWP(4+0,$S,"",0)); + &add($B, &DWP(4+4,$S,"",0)); + + for ($i=0; $i<$RC5_MAX_ROUNDS; $i++) + { + &xor($A, $B); + &mov($tmp1, &DWP(12+$i*8,$S,"",0)); + &mov($tmpc, $B); + &rotl($A, &LB("ecx")); + &add($A, $tmp1); + + &xor($B, $A); + &mov($tmp1, &DWP(16+$i*8,$S,"",0)); + &mov($tmpc, $A); + &rotl($B, &LB("ecx")); + &add($B, $tmp1); + if (($i == 7) || ($i == 11)) + { + &cmp($r, $i+1); + &je(&label("rc5_exit")); + } + } + } + else + { + &cmp($r, 12); + &je(&label("rc5_dec_12")); + &cmp($r, 8); + &je(&label("rc5_dec_8")); + for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--) + { + &set_label("rc5_dec_$i") if ($i == 12) || ($i == 8); + &mov($tmp1, &DWP($i*8+8,$S,"",0)); + &sub($B, $tmp1); + &mov($tmpc, $A); + &rotr($B, &LB("ecx")); + &xor($B, $A); + + &mov($tmp1, &DWP($i*8+4,$S,"",0)); + &sub($A, $tmp1); + &mov($tmpc, $B); + &rotr($A, &LB("ecx")); + &xor($A, $B); + } + &sub($B, &DWP(4+4,$S,"",0)); + &sub($A, &DWP(4+0,$S,"",0)); + } + + &set_label("rc5_exit"); + &mov(&DWP(0,$tmp4,"",0),$A); + &mov(&DWP(4,$tmp4,"",0),$B); + + &pop("ebx"); + &pop("edi"); + &pop("esi"); + &pop("ebp"); + &ret(); + &function_end_B($name); + } + + |