summaryrefslogtreecommitdiff
path: root/source3/lib/genrand.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-24 16:04:43 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-24 16:04:43 +0200
commitda01822671b3a553fd805315df7322b8225cfe95 (patch)
treee97c833cfb81eea5cae93a023cbb52cd84cac6c9 /source3/lib/genrand.c
parent2413a7200623855b93946d44bcdb949e2dc170a0 (diff)
downloadsamba-da01822671b3a553fd805315df7322b8225cfe95.tar.gz
samba-da01822671b3a553fd805315df7322b8225cfe95.tar.bz2
samba-da01822671b3a553fd805315df7322b8225cfe95.zip
Use common arcfour implementation.
Diffstat (limited to 'source3/lib/genrand.c')
-rw-r--r--source3/lib/genrand.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/source3/lib/genrand.c b/source3/lib/genrand.c
index 4590b812c5..57314c55df 100644
--- a/source3/lib/genrand.c
+++ b/source3/lib/genrand.c
@@ -21,7 +21,7 @@
#include "includes.h"
-static unsigned char smb_arc4_state[258];
+static struct arcfour_state smb_arc4_state;
static uint32 counter;
static bool done_reseed = False;
@@ -89,6 +89,7 @@ static void do_filehash(const char *fname, unsigned char *the_hash)
static int do_reseed(bool use_fd, int fd)
{
unsigned char seed_inbuf[40];
+ DATA_BLOB seed_blob = { seed_inbuf, 40 };
uint32 v1, v2; struct timeval tval; pid_t mypid;
struct passwd *pw;
int reseed_data = 0;
@@ -146,7 +147,7 @@ static int do_reseed(bool use_fd, int fd)
seed_inbuf[i] ^= ((char *)(&reseed_data))[i % sizeof(reseed_data)];
}
- smb_arc4_init(smb_arc4_state, seed_inbuf, sizeof(seed_inbuf));
+ arcfour_init(&smb_arc4_state, &seed_blob);
return -1;
}
@@ -190,7 +191,7 @@ void generate_random_buffer( unsigned char *out, int len)
while(len > 0) {
int copy_len = len > 16 ? 16 : len;
- smb_arc4_crypt(smb_arc4_state, md4_buf, sizeof(md4_buf));
+ arcfour_crypt_sbox(&smb_arc4_state, md4_buf, sizeof(md4_buf));
mdfour(tmp_buf, md4_buf, sizeof(md4_buf));
memcpy(p, tmp_buf, copy_len);
p += copy_len;