mirror of
				https://github.com/clearml/dropbear
				synced 2025-06-26 18:17:32 +00:00 
			
		
		
		
	/dev/random blocks on busy servers too.
This commit is contained in:
		
							parent
							
								
									6ba2b2b384
								
							
						
					
					
						commit
						545de7a3a1
					
				
							
								
								
									
										1
									
								
								gendss.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								gendss.c
									
									
									
									
									
								
							@ -57,7 +57,6 @@ dropbear_dss_key * gen_dss_priv_key(unsigned int size) {
 | 
				
			|||||||
	m_mp_init_multi(key->p, key->q, key->g, key->y, key->x, NULL);
 | 
						m_mp_init_multi(key->p, key->q, key->g, key->y, key->x, NULL);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	seedrandom();
 | 
						seedrandom();
 | 
				
			||||||
	seedstrongrandom();
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	getq(key);
 | 
						getq(key);
 | 
				
			||||||
	getp(key, size);
 | 
						getp(key, size);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								genrsa.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								genrsa.c
									
									
									
									
									
								
							@ -56,7 +56,6 @@ dropbear_rsa_key * gen_rsa_priv_key(unsigned int size) {
 | 
				
			|||||||
			&pminus, &lcm, &qminus, NULL);
 | 
								&pminus, &lcm, &qminus, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	seedrandom();
 | 
						seedrandom();
 | 
				
			||||||
	seedstrongrandom();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (mp_set_int(key->e, RSA_E) != MP_OKAY) {
 | 
						if (mp_set_int(key->e, RSA_E) != MP_OKAY) {
 | 
				
			||||||
		fprintf(stderr, "RSA generation failed\n");
 | 
							fprintf(stderr, "RSA generation failed\n");
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								random.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								random.c
									
									
									
									
									
								
							@ -155,24 +155,6 @@ static void write_urandom()
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* add entropy from the stronger, blocking source /dev/random. Only used
 | 
					 | 
				
			||||||
 * for generating persistent private keys (RSA and DSS) */
 | 
					 | 
				
			||||||
void seedstrongrandom()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/* We assume that PRNGD is a strong source, so don't need to do anything here */
 | 
					 | 
				
			||||||
#ifndef DROPBEAR_PRNGD_SOCKET
 | 
					 | 
				
			||||||
	hash_state hs;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
 | 
					 | 
				
			||||||
	if (process_file(&hs, "/dev/random", INIT_SEED_SIZE, 0) 
 | 
					 | 
				
			||||||
			!= DROPBEAR_SUCCESS) {
 | 
					 | 
				
			||||||
		dropbear_exit("Failure reading random device %s", "/dev/random");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sha1_done(&hs, hashpool);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Initialise the prng from /dev/urandom or prngd. This function can
 | 
					/* Initialise the prng from /dev/urandom or prngd. This function can
 | 
				
			||||||
 * be called multiple times */
 | 
					 * be called multiple times */
 | 
				
			||||||
void seedrandom() {
 | 
					void seedrandom() {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								random.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								random.h
									
									
									
									
									
								
							@ -27,7 +27,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct mp_int;
 | 
					struct mp_int;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void seedstrongrandom();
 | 
					 | 
				
			||||||
void seedrandom();
 | 
					void seedrandom();
 | 
				
			||||||
void genrandom(unsigned char* buf, unsigned int len);
 | 
					void genrandom(unsigned char* buf, unsigned int len);
 | 
				
			||||||
void addrandom(char * buf, unsigned int len);
 | 
					void addrandom(char * buf, unsigned int len);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user