diff --git a/src/commands.c b/src/commands.c index c6b5a9a1c..c5720aabe 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1061,8 +1061,8 @@ int yh_com_get_storage(yubihsm_context *ctx, Argument *argv, cmd_format in_fmt, // argc = 3 // arg 0: e:session // arg 1: w:key_id -// arg 2: t:key_type -// arg 3: f:filename +// arg 2: f:filename +// arg 3: t:key_type int yh_com_get_pubkey(yubihsm_context *ctx, Argument *argv, cmd_format in_fmt, cmd_format fmt) { @@ -1074,7 +1074,7 @@ int yh_com_get_pubkey(yubihsm_context *ctx, Argument *argv, cmd_format in_fmt, yh_algorithm algo = 0; EVP_PKEY *public_key = NULL; - yh_rc yrc = yh_util_get_public_key_ex(argv[0].e, argv[2].t, argv[1].w, + yh_rc yrc = yh_util_get_public_key_ex(argv[0].e, argv[3].t, argv[1].w, response, &response_len, &algo); if (yrc != YHR_SUCCESS) { fprintf(stderr, "Failed to get public key: %s\n", yh_strerror(yrc)); @@ -1341,8 +1341,8 @@ int yh_com_get_object_info(yubihsm_context *ctx, Argument *argv, // arg 1: w:keyid // arg 2: t:type // arg 3: w:id -// arg 4: b:include_seed -// arg 5: f:file +// arg 4: f:file +// arg 5: b:include_seed int yh_com_get_wrapped(yubihsm_context *ctx, Argument *argv, cmd_format in_fmt, cmd_format fmt) { uint8_t response[YH_MSG_BUF_SIZE] = {0}; @@ -1350,7 +1350,7 @@ int yh_com_get_wrapped(yubihsm_context *ctx, Argument *argv, cmd_format in_fmt, UNUSED(in_fmt); - uint8_t format = argv[4].b ? 1 : 0; + uint8_t format = argv[5].b ? 1 : 0; yh_rc yrc = yh_util_export_wrapped_ex(argv[0].e, argv[1].w, argv[2].b, argv[3].w, diff --git a/src/main.c b/src/main.c index 54d5540dc..ebb1dd28b 100644 --- a/src/main.c +++ b/src/main.c @@ -393,7 +393,7 @@ static void create_command_list(CommandList *c) { fmt_nofmt, fmt_nofmt, "Get storages stats", NULL, NULL}); register_subcommand(*c, (Command){"pubkey", yh_com_get_pubkey, - "e:session,w:key_id,t:key_type=asymmetric-key,F:file=-", fmt_nofmt, + "e:session,w:key_id,F:file=-,t:key_type=asymmetric-key", fmt_nofmt, fmt_PEM, "Get a public key", NULL, NULL}); register_subcommand(*c, (Command){"objectinfo", yh_com_get_object_info, @@ -401,7 +401,7 @@ static void create_command_list(CommandList *c) { "Get information about an object", NULL, NULL}); register_subcommand(*c, (Command){"wrapped", yh_com_get_wrapped, - "e:session,w:wrapkey_id,t:type,w:id,b:include_seed=0,F:file=-", + "e:session,w:wrapkey_id,t:type,w:id,F:file=-,b:include_seed=0", fmt_nofmt, fmt_base64, "Get an object under wrap", NULL, NULL}); register_subcommand(*c, @@ -2395,14 +2395,16 @@ int main(int argc, char *argv[]) { case action_arg_getMINUS_publicMINUS_key: { arg[1].w = args_info.object_id_arg; + + arg[2].s = args_info.out_arg; + arg[2].len = strlen(args_info.out_arg); + if(args_info.object_type_given) { - yrc = yh_string_to_type(args_info.object_type_arg, &arg[2].t); + yrc = yh_string_to_type(args_info.object_type_arg, &arg[3].t); LIB_SUCCEED_OR_DIE(yrc, "Unable to parse type: "); } else { - arg[2].t = YH_ASYMMETRIC_KEY; + arg[3].t = YH_ASYMMETRIC_KEY; } - arg[3].s = args_info.out_arg; - arg[3].len = strlen(args_info.out_arg); comrc = yh_com_get_pubkey(&g_ctx, arg, fmt_nofmt, @@ -2451,10 +2453,10 @@ int main(int argc, char *argv[]) { arg[3].w = args_info.object_id_arg; - arg[4].b = args_info.include_seed_given; + arg[4].s = args_info.out_arg; + arg[4].len = strlen(args_info.out_arg); - arg[5].s = args_info.out_arg; - arg[5].len = strlen(args_info.out_arg); + arg[5].b = args_info.include_seed_given; comrc = yh_com_get_wrapped(&g_ctx, arg, fmt_nofmt,