Skip to content

Commit

Permalink
yubihsm: show labels when listing keys (#102)
Browse files Browse the repository at this point in the history
Makes it easier to determine which key is which
  • Loading branch information
tony-iqlusion authored Jul 2, 2020
1 parent 9f4a961 commit b51d79d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.txsigner.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ Finally, confirm you see the key listed when you run
```
$ tmkms yubihsm keys list
Listing keys in YubiHSM #0001234567:
- 0x0001: [cons] cosmosvalconspub1zcjduepqpxg30wtw7tlt750lhl3fdjfex6eq7tj3gfer3ugrzahd27srflhqv6ep6j
- 0x0001: [cons] cosmosvalconspub...
[...]
- 0x0123: [acct] terra13tdvxsauagu33glu74u93mdka7ahvm5a6yfr76
label: "columbus-3 oracle signer"
```

If the newly generated account key is properly configured for the desired chain
Expand Down
12 changes: 12 additions & 0 deletions src/commands/yubihsm/keys/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ fn display_key_info(
key: &yubihsm::object::Entry,
key_formatters: &Map<u16, keyring::Format>,
) {
let key_info = hsm
.get_object_info(key.object_id, yubihsm::object::Type::AsymmetricKey)
.unwrap_or_else(|e| {
status_err!(
"couldn't get object info for asymmetric key #{}: {}",
key.object_id,
e
);
process::exit(1);
});

let public_key = hsm.get_public_key(key.object_id).unwrap_or_else(|e| {
status_err!(
"couldn't get public key for asymmetric key #{}: {}",
Expand Down Expand Up @@ -142,4 +153,5 @@ fn display_key_info(
};

status_attr_ok!(key_id, "[{}] {}", key_type, key_serialized);
println!(" label: \"{}\"", &key_info.label);
}

0 comments on commit b51d79d

Please sign in to comment.