• RC4 Cipher in X86 Assembly
  • RC4 Cipher

    Implemented in x86 assembly for faster speed

    This is the RC4 stream cipher implemented in x86 assembly language to improve its performance.

    RC4 is a simple stream cipher that is used for encryption by combining the keystrem with the source stream using bit-wise exclusive-or(xor). Since exclusive-or with given data is an involution, decryption is performed the same way. Hence, a single function is provided here that can be used both to encryt and decrypt.

    Source

    RC4 Cipher in Assembly is open source under the GPL V3

    Here's how you should be using the code.

    This project uses inline assemly in C to optimize the RC4 stream cipher, so the assembly code is in Intel style syntax that is supported by Microsoft Assembler (MASM). Thus, you should be using Microsoft Visual Studio to compile the code.

    The rc4_cipher.c file contains the x86 assemly version of the RC cipher.

    The rc4_test.c file contains the C version of the RC cipher and a benchmark test example to demonstrate the speed improvement.

    The rc4_cipher.e file is for E language (or EPL) users.

    Results

    Here are some benchmark results tested in my own machine.

    A quick, imformal benchmark on Intel Core i5-3230M 2.60GHz indicates:

    For small source data (44 bytes):
    Time consumed (C vs Assembly): 38 : 29
    The x86 assembly version is 1.31x faster than the C version.

    For large source data (44000 bytes):
    Time consumed (C vs Assembly): 4174 : 1875
    The x86 assembly version is 2.23x faster than the C version.

    Top