int main(int argc, char *argv[]) { if (argc == 2) { int i; for (i = 0; i < ARRAY_SIZE(key_algs); i++) { if (test_algorithm(key_algs[i], argv[1])) return 1; } } else if (argc == 3 && !strcasecmp(argv[2], "--all")) { /* Test all the algorithms */ int alg; for (alg = 0; alg < kNumAlgorithms; alg++) { if (test_algorithm(alg, argv[1])) return 1; } } else { fprintf(stderr, "Usage: %s <keys_dir> [--all]", argv[0]); return -1; } if (vboot_api_stub_check_memory()) return 255; return gTestSuccess ? 0 : 255; }
int main() { test_tokens(); test_algorithm(); tests_completed(); return 0; }
int main(int argc, char** argv ) { //TEST STATISTIC printf("----------------------------\n"); printf("\t test statistic\n"); printf("----------------------------\n"); test_statistic(); //TEST ALGORITHM printf("----------------------------\n"); printf("\t test algorithm\n"); printf("----------------------------\n"); test_algorithm(); //TEST UTILITY printf("----------------------------\n"); printf("\t test utility\n"); printf("----------------------------\n"); test_utility(); //TEST LOGGING printf("----------------------------\n"); printf("\t test logging\n"); printf("----------------------------\n"); int priority = 10; if(argc > 1) { if( strcmp( argv[1], "log_level_trace") == 0) { priority = 1; } else if(strcmp ( argv[1], "log_level_debug") == 0) { priority = 2; } else if( strcmp(argv[1], "log_level_info") == 0) { priority = 3; } else if (strcmp(argv[1], "log_level_warning") == 0) { priority = 5; } else if ( strcmp (argv[1], "log_level_error") ==0 ) { priority = 6; } } test_logging(priority); }
static void torture_algorithms_blowfish_cbc_hmac_sha2_512(void **state) { struct torture_state *s = *state; test_algorithm(s->ssh.session, "blowfish-cbc", "hmac-sha2-512"); }
static void torture_algorithms_3des_cbc_hmac_sha2_256(void **state) { struct torture_state *s = *state; test_algorithm(s->ssh.session, "3des-cbc", "hmac-sha2-256"); }
static void torture_algorithms_aes256_ctr_hmac_sha2_512(void **state) { struct torture_state *s = *state; test_algorithm(s->ssh.session, "aes256-ctr", "hmac-sha2-512"); }
static void torture_algorithms_aes192_ctr_hmac_sha2_256(void **state) { struct torture_state *s = *state; test_algorithm(s->ssh.session, "aes192-ctr", "hmac-sha2-256"); }
static void torture_algorithms_aes128_ctr_hmac_sha1(void **state) { struct torture_state *s = *state; test_algorithm(s->ssh.session, "aes128-ctr", "hmac-sha1"); }
static void torture_algorithms_aes256_cbc_hmac_sha1(void **state) { struct torture_state *s = *state; test_algorithm(s->ssh.session, "aes256-cbc", "hmac-sha1"); }
int main() { int len[]={10,100,1000,10000,100000,1000000}; int num=sizeof(len) / sizeof(int); int i, j, *number_rand, *number_order, *temp, *number_test; struct timeval tv_begin, tv_end; double diff ; test_algorithm(); // for(i = 0; i < num; i++) // { // printf("%d\n", len[i]); // number_rand = calloc(sizeof(int), len[i]); // number_order = calloc(sizeof(int), len[i]); // number_test = calloc(sizeof(int), len[i]); // temp = calloc(sizeof(int), len[i]); // for (j = 0; j<len[i]; j++) // { // *(number_rand + j) = rand() * 1000 + rand(); // //*(number_order + j) = j; // *(number_order + j) = len[i] - j; //反序 // } // printf("\nthe array length is %d\n",len[i]); // // printf("quickSort:\n"); // memcpy(number_test, number_rand, sizeof(int) * len[i]); // gettimeofday(&tv_begin, NULL); // quickSort(number_test, 0, len[i] - 1); // gettimeofday(&tv_end, NULL); // diff = diff_time(tv_begin, tv_end); // printf("rand number: %f\n",diff); // // memcpy(number_test, number_order, sizeof(int) * len[i]); // gettimeofday(&tv_begin, NULL); // quickSort(number_test, 0, len[i] - 1); // gettimeofday(&tv_end, NULL); // diff = diff_time(tv_begin, tv_end); // printf("order number: %f\n",diff); // // printf("MergeSort:\n"); // memcpy(number_test, number_rand, sizeof(int) * len[i]); // gettimeofday(&tv_begin, NULL); // mergeSort(number_test, 0, len[i]-1, temp); // gettimeofday(&tv_end, NULL); // diff = diff_time(tv_begin, tv_end); // printf("rand number: %f\n",diff); // // memcpy(number_test, number_order, sizeof(int) * len[i]); // gettimeofday(&tv_begin, NULL); // mergeSort(number_test, 0, len[i]-1, temp); // gettimeofday(&tv_end, NULL); // diff = diff_time(tv_begin, tv_end); // printf("order number: %f\n",diff); // // free(number_rand); // free(number_order); // free(temp); // free(number_test); // // } return 0; }
int main(int argc, char *argv[]) { plan_lazy(); dnssec_crypto_init(); // PKCS #11 initialization dnssec_keystore_t *store = NULL; int r = dnssec_keystore_init_pkcs11(&store); if (r == DNSSEC_NOT_IMPLEMENTED_ERROR) { skip_all("not supported"); goto done; } ok(r == DNSSEC_EOK && store, "dnssec_keystore_init_pkcs11()"); char *dso_name = libsofthsm_dso(); if (!dso_name) { skip_all("%s not found, set %s environment variable", SOFTHSM_DSO, ENV_SOFTHSM_DSO); goto done; } ok(dso_name != NULL, "find token DSO"); bool success = token_init(); if (!success) { skip_all("failed to configure and initialize the token"); goto done; } ok(success, "initialize the token"); char config[4096] = { 0 }; r = snprintf(config, sizeof(config), "pkcs11:token=%s;pin-value=%s %s", TOKEN_LABEL, TOKEN_PIN, dso_name); free(dso_name); ok(r > 0 && r < sizeof(config), "build configuration"); // key store access r = dnssec_keystore_init(store, config); ok(r == DNSSEC_NOT_IMPLEMENTED_ERROR, "dnssec_keystore_init(), not implemented"); r = dnssec_keystore_open(store, config); ok(r == DNSSEC_EOK, "dnssec_keystore_open()"); dnssec_list_t *keys = NULL; r = dnssec_keystore_list_keys(store, &keys); ok(r == DNSSEC_EOK && dnssec_list_size(keys) == 0, "dnssec_keystore_list_keys(), empty"); dnssec_list_free_full(keys, NULL, NULL); // key manipulation static const int KEYS_COUNT = 3; static const key_parameters_t *KEYS[] = { &SAMPLE_RSA_KEY, &SAMPLE_ECDSA_KEY, &SAMPLE_DSA_KEY, }; assert(KEYS_COUNT == sizeof(KEYS) / sizeof(*KEYS)); for (int i = 0; i < KEYS_COUNT; i++) { test_algorithm(store, KEYS[i]); } test_key_listing(store, KEYS, KEYS_COUNT); r = dnssec_keystore_close(store); ok(r == DNSSEC_EOK, "dnssec_keystore_close()"); done: dnssec_keystore_deinit(store); dnssec_crypto_cleanup(); token_cleanup(); return 0; }
static void torture_algorithms_blowfish_cbc(void **state) { test_algorithm(*state, "blowfish-cbc"); }
static void torture_algorithms_3des_cbc(void **state) { test_algorithm(*state, "3des-cbc"); }
static void torture_algorithms_aes256_ctr(void **state) { test_algorithm(*state, "aes256-ctr"); }
static void torture_algorithms_aes192_cbc(void **state) { test_algorithm(*state, "aes192-cbc"); }