int main() { plan (NO_PLAN); sha256_test (); done_testing (); return(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; }
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; }
bool unabto_test_all(void) { // NABTO_DECLARE_LOCAL_MODULE(NABTO_LOG_APP); bool ret = true; bool r; NABTO_LOG_INFO(("Testing sha256 implementation")); r = sha256_test(); if (!r) { NABTO_LOG_INFO(("sha256 test failed")); ret = false; } #if NABTO_ENABLE_SHA256_TESTS NABTO_LOG_INFO(("Testing hmac_sha256")); r = hmac_sha256_test(); if (!r) { NABTO_LOG_INFO(("hmac sha256 tests failed")); ret = false; } #endif NABTO_LOG_INFO(("Testing AES implementation")); r = aes_test(); if (!r) { NABTO_LOG_INFO(("AES test failed")); ret = false; } NABTO_LOG_INFO(("Testing AES cbc encrypt/decrypt")); r = aes_cbc_test(); if (!r) { NABTO_LOG_INFO(("AES_CBC encrypt/decrypt failed")); ret = false; } NABTO_LOG_INFO(("Testing prfplus")); r = unabto_prfplus_test(); if (!r) { NABTO_LOG_INFO(("Prfplus_sha256 failed")); ret = false; } NABTO_LOG_INFO(("Testing truncated_hmac_sha256_verify_integrity")); truncated_hmac_sha256_verify_integrity_test(&r); //NABTO_LOG_TRACE(("ret %u", r)); if (!r) { NABTO_LOG_INFO(("integrity verification test failed")); ret = false; } NABTO_LOG_INFO(("testing unabto_crypto.c")); r = test_nabto_crypto_create_key_material(); if (!r) { NABTO_LOG_INFO(("unabto_crypto.c test failed")); ret = false; } NABTO_LOG_INFO(("Testing unabto_util")); r = unabto_util_test(); if (!r) { NABTO_LOG_INFO(("testing of unabto_util failed")); ret = false; } NABTO_LOG_INFO(("Testing unabto_buffer")); r = unabto_buffer_test(); if (!r) { NABTO_LOG_ERROR(("Test of unabto_buffer failed")); ret = false; } { int i; NABTO_LOG_INFO(("testing unabto crypto timings")); i = integrity_verify_timing(); NABTO_LOG_INFO(("%i integrity checks in one second.", i)); i = aes_cbc_timing_test(); NABTO_LOG_INFO(("%i aes_cbc en/decryptions in one second.", i)); i = sha256_timing_test(); NABTO_LOG_INFO(("%i 131bytes sha256 hashes in one second.", i)); i = aes_timing_test(); NABTO_LOG_INFO(("%i aes blocks en/decryptiong in one second.", i)); } r = test_state_machine(); if (!r) { NABTO_LOG_ERROR(("Test of unabto stream state machine failed.")); ret = false; } r = unabto_base32_test(); if (!r) { NABTO_LOG_ERROR(("Test of base32 failed.")); ret = false; } if (ret) { NABTO_LOG_INFO(("All uNabto tests succeded")); } else { NABTO_LOG_INFO(("Some uNabto test failed")); } return ret; }