int main(int argc, char *argv[]) { const char *type = (argc > 1) ? argv[1] : "i"; GenerateTestVectors(type); return ARGON2_OK; }
int main(int argc, char* argv[]) { // const unsigned int argon2_type_length = 10; unsigned char out[32]; uint32_t outlen = 32; uint32_t m_cost = 1 << 18; uint32_t t_cost = 3; uint32_t p_len = 16; unsigned thread_n = 4; uint32_t s_len = 16; bool generate_test_vectors = false; //char type[argon2_type_length] = "Argon2d"; std::string type; #ifdef KAT remove(KAT_FILENAME); #endif if (argc == 1) { GenKat(); return 0; } for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "-help") == 0) { printf("====================================== \n"); printf("Argon2 - test implementation \n"); printf("====================================== \n"); printf("Options:\n"); printf("\t -taglength <Tag Length: 0..31>\n"); printf("\t -logmcost < Base 2 logarithm of m_cost : 0..23 > \n"); printf("\t -tcost < t_cost : 0..2^24 > \n"); printf("\t -pwdlen < Password : length>\n"); printf("\t -saltlen < Salt : Length>\n"); printf("\t -threads < Number of threads : % d.. % d>\n", MIN_LANES, MAX_LANES); printf("\t -type <Argon2d; Argon2di; Argon2ds; Argon2i; Argon2id >\n"); printf("\t -gen-tv\n"); printf("\t -verify\n"); printf("\t -benchmark\n"); printf("\t -help\n"); printf("If no arguments given, Argon2 is called with default parameters t_cost=%d, m_cost=%d and threads=%d.\n", t_cost, m_cost, thread_n); return 0; } if (strcmp(argv[i], "-taglength") == 0) { if (i < argc - 1) { i++; outlen = atoi(argv[i]) % 32; continue; } } if (strcmp(argv[i], "-logmcost") == 0) { if (i < argc - 1) { i++; m_cost = (size_t) 1 << (atoi(argv[i]) % 24); continue; } } if (strcmp(argv[i], "-tcost") == 0) { if (i < argc - 1) { i++; t_cost = atoi(argv[i]) & 0xffffff; continue; } } if (strcmp(argv[i], "-pwdlen") == 0) { if (i < argc - 1) { i++; p_len = atoi(argv[i]) % 160; continue; } } if (strcmp(argv[i], "-saltlen") == 0) { if (i < argc - 1) { i++; s_len = atoi(argv[i]) % 32; continue; } } if (strcmp(argv[i], "-threads") == 0) { if (i < argc - 1) { i++; thread_n = atoi(argv[i]) % 32; continue; } } if (strcmp(argv[i], "-type") == 0) { if (i < argc - 1) { i++; type = std::string(argv[i]); // if (argon2_type_length >= strlen(argv[i])) { // memcpy(type, argv[i], strlen(argv[i])); // } continue; } } if (strcmp(argv[i], "-gen-tv") == 0) { generate_test_vectors = true; continue; } if (strcmp(argv[i], "-verify") == 0) { bool modify = false; if (i < argc - 1) { i++; if (0 != atoi(argv[i])) { modify = true; } } VerifyTest(modify); return 0; } if (strcmp(argv[i], "-benchmark") == 0) { Benchmark(); return 0; } } if (generate_test_vectors) { GenerateTestVectors(type); return 0; } Run(out, outlen, p_len, s_len, t_cost, m_cost); return 0; }