From: Klas Lindfors Date: Thu, 9 Jan 2014 09:04:11 +0000 (+0100) Subject: drop salt parameter to ykpers-args X-Git-Tag: v1.15.0~5 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98e2b1cbb1b43d513130f201118aa8bbadc539d4;p=yubikey-personalization drop salt parameter to ykpers-args --- diff --git a/tests/test_args_to_config.c b/tests/test_args_to_config.c index c53044d..f0c024e 100644 --- a/tests/test_args_to_config.c +++ b/tests/test_args_to_config.c @@ -105,7 +105,7 @@ int _test_config (YKP_CONFIG *cfg, YK_STATUS *st, int argc, char **argv) const char *outfname = NULL; bool verbose = false; bool dry_run = false; - bool aesviahash = false; + char keylocation; bool use_access_code = false; unsigned char access_code[256]; YK_KEY *yk = 0; @@ -114,7 +114,6 @@ int _test_config (YKP_CONFIG *cfg, YK_STATUS *st, int argc, char **argv) int data_format = YKP_FORMAT_LEGACY; /* Options */ - char *salt = NULL; char ndef[128]; char ndef_type = 0; unsigned char usb_mode = 0; @@ -142,11 +141,10 @@ int _test_config (YKP_CONFIG *cfg, YK_STATUS *st, int argc, char **argv) /* call args_to_config from ykpers-args.c with a fake set of program arguments */ rc = args_to_config(argc, argv, cfg, yk, &infname, &outfname, - &data_format, - &autocommit, &salt, + &data_format, &autocommit, st, &verbose, &dry_run, access_code, &use_access_code, - &aesviahash, &ndef_type, ndef, &usb_mode, &zap, + &keylocation, &ndef_type, ndef, &usb_mode, &zap, scan_map, &cr_timeout, &autoeject_timeout, &num_modes_seen, &exit_code); @@ -298,7 +296,7 @@ int _test_non_config_args(void) const char *outfname = NULL; bool verbose = false; bool dry_run = false; - bool aesviahash = false; + char keylocation; bool use_access_code = false; unsigned char access_code[256]; YK_KEY *yk = 0; @@ -308,7 +306,6 @@ int _test_non_config_args(void) int data_format = YKP_FORMAT_LEGACY; /* Options */ - char *salt = NULL; char ndef[128]; char ndef_type = 0; unsigned char usb_mode = 0; @@ -341,11 +338,10 @@ int _test_non_config_args(void) /* call args_to_config from ykpers-args.c with a fake set of program arguments */ rc = args_to_config(argc, argv, cfg, yk, &infname, &outfname, - &data_format, - &autocommit, &salt, + &data_format, &autocommit, st, &verbose, &dry_run, access_code, &use_access_code, - &aesviahash, &ndef_type, ndef, &usb_mode, &zap, + &keylocation, &ndef_type, ndef, &usb_mode, &zap, scan_map, &cr_timeout, &autoeject_timeout, &num_modes_seen, &exit_code); assert(rc == 1); @@ -637,67 +633,6 @@ int _test_ndef2_with_neo(void) free(st); } -int _test_salt(void) -{ - char *argv[] = { - "unittest", "-1", "-osalt=kaka", - NULL - }; - YKP_CONFIG *cfg = ykp_alloc(); - YK_STATUS *st = _test_init_st(2, 2, 0); - const char *infname = NULL; - const char *outfname = NULL; - bool verbose = false; - bool dry_run = false; - bool aesviahash = false; - bool use_access_code = false; - unsigned char access_code[256]; - YK_KEY *yk = 0; - bool autocommit = false; - int exit_code = 0; - int data_format = YKP_FORMAT_LEGACY; - - /* Options */ - char *salt = NULL; - char ndef[128]; - char ndef_type = 0; - unsigned char usb_mode = 0; - unsigned char cr_timeout = 0; - unsigned char autoeject_timeout = 0; - int num_modes_seen = 0; - bool zap = false; - - unsigned char scan_map[sizeof(SCAN_MAP)]; - - int rc; - - ykp_errno = 0; - -/* getopt reinit (BSD systems use optreset and a different optind value) */ -#if defined(__GLIBC__) || defined(_WIN32) - optind = 0; -#else - optind = optreset = 1; -#endif - - /* copy version number from st into cfg */ - assert(ykp_configure_for(cfg, 1, st) == 1); - - /* call args_to_config from ykpers-args.c with a fake set of program arguments */ - rc = args_to_config(3, argv, cfg, yk, - &infname, &outfname, - &data_format, - &autocommit, &salt, - st, &verbose, &dry_run, - access_code, &use_access_code, - &aesviahash, &ndef_type, ndef, &usb_mode, &zap, - scan_map, &cr_timeout, &autoeject_timeout, &num_modes_seen, - &exit_code); - - assert(rc == 1); - assert(strncmp(salt, "kaka", 4) == 0); -} - int main (int argc, char **argv) { _test_config_slot1(); @@ -723,7 +658,6 @@ int main (int argc, char **argv) _test_slot_two_with_neo_beta(); _test_ndef2_with_neo(); _test_ndef2_with_neo_beta(); - _test_salt(); return 0; } diff --git a/ykpers-args.c b/ykpers-args.c index 99dc742..efbfae1 100644 --- a/ykpers-args.c +++ b/ykpers-args.c @@ -79,9 +79,6 @@ const char *usage = "-S0605.. Set the scanmap to use with the YubiKey NEO. Must be 45 unique bytes,\n" " in hex. Use with no argument to reset to the default.\n" "-oOPTION change configuration option. Possible OPTION arguments are:\n" -" salt=ssssssss Salt to be used when deriving key from a\n" -" password. If none is given, a unique random\n" -" one will be generated.\n" " fixed=xxxxxxxxxxx The public identity of key, in MODHEX.\n" " This is 0-16 characters long.\n" " uid=xxxxxx The uid part of the generated ticket, in HEX.\n" @@ -229,8 +226,7 @@ void report_yk_error(void) */ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, YK_KEY *yk, const char **infname, const char **outfname, - int *data_format, - bool *autocommit, char **salt, + int *data_format, bool *autocommit, YK_STATUS *st, bool *verbose, bool *dry_run, unsigned char *access_code, bool *use_access_code, char *keylocation, char *ndef_type, char *ndef, @@ -498,9 +494,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, YK_KEY *yk, *exit_code = 1; return 0; } - if (strncmp(optarg, "salt=", 5) == 0) - *salt = strdup(optarg+5); - else if (strncmp(optarg, "fixed=", 6) == 0) { + if (strncmp(optarg, "fixed=", 6) == 0) { if (_set_fixed(optarg + 6, cfg) != 1) { fprintf(stderr, "Invalid fixed string: %s\n", diff --git a/ykpers-args.h b/ykpers-args.h index bf07edd..22f99f2 100644 --- a/ykpers-args.h +++ b/ykpers-args.h @@ -35,8 +35,7 @@ const char *usage; int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, YK_KEY *yk, const char **infname, const char **outfname, - int *data_format, - bool *autocommit, char **salt, + int *data_format, bool *autocommit, YK_STATUS *st, bool *verbose, bool *dry_run, unsigned char *access_code, bool *use_access_code, char *keylocation, char *ndef_type, char *ndef, unsigned char *usb_mode, diff --git a/ykpersonalize.c b/ykpersonalize.c index a2d7ea4..2bce23e 100644 --- a/ykpersonalize.c +++ b/ykpersonalize.c @@ -59,7 +59,6 @@ int main(int argc, char **argv) bool dry_run = false; /* Options */ - char *salt = NULL; char ndef_string[128] = {0}; char ndef_type = 0; unsigned char usb_mode = 0; @@ -123,8 +122,7 @@ int main(int argc, char **argv) /* Parse all arguments in a testable way */ if (! args_to_config(argc, argv, cfg, yk, &infname, &outfname, - &data_format, - &autocommit, &salt, + &data_format, &autocommit, st, &verbose, &dry_run, access_code, &use_access_code, &keylocation, &ndef_type, ndef_string, @@ -387,8 +385,6 @@ err: report_yk_error(); } - if (salt) - free(salt); if (st) free(st); if (inf)