Hi,
|
Hi,
|
|
|
I was looking for a quick implementation of RC4 and I couldn't find one, so I wrote one based on the wikipedia example.
|
I was looking for a quick implementation of RC4 and I couldn't find one, so I wrote one based on the wikipedia example.
|
|
|
It's quite easy to use:
|
It's quite easy to use:
|
|
|
1) First, issue rst
|
1) First, issue rst
|
2) Load the password byte-by-byte into the password_input port. The lenght of the password is KEY_SIZE
|
2) Load the password byte-by-byte into the password_input port. The lenght of the password is KEY_SIZE
|
3) Issue 768 clocks to perform key expansion
|
3) Issue 768 clocks to perform key expansion
|
4) Now you should start receiving the pseudo-random stream via the output bus, one byte every two clocks. The output_ready signal signals when a valid byte is present at the output K.
|
4) Wait about 1000 clocks while the module discards the first 1000 weak bytes of the stream.
|
|
5) Now you should start receiving the pseudo-random stream via the output bus, one byte every clock. The output_ready signal signals when a valid byte is present at the output K.
|
To encrypt or decrypt using RC4 you simply xor your data with the output stream.
|
To encrypt or decrypt using RC4 you simply xor your data with the output stream.
|
Also you shouldn't use the first kb of stream because of a known RC4 vulnerability, so please discard those bytes.
|
|
|
|
The testbench and makefile work using icarus verilog and you can peer into rc4_tb.v to see an example implementation.
|
The testbench and makefile work using icarus verilog and you can peer into rc4_tb.v to see an example implementation.
|
|
|
After installing icarus verilog in your path, just issue:
|
After installing icarus verilog in your path, just issue:
|
|
|
make
|
make
|
|
|
and then
|
and then
|
|
|
./rc4.vvp
|
./rc4.vvp
|
|
|
And you should see the output of the simulation.
|
And you should see the output of the simulation.
|
|
|
Any question or suggestion send an email to aortega@alu.itba.edu.ar, cc: alfred@groundworkstech.com
|
Any question or suggestion send an email to aortega@alu.itba.edu.ar, cc: alfred@groundworkstech.com
|
|
|
Cheers,
|
Cheers,
|
|
|
Alfredo
|
Alfredo
|
|
|
|
|
PS: This is licensed LGPL, not public domain or BSD, so you should, put a copy of the license in your software and stuff. Yes, I'm talking to you jhunjhun, you too have to do it.
|
PS: This is licensed LGPL, not public domain or BSD, so you should, put a copy of the license in your software and stuff. Yes, I'm talking to you jhunjhun, you too have to do it.
|
|
|
|
|