4646
4747#define  CRC32 (c , b ) ((*(pcrc_32_tab+(((uint32_t)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
4848
49- #ifndef  ZCR_SEED2 
50- # define  ZCR_SEED2  3141592654UL /* use PI as default pattern */ 
51- #endif 
52- 
5349/***************************************************************************/ 
5450
5551uint8_t  decrypt_byte (uint32_t  * pkeys )
@@ -90,11 +86,10 @@ void init_keys(const char *passwd, uint32_t *pkeys, const z_crc_t *pcrc_32_tab)
9086
9187int  cryptrand (unsigned char   * buf , unsigned int   len )
9288{
93-  static  unsigned  calls  =  0 ;
94-  int  rlen  =  0 ;
9589#ifdef  _WIN32 
9690 HCRYPTPROV  provider ;
9791 unsigned __int64   pentium_tsc [1 ];
92+  int  rlen  =  0 ;
9893 int  result  =  0 ;
9994
10095
@@ -112,24 +107,12 @@ int cryptrand(unsigned char *buf, unsigned int len)
112107 QueryPerformanceCounter ((LARGE_INTEGER  * )pentium_tsc );
113108 buf [rlen ] =  ((unsigned char  * )pentium_tsc )[rlen  % 8 ];
114109 }
115- #else 
116-  int  frand  =  open ("/dev/urandom" , O_RDONLY );
117-  if  (frand  !=  -1 )
118-  {
119-  rlen  =  (int )read (frand , buf , len );
120-  close (frand );
121-  }
122- #endif 
123-  if  (rlen  <  (int )len )
124-  {
125-  /* Ensure different random header each time */ 
126-  if  (++ calls  ==  1 )
127-  srand ((unsigned )(time (NULL ) ^ ZCR_SEED2 ));
128110
129-  while  (rlen  <  (int )len )
130-  buf [rlen ++ ] =  (rand () >> 7 ) &  0xff ;
131-  }
132111 return  rlen ;
112+ #else 
113+  arc4random_buf (buf , len );
114+  return  len ;
115+ #endif 
133116}
134117
135118int  crypthead (const  char  * passwd , uint8_t  * buf , int  buf_size , uint32_t  * pkeys ,
0 commit comments