mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-04 04:32:24 -05:00 
			
		
		
		
	Add test for dhm_parse_dhmfile
This commit is contained in:
		
							parent
							
								
									66dfc5a689
								
							
						
					
					
						commit
						3fec220a33
					
				@ -21,6 +21,7 @@ Bugfix
 | 
			
		||||
     (found by Gergely Budai)
 | 
			
		||||
   * oid_get_numeric_string() used to truncate the output without returning an
 | 
			
		||||
     error if the output buffer was just 1 byte too small.
 | 
			
		||||
   * dhm_parse_dhm() (hence dhm_parse_dhmfile()) did not set dhm->len.
 | 
			
		||||
 | 
			
		||||
= PolarSSL 1.3.5 released on 2014-03-26
 | 
			
		||||
Features
 | 
			
		||||
 | 
			
		||||
@ -460,6 +460,8 @@ int dhm_parse_dhm( dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen
 | 
			
		||||
 | 
			
		||||
    ret = 0;
 | 
			
		||||
 | 
			
		||||
    dhm->len = mpi_size( &dhm->P );
 | 
			
		||||
 | 
			
		||||
exit:
 | 
			
		||||
#if defined(POLARSSL_PEM_PARSE_C)
 | 
			
		||||
    pem_free( &pem );
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								tests/data_files/dhparams.pem
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/data_files/dhparams.pem
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
-----BEGIN DH PARAMETERS-----
 | 
			
		||||
MIGHAoGBAJ419DBEOgmQTzo5qXl5fQcN9TN455wkOL7052HzxxRVMyhYmwQcgJvh
 | 
			
		||||
1sa18fyfR9OiVEMYglOpkqVoGLN7qd5aQNNi5W7/C+VBdHTBJcGZJyyP5B3qcz32
 | 
			
		||||
9mLJKudlVudV0Qxk5qUJaPZ/xupz0NyoVpviuiBOI1gNi8ovSXWzAgEC
 | 
			
		||||
-----END DH PARAMETERS-----
 | 
			
		||||
@ -7,5 +7,8 @@ dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622"
 | 
			
		||||
Diffie-Hellman full exchange #3
 | 
			
		||||
dhm_do_dhm:10:"93450983094850938450983409623982317398171298719873918739182739712938719287391879381271":10:"9345098309485093845098340962223981329819812792137312973297123912791271"
 | 
			
		||||
 | 
			
		||||
Diffie-Hallman load parameters from file
 | 
			
		||||
dhm_file:"data_files/dhparams.pem":"9e35f430443a09904f3a39a979797d070df53378e79c2438bef4e761f3c714553328589b041c809be1d6c6b5f1fc9f47d3a25443188253a992a56818b37ba9de5a40d362e56eff0be5417474c125c199272c8fe41dea733df6f662c92ae76556e755d10c64e6a50968f67fc6ea73d0dca8569be2ba204e23580d8bca2f4975b3":"02":128
 | 
			
		||||
 | 
			
		||||
Diffie-Hellman selftest
 | 
			
		||||
dhm_selftest:
 | 
			
		||||
 | 
			
		||||
@ -97,6 +97,29 @@ void dhm_do_dhm( int radix_P, char *input_P,
 | 
			
		||||
}
 | 
			
		||||
/* END_CASE */
 | 
			
		||||
 | 
			
		||||
/* BEGIN_CASE depends_on:POLARSSL_FS_IO */
 | 
			
		||||
void dhm_file( char *filename, char *p, char *g, int len )
 | 
			
		||||
{
 | 
			
		||||
    dhm_context ctx;
 | 
			
		||||
    mpi P, G;
 | 
			
		||||
 | 
			
		||||
    memset( &ctx, 0, sizeof ctx );
 | 
			
		||||
    mpi_init( &P ); mpi_init( &G );
 | 
			
		||||
 | 
			
		||||
    TEST_ASSERT( mpi_read_string( &P, 16, p ) == 0 );
 | 
			
		||||
    TEST_ASSERT( mpi_read_string( &G, 16, g ) == 0 );
 | 
			
		||||
 | 
			
		||||
    TEST_ASSERT( dhm_parse_dhmfile( &ctx, filename ) == 0 );
 | 
			
		||||
 | 
			
		||||
    TEST_ASSERT( ctx.len == (size_t) len );
 | 
			
		||||
    TEST_ASSERT( mpi_cmp_mpi( &ctx.P, &P ) == 0 );
 | 
			
		||||
    TEST_ASSERT( mpi_cmp_mpi( &ctx.G, &G ) == 0 );
 | 
			
		||||
 | 
			
		||||
    mpi_free( &P ); mpi_free( &G );
 | 
			
		||||
    dhm_free( &ctx );
 | 
			
		||||
}
 | 
			
		||||
/* END_CASE */
 | 
			
		||||
 | 
			
		||||
/* BEGIN_CASE depends_on:POLARSSL_SELF_TEST */
 | 
			
		||||
void dhm_selftest()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user