Fix some dependencies/warnings in programs

This commit is contained in:
Manuel Pégourié-Gonnard 2013-09-18 18:57:10 +02:00
parent 1032c1d3ec
commit 92e5b59355
6 changed files with 41 additions and 32 deletions

View File

@ -43,22 +43,22 @@
#define GENERATOR "4"
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_ENTROPY_C) || \
!defined(POLARSSL_FS_IO) || !defined(POLARSSL_CTR_DRBG_C)
!defined(POLARSSL_FS_IO) || !defined(POLARSSL_CTR_DRBG_C) || \
!defined(POLARSSL_GENPRIME)
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_BIGNUM_C and/or POLARSSL_ENTROPY_C and/or "
"POLARSSL_FS_IO and/or POLARSSL_CTR_DRBG_C not defined.\n");
"POLARSSL_FS_IO and/or POLARSSL_CTR_DRBG_C and/or "
"POLARSSL_GENPRIME not defined.\n");
return( 0 );
}
#else
int main( int argc, char *argv[] )
{
int ret = 1;
#if defined(POLARSSL_GENPRIME)
mpi G, P, Q;
entropy_context entropy;
ctr_drbg_context ctr_drbg;
@ -147,9 +147,6 @@ int main( int argc, char *argv[] )
exit:
mpi_free( &G ); mpi_free( &P ); mpi_free( &Q );
#else
printf( "\n ! Prime-number generation is not available.\n\n" );
#endif
#if defined(_WIN32)
printf( " Press Enter to exit this program.\n" );
@ -159,4 +156,4 @@ exit:
return( ret );
}
#endif /* POLARSSL_BIGNUM_C && POLARSSL_ENTROPY_C && POLARSSL_FS_IO &&
POLARSSL_CTR_DRBG_C */
POLARSSL_CTR_DRBG_C && POLARSSL_GENPRIME */

View File

@ -169,8 +169,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
polarssl_strerror( ret, buf, sizeof(buf) );
printf( " failed\n ! pk_parse_keyfile returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! pk_parse_keyfile returned -0x%04x\n", -ret );
goto exit;
}
@ -223,8 +222,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
polarssl_strerror( ret, buf, sizeof(buf) );
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x\n", -ret );
goto exit;
}
@ -260,6 +258,11 @@ int main( int argc, char *argv[] )
exit:
#if defined(POLARSSL_ERROR_C)
polarssl_strerror( ret, buf, sizeof(buf) );
printf( " ! Last error was: %s\n", buf );
#endif
pk_free( &pk );
#if defined(_WIN32)

View File

@ -97,9 +97,7 @@ int main( int argc, char *argv[] )
if( ( ret = pk_parse_keyfile( &pk, argv[1], "" ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! pk_parse_keyfile returned -0x%04x - %s\n\n", -ret,
buf );
printf( " failed\n ! pk_parse_keyfile returned -0x%04x\n", -ret );
goto exit;
}
@ -131,9 +129,7 @@ int main( int argc, char *argv[] )
if( ( ret = pk_decrypt( &pk, buf, i, result, &olen, sizeof(result),
ctr_drbg_random, &ctr_drbg ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! pk_decrypt returned -0x%04x - %s\n\n", -ret,
buf );
printf( " failed\n ! pk_decrypt returned -0x%04x\n", -ret );
goto exit;
}
@ -145,6 +141,11 @@ int main( int argc, char *argv[] )
exit:
#if defined(POLARSSL_ERROR_C)
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " ! Last error was: %s\n", buf );
#endif
#if defined(_WIN32)
printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();

View File

@ -84,8 +84,7 @@ int main( int argc, char *argv[] )
(const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! ctr_drbg_init returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! ctr_drbg_init returned -0x%04x\n", -ret );
goto exit;
}
@ -96,8 +95,7 @@ int main( int argc, char *argv[] )
if( ( ret = pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x\n", -ret );
goto exit;
}
@ -119,8 +117,7 @@ int main( int argc, char *argv[] )
buf, &olen, sizeof(buf),
ctr_drbg_random, &ctr_drbg ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! pk_encrypt returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! pk_encrypt returned -0x%04x\n", -ret );
goto exit;
}
@ -144,6 +141,11 @@ int main( int argc, char *argv[] )
exit:
#if defined(POLARSSL_ERROR_C)
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " ! Last error was: %s\n", buf );
#endif
#if defined(_WIN32)
printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();

View File

@ -93,8 +93,7 @@ int main( int argc, char *argv[] )
(const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! ctr_drbg_init returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! ctr_drbg_init returned -0x%04x\n", -ret );
goto exit;
}
@ -126,8 +125,7 @@ int main( int argc, char *argv[] )
if( ( ret = pk_sign( &pk, POLARSSL_MD_SHA1, hash, 0, buf, &olen,
ctr_drbg_random, &ctr_drbg ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! pk_sign returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! pk_sign returned -0x%04x\n", -ret );
goto exit;
}
@ -156,6 +154,11 @@ int main( int argc, char *argv[] )
exit:
pk_free( &pk );
#if defined(POLARSSL_ERROR_C)
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " ! Last error was: %s\n", buf );
#endif
#if defined(_WIN32)
printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();

View File

@ -84,8 +84,7 @@ int main( int argc, char *argv[] )
if( ( ret = pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x\n", -ret );
goto exit;
}
@ -122,8 +121,7 @@ int main( int argc, char *argv[] )
if( ( ret = pk_verify( &pk, POLARSSL_MD_SHA1, hash, 0,
buf, i ) ) != 0 )
{
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " failed\n ! pk_verify returned -0x%04x - %s\n\n", -ret, buf );
printf( " failed\n ! pk_verify returned -0x%04x\n", -ret );
goto exit;
}
@ -134,6 +132,11 @@ int main( int argc, char *argv[] )
exit:
pk_free( &pk );
#if defined(POLARSSL_ERROR_C)
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
printf( " ! Last error was: %s\n", buf );
#endif
#if defined(_WIN32)
printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();