Skip to content

Commit d24e1d5

Browse files
Documentation
1 parent 23b7c67 commit d24e1d5

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# FastRC4 - LibARC4
2+
3+
> **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.**
4+
5+
## Description
6+
7+
This repository implements RC4 encryption with IV, written in ASM with few optimizations.
8+
9+
## Requirements
10+
11+
- To use the shared library you don't need any requirements.
12+
- To use the python interface you need Python3 and the standard library.
13+
14+
## Compilation
15+
16+
```bash
17+
nasm -felf64 ARC4.asm
18+
ld -shared ARC4.o -o librc4.so
19+
strip librc4.so
20+
```
21+
22+
## Usages
23+
24+
### Exported functions
25+
26+
```c
27+
char *get_iv();
28+
void *encrypt(char *key, char *data, unsigned long long length);
29+
void *decrypt(char *key, char iv[256], char *data, unsigned long long length);
30+
void *generate_iv();
31+
void *xor_key_iv();
32+
void *generate_key(char *key);
33+
void *arc4_null_byte(char *data);
34+
void *arc4(char *data, unsigned long long length);
35+
void *reset_key();
36+
void *set_iv(char *iv);
37+
```
38+
39+
```
40+
arc4_null_byte([IN/OUT] char *data) -> NULL
41+
arc4([IN/OUT] char *data, [IN] unsigned long long length) -> NULL
42+
generate_iv() -> NULL
43+
xor_key_iv() -> NULL
44+
generate_key(char *key) -> NULL
45+
reset_key() -> NULL
46+
get_iv() -> char[256] // null byte terminate string
47+
set_iv([IN] char iv[256]) -> NULL
48+
encrypt([IN] char *key, [IN/OUT] char *data, [IN] unsigned long long length) -> NULL // if length is 0 call arc4_null_byte
49+
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
50+
```
51+
52+
### Python interface
53+
54+
```python
55+
from librc4 import RC4
56+
57+
rc4 = RC4(b'my key')
58+
cipher = rc4.encrypt(b'my data')
59+
secret = rc4.decrypt(cipher)
60+
```
61+
62+
## Licence
63+
64+
Licensed under the [GPL, version 3](https://www.gnu.org/licenses/).

librc4.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def tests():
211211
analyzer = DataAnalysis(data)
212212
analyze = list(analyzer.keys_frequences())
213213
analyzer.statistictypes_printer(analyze)
214-
analyzer.statistictypes_chart(analyze)
214+
# analyzer.statistictypes_chart(analyze)
215215

216216
from binascii import hexlify
217217
key = b'This is my secret key !'

0 commit comments

Comments
 (0)