Skip to content

WIP: cmd: change order of argument for 'get pubkey' and 'get wrapped' in i… #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -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));
Expand Down Expand Up @@ -1341,16 +1341,16 @@ 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};
size_t response_len = sizeof(response);

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,
Expand Down
20 changes: 11 additions & 9 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,15 @@ 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,
"e:session,w:id,t:type", fmt_nofmt, fmt_nofmt,
"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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading