mirror of
				https://github.com/libssh2/libssh2.git
				synced 2025-11-03 22:13:11 +03:00 
			
		
		
		
	use actual random data with KEX_INIT cookie and packet padding
This commit is contained in:
		
							
								
								
									
										2
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								README
									
									
									
									
									
								
							@@ -4,6 +4,8 @@ libssh2 - SSH2 library
 | 
			
		||||
Version 0.5
 | 
			
		||||
-----------
 | 
			
		||||
 | 
			
		||||
  Fixed KEX_INIT cookie and packet padding to use actual random data
 | 
			
		||||
 | 
			
		||||
  Added DESTDIR support to makefiles (Adam Go<47><6F>biowski -- I hope that character set translates right)
 | 
			
		||||
 | 
			
		||||
Version 0.4
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@
 | 
			
		||||
#include <openssl/bn.h>
 | 
			
		||||
#include <openssl/sha.h>
 | 
			
		||||
#include <openssl/evp.h>
 | 
			
		||||
#include <openssl/rand.h>
 | 
			
		||||
 | 
			
		||||
/* TODO: Switch this to an inline and handle alloc() failures */
 | 
			
		||||
/* Helper macro called from libssh2_kex_method_diffie_hellman_group1_sha1_key_exchange */
 | 
			
		||||
@@ -720,8 +721,7 @@ static int libssh2_kexinit(LIBSSH2_SESSION *session)
 | 
			
		||||
 | 
			
		||||
	*(s++) = SSH_MSG_KEXINIT;
 | 
			
		||||
 | 
			
		||||
	/* TODO: Build a better cookie (and the mice will beat a path to my door...) */
 | 
			
		||||
	memcpy(s, "mysecretMYSECRET", 16);
 | 
			
		||||
	RAND_bytes(s, 16);
 | 
			
		||||
	s += 16;
 | 
			
		||||
 | 
			
		||||
	/* Ennumerating through these lists twice is probably (certainly?) inefficient from a CPU standpoint, but it saves multiple malloc/realloc calls */
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,7 @@
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <openssl/evp.h>
 | 
			
		||||
#include <openssl/rand.h>
 | 
			
		||||
 | 
			
		||||
/* {{{ libssh2_packet_new
 | 
			
		||||
 * Create a new packet and attach it to the brigade
 | 
			
		||||
@@ -627,7 +628,7 @@ int libssh2_packet_write(LIBSSH2_SESSION *session, unsigned char *data, unsigned
 | 
			
		||||
		/* Copy packet to encoding buffer */
 | 
			
		||||
		memcpy(encbuf, buf, 5);
 | 
			
		||||
		memcpy(encbuf + 5, data, data_len);
 | 
			
		||||
		memcpy(encbuf + 5 + data_len, buf + 5, padding_length);
 | 
			
		||||
		RAND_bytes(encbuf + 5 + data_len, padding_length);
 | 
			
		||||
		if (free_data) {
 | 
			
		||||
			LIBSSH2_FREE(session, data);
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user