diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-05-06 15:02:58 +0000 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2004-05-06 15:02:58 +0000 |
commit | e256acce3bfc22534b5738f8438faf328fda6a8b (patch) | |
tree | db96031437314f4d14db5a4f4e837c9f8c28642b /source/lib/genrand.c | |
parent | 9c9d2fac0b8ccbb5292a7e8b90361da6ea9d2ece (diff) | |
download | samba-e256acce3bfc22534b5738f8438faf328fda6a8b.tar.gz samba-e256acce3bfc22534b5738f8438faf328fda6a8b.tar.xz samba-e256acce3bfc22534b5738f8438faf328fda6a8b.zip |
r518: merge in the SAMBA_2_2 branch from cvs to brnaches/SAMBA_2_2
this is maybe not complete yet, please wait until I create the DAY_ZERRO tag
metze
Diffstat (limited to 'source/lib/genrand.c')
-rw-r--r-- | source/lib/genrand.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/lib/genrand.c b/source/lib/genrand.c index bc9f21c6403..009c62fcf35 100644 --- a/source/lib/genrand.c +++ b/source/lib/genrand.c @@ -1,5 +1,6 @@ /* - Unix SMB/CIFS implementation. + Unix SMB/Netbios implementation. + Version 2.2 Functions to create reasonable random numbers for crypto use. @@ -24,8 +25,8 @@ static unsigned char hash[258]; static uint32 counter; -static unsigned char *reseed_data; -static size_t reseed_data_size; +unsigned char *reseed_data; +size_t reseed_data_size; /**************************************************************** Copy any user given reseed data. @@ -146,10 +147,18 @@ static int do_reseed(BOOL use_fd, int fd) return fd; } +#ifdef __INSURE__ + memset(seed_inbuf, '\0', sizeof(seed_inbuf)); +#endif + /* Add in some secret file contents */ do_filehash("/etc/shadow", &seed_inbuf[0]); +#ifdef WITH_TDB_SAM + do_filehash(lp_tdb_passwd_file(), &seed_inbuf[16]); +#else do_filehash(lp_smb_passwd_file(), &seed_inbuf[16]); +#endif /* * Add in the root encrypted password. @@ -157,14 +166,13 @@ static int do_reseed(BOOL use_fd, int fd) * seriously this will be secret. */ - pw = getpwnam_alloc("root"); + pw = sys_getpwnam("root"); if (pw && pw->pw_passwd) { size_t i; unsigned char md4_tmp[16]; mdfour(md4_tmp, (unsigned char *)pw->pw_passwd, strlen(pw->pw_passwd)); for (i=0;i<16;i++) seed_inbuf[8+i] ^= md4_tmp[i]; - passwd_free(&pw); } /* @@ -259,7 +267,7 @@ char *generate_random_str(size_t len) len = sizeof(retstr) -1; generate_random_buffer( retstr, len, False); for (i = 0; i < len; i++) - retstr[i] = c_list[ retstr[i] % (sizeof(c_list)-1) ]; + retstr[i] = c_list[ retstr[i] % sizeof(c_list) ]; retstr[i] = '\0'; |