init=0;
static void ssleay_rand_bytes(unsigned char *buf, int num)	{	int i,j,k,st_num,st_idx;	MD_CTX m;	static int init=1;	unsigned long l;#ifdef DEVRANDOM	FILE *fh;#endif#ifdef PREDICT	{	static unsigned char val=0;	for (i=0; i<num; i++)		buf[i]=val++;	return;	}#endif	CRYPTO_w_lock(CRYPTO_LOCK_RAND);	if (init)		{		init=0;		CRYPTO_w_unlock(CRYPTO_LOCK_RAND);		/* put in some default random data, we need more than		 * just this */		RAND_seed(&m,sizeof(m));#ifndef MSDOS		l=getpid();		RAND_seed(&l,sizeof(l));		l=getuid();		RAND_seed(&l,sizeof(l));#endif		l=time(NULL);		RAND_seed(&l,sizeof(l));/* #ifdef DEVRANDOM */		/* 		 * Use a random entropy pool device.		 * Linux 1.3.x and FreeBSD-Current has 		 * this. Use /dev/urandom if you can		 * as /dev/random will block if it runs out		 * of random entries.		 */		if ((fh = fopen(DEVRANDOM, "r")) != NULL)			{			unsigned char tmpbuf[32];			fread((unsigned char *)tmpbuf,1,32,fh);			/* we don't care how many bytes we read,			 * we will just copy the 'stack' if there is			 * nothing else :-) */			fclose(fh);			RAND_seed(tmpbuf,32);			memset(tmpbuf,0,32);			}/* #endif */#ifdef PURIFY		memset(state,0,STATE_SIZE);		memset(md,0,MD_DIGEST_LENGTH);#endif		CRYPTO_w_lock(CRYPTO_LOCK_RAND);		}	st_idx=state_index;	st_num=state_num;	state_index+=num;	if (state_index > state_num)		state_index=(state_index%state_num);	CRYPTO_w_unlock(CRYPTO_LOCK_RAND);	while (num > 0)		{		j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num;		num-=j;		MD_Init(&m);		MD_Update(&m,&(md[MD_DIGEST_LENGTH/2]),MD_DIGEST_LENGTH/2);		MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count));#ifndef PURIFY		MD_Update(&m,buf,j); /* purify complains */#endif		k=(st_idx+j)-st_num;		if (k > 0)			{			MD_Update(&m,&(state[st_idx]),j-k);			MD_Update(&m,&(state[0]),k);			}		else			MD_Update(&m,&(state[st_idx]),j);		MD_Final(md,&m);		for (i=0; i<j; i++)			{			if (st_idx >= st_num)				st_idx=0;			state[st_idx++]^=md[i];			*(buf++)=md[i+MD_DIGEST_LENGTH/2];			}		}	MD_Init(&m);	MD_Update(&m,(unsigned char *)&(md_count[0]),sizeof(md_count));	md_count[0]++;	MD_Update(&m,md,MD_DIGEST_LENGTH);	MD_Final(md,&m);	memset(&m,0,sizeof(m));	}