Esempio n. 1
0
int main(int argc, char *argv[])
{
	int i, err = 0;

	char **p, **r, *t;
	unsigned char md[MD5_LENGTH];

	p = test;
	r = ret;

	i = 1;
	while (*p != NULL) {
		md5_test(*p, strlen(*p), md);
		t = pt(md);

		if (strcmp(t, (char *)*r) != 0) {
			printf("error calculating MD5 on '%s'\n", *p);
			printf("got %s instead of %s\n", t, *r);
			err++;
		} else {
			printf("test %d ok\n", i);
		}
		i++;
		p++;
		r++;
	}

	return err;
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
	DBG_PRINT_S("hello");
	md5_test("abc");

	return 0;
}
Esempio n. 3
0
File: main.c Progetto: jwcxz/scln
int main(void )
{
unsigned char ret=0;
	if(md5_test()) ret|=0x01;
	if(SkipJack_test())ret|=0x10;
	if(AES_test())ret|=0x20;
	if(sha_test()) ret|=0x02;	
	if(des_test()) ret|=0x04;
	if(rsa_test()) ret|=0x08;
	
	return ret;
}
Esempio n. 4
0
void ctaocrypt_test(void* args)
{
    int ret = 0;

    ((func_args*)args)->return_code = -1; /* error state */
    
    if ( (ret = md5_test()) ) 
        err_sys("MD5      test failed!\n", ret);
    else
        printf( "MD5      test passed!\n");

#ifndef NO_MD4
    if ( (ret = md4_test()) ) 
        err_sys("MD4      test failed!\n", ret);
    else
        printf( "MD4      test passed!\n");
#endif

    if ( (ret = sha_test()) ) 
        err_sys("SHA      test failed!\n", ret);
    else
        printf( "SHA      test passed!\n");

#ifndef NO_SHA256
    if ( (ret = sha256_test()) ) 
        err_sys("SHA-256  test failed!\n", ret);
    else
        printf( "SHA-256  test passed!\n");
#endif

#ifndef NO_HMAC
    if ( (ret = hmac_test()) ) 
        err_sys("HMAC     test failed!\n", ret);
    else
        printf( "HMAC     test passed!\n");
#endif

    if ( (ret = arc4_test()) )
        err_sys("ARC4     test failed!\n", ret);
    else
        printf( "ARC4     test passed!\n");

#ifndef NO_HC128
    if ( (ret = hc128_test()) )
        err_sys("HC-128   test failed!\n", ret);
    else
        printf( "HC-128   test passed!\n");
#endif

#ifndef NO_RABBIT
    if ( (ret = rabbit_test()) )
        err_sys("Rabbit   test failed!\n", ret);
    else
        printf( "Rabbit   test passed!\n");
#endif

#ifndef NO_DES
    if ( (ret = des_test()) )
        err_sys("DES      test failed!\n", ret);
    else
        printf( "DES      test passed!\n");
#endif

#ifndef NO_DES3
    if ( (ret = des3_test()) )
        err_sys("DES3     test failed!\n", ret);
    else
        printf( "DES3     test passed!\n");
#endif

#ifndef NO_AES
    if ( (ret = aes_test()) )
        err_sys("AES      test failed!\n", ret);
    else
        printf( "AES      test passed!\n");
#endif

    if ( (ret = random_test()) )
        err_sys("RANDOM   test failed!\n", ret);
    else
        printf( "RANDOM   test passed!\n");

    if ( (ret = rsa_test()) ) 
        err_sys("RSA      test failed!\n", ret);
    else
        printf( "RSA      test passed!\n");

#ifndef NO_DH
    if ( (ret = dh_test()) ) 
        err_sys("DH       test failed!\n", ret);
    else
        printf( "DH       test passed!\n");
#endif

#ifndef NO_DSA
    if ( (ret = dsa_test()) ) 
        err_sys("DSA      test failed!\n", ret);
    else
        printf( "DSA      test passed!\n");
#endif
    
#ifdef OPENSSL_EXTRA
    if ( (ret = openssl_test()) ) 
        err_sys("OPENSSL  test failed!\n", ret);
    else
        printf( "OPENSSL  test passed!\n");
#endif

    ((func_args*)args)->return_code = ret;
}
Esempio n. 5
0
int HashTest(void)
{
    int ret = 0;

    printf(" Begin HASH Tests\n");

#ifndef NO_MD4
    if ( (ret = md4_test()) ) {
        printf( "   MD4      test failed!\n");
        return ret; 
    } else
        printf( "   MD4      test passed!\n");
#endif

#ifndef NO_MD5
    if ( (ret = md5_test()) ) {
        printf( "   MD5      test failed!\n");
        return ret; 
    } else
        printf( "   MD5      test passed!\n");
#endif
    
#ifndef NO_SHA
    if ( (ret = sha_test()) ) {
        printf( "   SHA      test failed!\n");
        return ret; 
    } else
        printf( "   SHA      test passed!\n");
#endif
    
#ifndef NO_SHA256
    if ( (ret = sha256_test()) ) {
        printf( "   SHA-256  test failed!\n");
        return ret; 
    } else
        printf( "   SHA-256  test passed!\n");
#endif

#ifdef CYASSL_SHA512
    if ( (ret = sha512_test()) ) {
        printf( "   SHA-512  test failed!\n");
        return ret; 
    } else
        printf( "   SHA-512  test passed!\n");
#endif

#ifdef CYASSL_SHA384
    if ( (ret = sha384_test()) ) {
        printf( "   SHA-384  test failed!\n");
        return ret; 
    } else
        printf( "   SHA-384  test passed!\n");
#endif

#ifdef CYASSL_RIPEMD
    if ( (ret = ripemd_test()) ) {
        printf( "   RIPEMD   test failed!\n");
        return ret; 
    } else
        printf( "   RIPEMD   test passed!\n");
#endif

#ifndef NO_HMAC
    #ifndef NO_MD5
        if ( (ret = hmac_md5_test()) ) {
            printf( "   HMAC-MD5 test failed!\n");
            return ret; 
        } else
            printf( "   HMAC-MD5 test passed!\n");
    #endif

    if ( (ret = hmac_sha_test()) ) 
        printf( "   HMAC-SHA test failed!\n");
    else
        printf( "   HMAC-SHA test passed!\n");

    #ifndef NO_SHA256
        if ( (ret = hmac_sha256_test()) ) 
            printf( "   HMAC-SHA256 test failed!\n");
        else
            printf( "   HMAC-SHA256 test passed!\n");
    #endif

    #ifdef CYASSL_SHA384
        if ( (ret = hmac_sha384_test()) ) 
            printf( "   HMAC-SHA384 test failed!\n");
        else
            printf( "   HMAC-SHA384 test passed!\n");
    #endif
#endif

    printf(" End HASH Tests\n");
    
    return 0;
}
Esempio n. 6
0
int main(int argc,char **argv)
    {

    printf("\tFIPS-mode test application\n\n");

    /* Load entropy from external file, if any */
    RAND_load_file(".rnd", 1024);

    if (argv[1]) {
        /* Corrupted KAT tests */
        if (!strcmp(argv[1], "aes")) {
            FIPS_corrupt_aes();
            printf("AES encryption/decryption with corrupted KAT...\n");
        } else if (!strcmp(argv[1], "des")) {
            FIPS_corrupt_des();
            printf("DES-ECB encryption/decryption with corrupted KAT...\n");
        } else if (!strcmp(argv[1], "dsa")) {
            FIPS_corrupt_dsa();
            printf("DSA key generation and signature validation with corrupted KAT...\n");
        } else if (!strcmp(argv[1], "rsa")) {
            FIPS_corrupt_rsa();
            printf("RSA key generation and encryption/decryption with corrupted KAT...\n");
        } else if (!strcmp(argv[1], "sha1")) {
            FIPS_corrupt_sha1();
            printf("SHA-1 hash with corrupted KAT...\n");
	} else if (!strcmp(argv[1], "rng")) {
	    FIPS_corrupt_rng();
	    printf("RNG test with corrupted KAT...\n");
        } else {
            printf("Bad argument \"%s\"\n", argv[1]);
            exit(1);
        }
        if (!FIPS_mode_set(1))
   	    {
	    ERR_load_crypto_strings();
	    ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE));
            printf("Power-up self test failed\n");
	    exit(1);
	}
        printf("Power-up self test successful\n");
        exit(0);
    }

    /* Non-Approved cryptographic operation
    */
    printf("1. Non-Approved cryptographic operation test...\n");
    printf("\ta. Excluded algorithm (MD5)...");
    printf( md5_test() ? "successful\n" :  Fail("FAILED!\n") );
    printf("\tb. Included algorithm (D-H)...");
    printf( dh_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* Power-up self test
    */
    ERR_clear_error();
    printf("2. Automatic power-up self test...");
    if (!FIPS_mode_set(1))
	{
	ERR_load_crypto_strings();
	ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE));
        printf(Fail("FAILED!\n"));
	exit(1);
	}
    printf("successful\n");

    /* AES encryption/decryption
    */
    printf("3. AES encryption/decryption...");
    printf( FIPS_aes_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* RSA key generation and encryption/decryption
    */
    printf("4. RSA key generation and encryption/decryption...");
    printf( FIPS_rsa_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* DES-CBC encryption/decryption
    */
    printf("5. DES-ECB encryption/decryption...");
    printf( FIPS_des_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* DSA key generation and signature validation
    */
    printf("6. DSA key generation and signature validation...");
    printf( FIPS_dsa_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* SHA-1 hash
    */
    printf("7a. SHA-1 hash...");
    printf( FIPS_sha1_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* SHA-256 hash
    */
    printf("7b. SHA-256 hash...");
    printf( FIPS_sha256_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* SHA-512 hash
    */
    printf("7c. SHA-512 hash...");
    printf( FIPS_sha512_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* HMAC-SHA-1 hash
    */
    printf("7d. SHA-1 hash...");
    printf( FIPS_hmac_sha1_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* HMAC-SHA-224 hash
    */
    printf("7e. SHA-224 hash...");
    printf( FIPS_hmac_sha224_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* HMAC-SHA-256 hash
    */
    printf("7f. SHA-256 hash...");
    printf( FIPS_hmac_sha256_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* HMAC-SHA-384 hash
    */
    printf("7g. SHA-384 hash...");
    printf( FIPS_hmac_sha384_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* HMAC-SHA-512 hash
    */
    printf("7h. SHA-512 hash...");
    printf( FIPS_hmac_sha512_test() ? "successful\n" :  Fail("FAILED!\n") );

    /* Non-Approved cryptographic operation
    */
    printf("8. Non-Approved cryptographic operation test...\n");
    printf("\ta. Excluded algorithm (MD5)...");
    printf( md5_test() ? Fail("passed INCORRECTLY!\n")
	    : "failed as expected\n" );
    printf("\tb. Included algorithm (D-H)...");
    printf( dh_test() ? "successful as expected\n"
	    : Fail("failed INCORRECTLY!\n") );

    /* Zeroization
    */
    printf("9. Zero-ization...\n");
    Zeroize();

    printf("\nAll tests completed with %d errors\n", Error);
    return 0;
    }