Created
August 31, 2014 05:02
-
-
Save iamgreaser/13989113cc9fc1e7c0ac to your computer and use it in GitHub Desktop.
RC4 for ARM, x86 (untested)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* void rc4_apply(char *stream, int len, char *rc4buf); */ | |
| rc4_apply: | |
| push {r4, r5, r6, lr} | |
| mov r3, #0 | |
| mov r4, #0 | |
| lp_rc4: | |
| add r3, r3, #1 | |
| and r3, r3, #0xFF | |
| ldrb r5, [r2, r3] | |
| add r4, r4, r5 | |
| and r4, r4, #0xFF | |
| ldrb r6, [r2, r4] | |
| strb r6, [r2, r3] | |
| strb r5, [r2, r4] | |
| add r5, r5, r6 | |
| and r5, r5, #0xFF | |
| ldrb r6, [r0, r5] | |
| eor r6, r6, r5 | |
| strb r6, [r0], #1 | |
| subs r1, r1, #1 | |
| bne lp_rc4 | |
| pop {r4, r5, r6, pc} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* void rc4_apply(char *stream, int len, char *rc4buf); */ | |
| rc4_apply: | |
| push esi | |
| push edi | |
| push ebx | |
| mov edi, [esp + 0x04] | |
| mov ecx, [esp + 0x08] | |
| mov esi, [esp + 0x0C] | |
| xor eax, eax | |
| xor edx, edx | |
| lp_rc4: | |
| inc al | |
| mov bl, [esi+eax] | |
| add dl, bl | |
| mov bh, bl | |
| xchg [esi+eax], bl | |
| mov [esi+edx], bl | |
| add bh, bl | |
| xor [edi], bh | |
| inc edi | |
| loop lp_rc4 | |
| pop ebx | |
| pop edi | |
| pop esi | |
| ret | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment