]> err.no Git - yubikey-personalization/commitdiff
drop salt parameter to ykpers-args
authorKlas Lindfors <klas@yubico.com>
Thu, 9 Jan 2014 09:04:11 +0000 (10:04 +0100)
committerKlas Lindfors <klas@yubico.com>
Thu, 9 Jan 2014 09:04:11 +0000 (10:04 +0100)
tests/test_args_to_config.c
ykpers-args.c
ykpers-args.h
ykpersonalize.c

index c53044dfa79d844170f0a2c17d5df64ef8c622e6..f0c024e9a15cc3923202a29ca4c17eab5a2967af 100644 (file)
@@ -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;
 }
index 99dc742c82977421375c68e55824cf856c7181e5..efbfae1046aa1e08f02d62247c2075546a2572aa 100644 (file)
@@ -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",
index bf07eddb154aa27dec5b10a54c92211056ffccc8..22f99f2655da85032f001d407b0a74f6209fdcaa 100644 (file)
@@ -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,
index a2d7ea4cb3e316161875d292765599d0236b79ab..2bce23e1a217190f9d8bec257c5575aaa9f44523 100644 (file)
@@ -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)