Beispiel #1
0
int main( int argc, char *argv[] )
{
    int ret = 0, v;
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
    unsigned char buf[1000000];
#endif

    if( argc == 2 && strcmp( argv[1], "-quiet" ) == 0 )
        v = 0;
    else
    {
        v = 1;
        printf( "\n" );
    }

#if defined(POLARSSL_SELF_TEST)

#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
    memory_buffer_alloc_init( buf, sizeof(buf) );
#endif

#if defined(POLARSSL_MD2_C)
    if( ( ret = md2_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_MD4_C)
    if( ( ret = md4_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_MD5_C)
    if( ( ret = md5_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_RIPEMD160_C)
    if( ( ret = ripemd160_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_SHA1_C)
    if( ( ret = sha1_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_SHA256_C)
    if( ( ret = sha256_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_SHA512_C)
    if( ( ret = sha512_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_ARC4_C)
    if( ( ret = arc4_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_DES_C)
    if( ( ret = des_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_AES_C)
    if( ( ret = aes_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_GCM_C)
    if( ( ret = gcm_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_BASE64_C)
    if( ( ret = base64_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_BIGNUM_C)
    if( ( ret = mpi_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_RSA_C)
    if( ( ret = rsa_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_X509_USE_C)
    if( ( ret = x509_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_XTEA_C)
    if( ( ret = xtea_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_CAMELLIA_C)
    if( ( ret = camellia_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_CTR_DRBG_C)
    if( ( ret = ctr_drbg_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_HMAC_DRBG_C)
    if( ( ret = hmac_drbg_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_ECP_C)
    if( ( ret = ecp_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_DHM_C)
    if( ( ret = dhm_self_test( v ) ) != 0 )
        return( ret );
#endif

/* Slow tests last */

#if defined(POLARSSL_PBKDF2_C)
    if( ( ret = pbkdf2_self_test( v ) ) != 0 )
        return( ret );
#else
#if defined(POLARSSL_PKCS5_C)
    if( ( ret = pkcs5_self_test( v ) ) != 0 )
        return( ret );
#endif
#endif

/*
 * Not reliable enough yet
 */
#if 0 && defined(POLARSSL_TIMING_C)
    if( ( ret = timing_self_test( v ) ) != 0 )
        return( ret );
#endif

#else
    printf( " POLARSSL_SELF_TEST not defined.\n" );
#endif

    if( v != 0 )
    {
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && defined(POLARSSL_MEMORY_DEBUG)
        memory_buffer_alloc_status();
#endif

        printf( "  [ All tests passed ]\n\n" );
#if defined(_WIN32)
        printf( "  Press Enter to exit this program.\n" );
        fflush( stdout ); getchar();
#endif
    }
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
    memory_buffer_alloc_free();
#endif

    return( ret );
}
Beispiel #2
0
int main(int argc, char *argv[])
{
	int ret, v;

	if (argc == 2 && strcmp(argv[1], "-quiet") == 0)
		v = 0;
	else {
		v = 1;
		printf("\n");
	}

#if defined(TROPICSSL_MD2_C)
	if ((ret = md2_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_MD4_C)
	if ((ret = md4_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_MD5_C)
	if ((ret = md5_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_SHA1_C)
	if ((ret = sha1_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_SHA2_C)
	if ((ret = sha2_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_SHA4_C)
	if ((ret = sha4_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_ARC4_C)
	if ((ret = arc4_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_DES_C)
	if ((ret = des_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_AES_C)
	if ((ret = aes_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_BASE64_C)
	if ((ret = base64_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_BIGNUM_C)
	if ((ret = mpi_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_RSA_C)
	if ((ret = rsa_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_X509_C)
	if ((ret = x509_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_XTEA_C)
	if ((ret = xtea_self_test(v)) != 0)
		return (ret);
#endif

#if defined(TROPICSSL_CAMELLIA_C)
	if ((ret = camellia_self_test(v)) != 0)
		return (ret);
#endif

	if (v != 0) {
		printf("  [ All tests passed ]\n\n");
#ifdef WIN32
		printf("  Press Enter to exit this program.\n");
		fflush(stdout);
		getchar();
#endif
	}

	return (ret);
}
Beispiel #3
0
int main( int argc, char *argv[] )
{
    int ret, v=1;

    // USART options.
    static usart_serial_options_t USART_SERIAL_OPTIONS =
    {
            .baudrate     = USART_SERIAL_EXAMPLE_BAUDRATE,
            .charlength   = USART_SERIAL_CHAR_LENGTH,
            .paritytype   = USART_SERIAL_PARITY,
            .stopbits     = USART_SERIAL_STOP_BIT
    };

    sysclk_init();

    // Initialize the board.
    // The board-specific conf_board.h file contains the configuration of the board
    // initialization.
    board_init();

    // Initialize Serial Interface using Stdio Library
    stdio_serial_init(USART_SERIAL_EXAMPLE,&USART_SERIAL_OPTIONS);

    printf( "Start Self Test\n" );

#if defined(POLARSSL_MD2_C)
    if( ( ret = md2_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_MD4_C)
    if( ( ret = md4_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_MD5_C)
    if( ( ret = md5_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_SHA1_C)
    if( ( ret = sha1_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_SHA2_C)
    if( ( ret = sha2_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_SHA4_C)
    if( ( ret = sha4_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_ARC4_C)
    if( ( ret = arc4_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_DES_C)
    if( ( ret = des_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_AES_C)
    if( ( ret = aes_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_BASE64_C)
    if( ( ret = base64_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_BIGNUM_C)
    if( ( ret = mpi_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_RSA_C)
    if( ( ret = rsa_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_X509_PARSE_C)
    if( ( ret = x509_self_test( v ) ) != 0 );
//        return( ret );
#endif

#if defined(POLARSSL_XTEA_C)
    if( ( ret = xtea_self_test( v ) ) != 0 )
        return( ret );
#endif

#if defined(POLARSSL_CAMELLIA_C)
    if( ( ret = camellia_self_test( v ) ) != 0 )
        return( ret );
#endif

    if( v != 0 )
    {
        printf( "  [ All tests passed ]\n\n" );
#ifdef WIN32
        printf( "  Press Enter to exit this program.\n" );
        fflush( stdout ); getchar();
#endif
    }

    return( ret );
}