Fix some dependencies/warnings in programs
This commit is contained in:
parent
1032c1d3ec
commit
92e5b59355
@ -43,22 +43,22 @@
|
|||||||
#define GENERATOR "4"
|
#define GENERATOR "4"
|
||||||
|
|
||||||
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_ENTROPY_C) || \
|
#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[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
((void) argc);
|
((void) argc);
|
||||||
((void) argv);
|
((void) argv);
|
||||||
|
|
||||||
printf("POLARSSL_BIGNUM_C and/or POLARSSL_ENTROPY_C and/or "
|
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 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
|
||||||
#if defined(POLARSSL_GENPRIME)
|
|
||||||
mpi G, P, Q;
|
mpi G, P, Q;
|
||||||
entropy_context entropy;
|
entropy_context entropy;
|
||||||
ctr_drbg_context ctr_drbg;
|
ctr_drbg_context ctr_drbg;
|
||||||
@ -147,9 +147,6 @@ int main( int argc, char *argv[] )
|
|||||||
exit:
|
exit:
|
||||||
|
|
||||||
mpi_free( &G ); mpi_free( &P ); mpi_free( &Q );
|
mpi_free( &G ); mpi_free( &P ); mpi_free( &Q );
|
||||||
#else
|
|
||||||
printf( "\n ! Prime-number generation is not available.\n\n" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
printf( " Press Enter to exit this program.\n" );
|
printf( " Press Enter to exit this program.\n" );
|
||||||
@ -159,4 +156,4 @@ exit:
|
|||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
#endif /* POLARSSL_BIGNUM_C && POLARSSL_ENTROPY_C && POLARSSL_FS_IO &&
|
#endif /* POLARSSL_BIGNUM_C && POLARSSL_ENTROPY_C && POLARSSL_FS_IO &&
|
||||||
POLARSSL_CTR_DRBG_C */
|
POLARSSL_CTR_DRBG_C && POLARSSL_GENPRIME */
|
||||||
|
@ -169,8 +169,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
polarssl_strerror( ret, buf, sizeof(buf) );
|
printf( " failed\n ! pk_parse_keyfile returned -0x%04x\n", -ret );
|
||||||
printf( " failed\n ! pk_parse_keyfile returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,8 +222,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
polarssl_strerror( ret, buf, sizeof(buf) );
|
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x\n", -ret );
|
||||||
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,6 +258,11 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
|
#if defined(POLARSSL_ERROR_C)
|
||||||
|
polarssl_strerror( ret, buf, sizeof(buf) );
|
||||||
|
printf( " ! Last error was: %s\n", buf );
|
||||||
|
#endif
|
||||||
|
|
||||||
pk_free( &pk );
|
pk_free( &pk );
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -97,9 +97,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ( ret = pk_parse_keyfile( &pk, argv[1], "" ) ) != 0 )
|
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\n", -ret );
|
||||||
printf( " failed\n ! pk_parse_keyfile returned -0x%04x - %s\n\n", -ret,
|
|
||||||
buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,9 +129,7 @@ int main( int argc, char *argv[] )
|
|||||||
if( ( ret = pk_decrypt( &pk, buf, i, result, &olen, sizeof(result),
|
if( ( ret = pk_decrypt( &pk, buf, i, result, &olen, sizeof(result),
|
||||||
ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||||
{
|
{
|
||||||
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
printf( " failed\n ! pk_decrypt returned -0x%04x\n", -ret );
|
||||||
printf( " failed\n ! pk_decrypt returned -0x%04x - %s\n\n", -ret,
|
|
||||||
buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +141,11 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
|
#if defined(POLARSSL_ERROR_C)
|
||||||
|
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
||||||
|
printf( " ! Last error was: %s\n", buf );
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
printf( " + Press Enter to exit this program.\n" );
|
printf( " + Press Enter to exit this program.\n" );
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
|
@ -84,8 +84,7 @@ int main( int argc, char *argv[] )
|
|||||||
(const unsigned char *) pers,
|
(const unsigned char *) pers,
|
||||||
strlen( pers ) ) ) != 0 )
|
strlen( pers ) ) ) != 0 )
|
||||||
{
|
{
|
||||||
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
printf( " failed\n ! ctr_drbg_init returned -0x%04x\n", -ret );
|
||||||
printf( " failed\n ! ctr_drbg_init returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +95,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ( ret = pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 )
|
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\n", -ret );
|
||||||
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +117,7 @@ int main( int argc, char *argv[] )
|
|||||||
buf, &olen, sizeof(buf),
|
buf, &olen, sizeof(buf),
|
||||||
ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||||
{
|
{
|
||||||
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
printf( " failed\n ! pk_encrypt returned -0x%04x\n", -ret );
|
||||||
printf( " failed\n ! pk_encrypt returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +141,11 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
|
#if defined(POLARSSL_ERROR_C)
|
||||||
|
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
||||||
|
printf( " ! Last error was: %s\n", buf );
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
printf( " + Press Enter to exit this program.\n" );
|
printf( " + Press Enter to exit this program.\n" );
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
|
@ -93,8 +93,7 @@ int main( int argc, char *argv[] )
|
|||||||
(const unsigned char *) pers,
|
(const unsigned char *) pers,
|
||||||
strlen( pers ) ) ) != 0 )
|
strlen( pers ) ) ) != 0 )
|
||||||
{
|
{
|
||||||
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
printf( " failed\n ! ctr_drbg_init returned -0x%04x\n", -ret );
|
||||||
printf( " failed\n ! ctr_drbg_init returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +125,7 @@ int main( int argc, char *argv[] )
|
|||||||
if( ( ret = pk_sign( &pk, POLARSSL_MD_SHA1, hash, 0, buf, &olen,
|
if( ( ret = pk_sign( &pk, POLARSSL_MD_SHA1, hash, 0, buf, &olen,
|
||||||
ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||||
{
|
{
|
||||||
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
printf( " failed\n ! pk_sign returned -0x%04x\n", -ret );
|
||||||
printf( " failed\n ! pk_sign returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,6 +154,11 @@ int main( int argc, char *argv[] )
|
|||||||
exit:
|
exit:
|
||||||
pk_free( &pk );
|
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)
|
#if defined(_WIN32)
|
||||||
printf( " + Press Enter to exit this program.\n" );
|
printf( " + Press Enter to exit this program.\n" );
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
|
@ -84,8 +84,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ( ret = pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 )
|
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\n", -ret );
|
||||||
printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +121,7 @@ int main( int argc, char *argv[] )
|
|||||||
if( ( ret = pk_verify( &pk, POLARSSL_MD_SHA1, hash, 0,
|
if( ( ret = pk_verify( &pk, POLARSSL_MD_SHA1, hash, 0,
|
||||||
buf, i ) ) != 0 )
|
buf, i ) ) != 0 )
|
||||||
{
|
{
|
||||||
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
printf( " failed\n ! pk_verify returned -0x%04x\n", -ret );
|
||||||
printf( " failed\n ! pk_verify returned -0x%04x - %s\n\n", -ret, buf );
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +132,11 @@ int main( int argc, char *argv[] )
|
|||||||
exit:
|
exit:
|
||||||
pk_free( &pk );
|
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)
|
#if defined(_WIN32)
|
||||||
printf( " + Press Enter to exit this program.\n" );
|
printf( " + Press Enter to exit this program.\n" );
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
|
Loading…
Reference in New Issue
Block a user