Giter Site home page Giter Site logo

mauricelambert / fastrc4 Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 63 KB

Optimized implementation of RC4 (Rivest Cipher 4, ARCFOUR) in ASM (x64) for Linux and Windows.

License: GNU General Public License v3.0

Assembly 49.68% Python 44.22% C 6.10%
arc4 asm cipher rc4 encrypt optimization poc linux windows

fastrc4's Introduction

FastRC4 - LibARC4

This RC4 implementation is not secure, it is a POC for an optimized RC4 implementation in ASM. You should never use this implementation for TLS, WEP, ... or other old protocols using RC4. You should never use it to encrypt secrets or very large file.

The RC4 algorithm validity is checked with lddgo.net API to be sure is correct.

Description

This repository implements RC4 encryption with IV, written in ASM with few optimizations.

Requirements

  • To use the shared library you don't need any requirements.
  • To use the python interface you need Python3 and the standard library.

Compilation

Linux

nasm -felf64 ARC4.asm
ld -shared ARC4.o -o librc4.so
strip librc4.so

Windows

nasm -fwin64 rc4_win.asm
gcc -shared rc4_win.obj -o librc4.dll
strip librc4.dll

Usages

Exported functions

char *get_iv();
void *encrypt(char *key, char *data, unsigned long long length);
void *decrypt(char *key, char iv[256], char *data, unsigned long long length);
void *generate_iv();
void *xor_key_iv();
void *generate_key(char *key);
void *arc4_null_byte(char *data);
void *arc4(char *data, unsigned long long length);
void *reset_key();
void *set_iv(char *iv);
arc4_null_byte([IN/OUT] char *data) -> NULL
arc4([IN/OUT] char *data, [IN] unsigned long long length) -> NULL
generate_iv() -> NULL
xor_key_iv() -> NULL
generate_key(char *key) -> NULL
reset_key() -> NULL
get_iv() -> char[256] // null byte terminate string
set_iv([IN] char iv[256]) -> NULL
encrypt([IN] char *key, [IN/OUT] char *data, [IN] unsigned long long length) -> NULL  // if length is 0 call arc4_null_byte
decrypt([IN] char *key, [IN] char iv[256], [IN/OUT] char *data, [IN] unsigned long long length) -> NULL // there is no way to decrypt string terminating by null byte because encrypted data can contains null byte

Python interface

from librc4 import RC4

rc4 = RC4(b'my key')
cipher = rc4.encrypt(b'my data')
secret = rc4.decrypt(cipher)

Licence

Licensed under the GPL, version 3.

fastrc4's People

Contributors

mauricelambert avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.