From df05e4f2ba1dac466b31749e42cf12705427ea8c Mon Sep 17 00:00:00 2001 From: cem Date: Fri, 13 Dec 2019 04:03:05 +0000 Subject: [PATCH] keyserv(8): unifdef out __FreeBSD__ and KEYSERV_RANDOM This doesn't appear to have some active upstream (and it's a steaming pile of bad 90s crypto design). Rip out the completely horrible bits and leave the only mildly less horrible bits. The whole thing should probably be deleted; to the extent it purports to provide a security feature: it doesn't. --- usr.sbin/keyserv/Makefile | 2 +- usr.sbin/keyserv/keyserv.c | 30 ------------------------------ 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/usr.sbin/keyserv/Makefile b/usr.sbin/keyserv/Makefile index 42d86b27c29c..367919271ee8 100644 --- a/usr.sbin/keyserv/Makefile +++ b/usr.sbin/keyserv/Makefile @@ -4,7 +4,7 @@ PROG= keyserv MAN= keyserv.8 SRCS= keyserv.c setkey.c crypt_svc.c crypt_server.c crypt.h -CFLAGS+= -DKEYSERV_RANDOM -DBROKEN_DES -I. +CFLAGS+= -DBROKEN_DES -I. LIBADD= mp rpcsvc diff --git a/usr.sbin/keyserv/keyserv.c b/usr.sbin/keyserv/keyserv.c index 8acbaf699d9c..051521636ce7 100644 --- a/usr.sbin/keyserv/keyserv.c +++ b/usr.sbin/keyserv/keyserv.c @@ -224,38 +224,8 @@ static void randomize(master) des_block *master; { -#ifndef __FreeBSD__ - int i; - int seed; - struct timeval tv; - int shift; - - seed = 0; - for (i = 0; i < 1024; i++) { - (void)gettimeofday(&tv, NULL); - shift = i % 8 * sizeof (int); - seed ^= (tv.tv_usec << shift) | (tv.tv_usec >> (32 - shift)); - } -#endif -#ifdef KEYSERV_RANDOM -#ifdef __FreeBSD__ master->key.low = arc4random(); master->key.high = arc4random(); -#else - srandom(seed); - master->key.low = random(); - master->key.high = random(); -#endif -#else - /* use stupid dangerous bad rand() */ -#ifdef __FreeBSD__ - sranddev(); -#else - srand(seed); -#endif - master->key.low = rand(); - master->key.high = rand(); -#endif } /*