mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 00:06:32 +01:00
- mpi_init() and mpi_free() only accept a single argument and do not accept variable arguments anymore. This prevents unexpected memory corruption in a number of use cases.
This commit is contained in:
parent
f968857a82
commit
6c591fab72
11 changed files with 230 additions and 137 deletions
|
|
@ -49,7 +49,7 @@ int main( void )
|
|||
havege_state hs;
|
||||
FILE *fout;
|
||||
|
||||
mpi_init( &G, &P, &Q, NULL );
|
||||
mpi_init( &G ); mpi_init( &P ); mpi_init( &Q );
|
||||
mpi_read_string( &G, 10, GENERATOR );
|
||||
|
||||
printf( "\n . Seeding the random number generator..." );
|
||||
|
|
@ -113,7 +113,7 @@ int main( void )
|
|||
|
||||
exit:
|
||||
|
||||
mpi_free( &Q, &P, &G, NULL );
|
||||
mpi_free( &G ); mpi_free( &P ); mpi_free( &Q );
|
||||
#else
|
||||
printf( "\n ! Prime-number generation is not available.\n\n" );
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@ int main( void )
|
|||
{
|
||||
mpi E, P, Q, N, H, D, X, Y, Z;
|
||||
|
||||
mpi_init( &E, &P, &Q, &N, &H,
|
||||
&D, &X, &Y, &Z, NULL );
|
||||
mpi_init( &E ); mpi_init( &P ); mpi_init( &Q ); mpi_init( &N );
|
||||
mpi_init( &H ); mpi_init( &D ); mpi_init( &X ); mpi_init( &Y );
|
||||
mpi_init( &Z );
|
||||
|
||||
mpi_read_string( &P, 10, "2789" );
|
||||
mpi_read_string( &Q, 10, "3203" );
|
||||
|
|
@ -69,8 +70,9 @@ int main( void )
|
|||
mpi_write_file( " Z (decrypted) = Y^D mod N = ", &Z, 10, NULL );
|
||||
printf( "\n" );
|
||||
|
||||
mpi_free( &Z, &Y, &X, &D, &H,
|
||||
&N, &Q, &P, &E, NULL );
|
||||
mpi_free( &E ); mpi_free( &P ); mpi_free( &Q ); mpi_free( &N );
|
||||
mpi_free( &H ); mpi_free( &D ); mpi_free( &X ); mpi_free( &Y );
|
||||
mpi_free( &Z );
|
||||
|
||||
#ifdef WIN32
|
||||
printf( " Press Enter to exit this program.\n" );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue