Changeset 1719464 for lib/rc4.c


Ignore:
Timestamp:
2006-06-28T14:47:05Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5c9512f
Parents:
b3c467b
Message:

Added random_bytes() function for better/more reliable randomization and
moved set_eval_ops() to a slightly more suitable place.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/rc4.c

    rb3c467b r1719464  
    3939
    4040#include <glib.h>
     41#include <gmodule.h>
    4142#include <stdlib.h>
    4243#include <string.h>
     44#include "misc.h"
    4345#include "rc4.h"
    4446
     
    134136        key = g_malloc( key_len );
    135137        strcpy( (char*) key, password );
    136         for( i = 0; i < RC4_IV_LEN; i ++ )
    137                 key[key_len-RC4_IV_LEN+i] = crypt[0][i] = rand() & 0xff;
     138       
     139        /* Add the salt. Save it for later (when decrypting) and, of course,
     140           add it to the encryption key. */
     141        random_bytes( crypt[0], RC4_IV_LEN );
     142        memcpy( key + key_len - RC4_IV_LEN, crypt[0], RC4_IV_LEN );
    138143       
    139144        /* Generate the initial S[] from the IVed key. */
Note: See TracChangeset for help on using the changeset viewer.