Jump to content
  • Advertisement
Sign in to follow this  
Arunas

RC4 (arcfour) question

This topic is 3404 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.. I have been using RC4 (arcfour) algorithm to mildly secure some portions of data in my network game from being viewed by users. I've read that its possible to easily improve RC4 by discarding some portion of its keystream. It's called RC4-drop[n] where n is some certain amount of bytes like 768 or 3072. But what I didn't find anywhere is how its actually done?
unsigned char* arcfour(unsigned char* pwd, unsigned char* data, int data_length)
{
    unsigned char key[256];
    unsigned char box[256];

    int pwd_length = strlen((char*)pwd);    
    int i, j, a, k;
    int tmp;

    unsigned char* cipher = new unsigned char[data_length];
    
    for(i = 0; i < 256; i++)
    {
        key = pwd[i % pwd_length];
        box = i;
    }

    i = 0;
    j = 0;    

    for(i = 0; i < 256; i++)
    {
        j = (j + box + key) % 256;
        tmp = box;
        box = box[j];
        box[j] = tmp;
    }

    a = 0; 
    j = 0;

    for(i = 0; i < data_length; i++)
    {
        a = (a + 1) % 256;
        j = (j + box[a]) % 256;
        tmp = box[a];
        box[a] = box[j];
        box[j] = tmp;
        k = box[((box[a] + box[j]) % 256)];
        cipher = data ^ k;        
    }            

    return cipher;
}
I'm know little about crypto..

Share this post


Link to post
Share on other sites
Advertisement
The RC4 encryption is used for WEP encryption by WiFi network devices. RC4 is still considered safe with one drawback: You can find the encryption key (e.g. WiFi password) easily by investigating on the first xxxx bytes. So if you drop these bytes, you will improve security.

Note that I'm not really into cryptography either, but the above is what I heard about WEP cracking.

Look into Wikipedia. The article describes what I said.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!