make action a multi-val
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@
|
|||||||
option "verbose" v "Print more information" int optional default="0" argoptional
|
option "verbose" v "Print more information" int optional default="0" argoptional
|
||||||
option "reader" r "Only use a matching reader" string optional
|
option "reader" r "Only use a matching reader" string optional
|
||||||
option "key" k "Authentication key to use" string optional default="010203040506070801020304050607080102030405060708"
|
option "key" k "Authentication key to use" string optional default="010203040506070801020304050607080102030405060708"
|
||||||
option "action" a "Action to take" values="version","generate","set-mgm-key","reset","pin-retries","import-key" enum
|
option "action" a "Action to take" values="version","generate","set-mgm-key","reset","pin-retries","import-key" enum multiple
|
||||||
option "slot" s "What key slot to operate on" values="9a","9c","9d","9e" enum optional
|
option "slot" s "What key slot to operate on" values="9a","9c","9d","9e" enum optional
|
||||||
option "algorithm" A "What algorithm to use" values="RSA1024","RSA2048","ECCP256" enum optional default="RSA2048"
|
option "algorithm" A "What algorithm to use" values="RSA1024","RSA2048","ECCP256" enum optional default="RSA2048"
|
||||||
option "new-key" n "New authentication key to use" string optional
|
option "new-key" n "New authentication key to use" string optional
|
||||||
|
|||||||
+14
-6
@@ -568,6 +568,8 @@ int main(int argc, char *argv[]) {
|
|||||||
SCARDCONTEXT context;
|
SCARDCONTEXT context;
|
||||||
unsigned char key[KEY_LEN];
|
unsigned char key[KEY_LEN];
|
||||||
int verbosity;
|
int verbosity;
|
||||||
|
enum enum_action action;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
if(cmdline_parser(argc, argv, &args_info) != 0) {
|
if(cmdline_parser(argc, argv, &args_info) != 0) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -591,16 +593,21 @@ int main(int argc, char *argv[]) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args_info.action_arg == action_arg_version) {
|
for(i = 0; i < args_info.action_given; i++) {
|
||||||
|
action = *args_info.action_arg++;
|
||||||
|
if(verbosity) {
|
||||||
|
fprintf(stderr, "Now processing for action %d.\n", action);
|
||||||
|
}
|
||||||
|
if(action == action_arg_version) {
|
||||||
print_version(&card, verbosity);
|
print_version(&card, verbosity);
|
||||||
} else if(args_info.action_arg == action_arg_generate) {
|
} else if(action == action_arg_generate) {
|
||||||
if(args_info.slot_arg != slot__NULL) {
|
if(args_info.slot_arg != slot__NULL) {
|
||||||
generate_key(&card, args_info.slot_orig, args_info.algorithm_arg, verbosity);
|
generate_key(&card, args_info.slot_orig, args_info.algorithm_arg, verbosity);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "The generate action needs a slot (-s) to operate on.\n");
|
fprintf(stderr, "The generate action needs a slot (-s) to operate on.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
} else if(args_info.action_arg == action_arg_setMINUS_mgmMINUS_key) {
|
} else if(action == action_arg_setMINUS_mgmMINUS_key) {
|
||||||
if(args_info.new_key_arg) {
|
if(args_info.new_key_arg) {
|
||||||
unsigned char new_key[KEY_LEN];
|
unsigned char new_key[KEY_LEN];
|
||||||
if(parse_key(args_info.new_key_arg, new_key, verbosity) == false) {
|
if(parse_key(args_info.new_key_arg, new_key, verbosity) == false) {
|
||||||
@@ -613,11 +620,11 @@ int main(int argc, char *argv[]) {
|
|||||||
fprintf(stderr, "The set-mgm-key action needs the new-key (-n) argument.\n");
|
fprintf(stderr, "The set-mgm-key action needs the new-key (-n) argument.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
} else if(args_info.action_arg == action_arg_reset) {
|
} else if(action == action_arg_reset) {
|
||||||
if(reset(&card, verbosity) == false) {
|
if(reset(&card, verbosity) == false) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
} else if(args_info.action_arg == action_arg_pinMINUS_retries) {
|
} else if(action == action_arg_pinMINUS_retries) {
|
||||||
if(args_info.pin_retries_arg && args_info.puk_retries_arg) {
|
if(args_info.pin_retries_arg && args_info.puk_retries_arg) {
|
||||||
if(set_pin_retries(&card, args_info.pin_retries_arg, args_info.puk_retries_arg, verbosity) == false) {
|
if(set_pin_retries(&card, args_info.pin_retries_arg, args_info.puk_retries_arg, verbosity) == false) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -625,7 +632,7 @@ int main(int argc, char *argv[]) {
|
|||||||
} else {
|
} else {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
} else if(args_info.action_arg == action_arg_importMINUS_key) {
|
} else if(action == action_arg_importMINUS_key) {
|
||||||
if(args_info.slot_arg != slot__NULL) {
|
if(args_info.slot_arg != slot__NULL) {
|
||||||
if(import_key(&card, args_info.key_format_arg, args_info.input_arg, args_info.slot_orig, verbosity) == false) {
|
if(import_key(&card, args_info.key_format_arg, args_info.input_arg, args_info.slot_orig, verbosity) == false) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -635,6 +642,7 @@ int main(int argc, char *argv[]) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user