use zeromem() where appropriate
This commit is contained in:
		
							parent
							
								
									258de3cecc
								
							
						
					
					
						commit
						f2076f0700
					
				@ -71,7 +71,7 @@ int chacha20_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng
 | 
			
		||||
      /* iv 8 bytes */
 | 
			
		||||
      if ((err = chacha_ivctr64(&prng->chacha.s, buf + 32, 8, 0)) != CRYPT_OK) goto LBL_UNLOCK;
 | 
			
		||||
      /* clear KEY + IV */
 | 
			
		||||
      XMEMSET(buf, 0, sizeof(buf));
 | 
			
		||||
      zeromem(buf, sizeof(buf));
 | 
			
		||||
   }
 | 
			
		||||
   else {
 | 
			
		||||
      /* chacha20_prng_ready() was not called yet, add entropy to ent buffer */
 | 
			
		||||
 | 
			
		||||
@ -72,6 +72,7 @@ int rc4_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *pr
 | 
			
		||||
      if ((err = rc4_stream_setup(&prng->rc4.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK;
 | 
			
		||||
      /* drop first 3072 bytes - https://en.wikipedia.org/wiki/RC4#Fluhrer.2C_Mantin_and_Shamir_attack */
 | 
			
		||||
      for (i = 0; i < 12; i++) rc4_stream_keystream(&prng->rc4.s, buf, sizeof(buf));
 | 
			
		||||
      zeromem(buf, sizeof(buf));
 | 
			
		||||
   }
 | 
			
		||||
   else {
 | 
			
		||||
      /* rc4_ready() was not called yet, add entropy to the buffer */
 | 
			
		||||
 | 
			
		||||
@ -73,7 +73,7 @@ int sober128_add_entropy(const unsigned char *in, unsigned long inlen, prng_stat
 | 
			
		||||
      /* iv 8 bytes */
 | 
			
		||||
      if ((err = sober128_stream_setiv(&prng->sober128.s, buf + 32, 8)) != CRYPT_OK) goto LBL_UNLOCK;
 | 
			
		||||
      /* clear KEY + IV */
 | 
			
		||||
      XMEMSET(buf, 0, sizeof(buf));
 | 
			
		||||
      zeromem(buf, sizeof(buf));
 | 
			
		||||
   }
 | 
			
		||||
   else {
 | 
			
		||||
      /* sober128_ready() was not called yet, add entropy to ent buffer */
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user