add commandKeycardExportKey

This commit is contained in:
Andrea Franz 2021-10-04 14:10:40 +02:00
parent fd3c9d3451
commit aa17c16920
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
1 changed files with 18 additions and 0 deletions

View File

@ -139,6 +139,7 @@ func NewShell(t keycardio.Transmitter) *Shell {
"keycard-generate-key": s.commandKeycardGenerateKey,
"keycard-remove-key": s.commandKeycardRemoveKey,
"keycard-derive-key": s.commandKeycardDeriveKey,
"keycard-export-key": s.commandKeycardExportKey,
"keycard-sign": s.commandKeycardSign,
"keycard-sign-with-path": s.commandKeycardSignWithPath,
"keycard-sign-message": s.commandKeycardSignMessage,
@ -663,6 +664,23 @@ func (s *Shell) commandKeycardDeriveKey(args ...string) error {
return nil
}
func (s *Shell) commandKeycardExportKey(args ...string) error {
if err := s.requireArgs(args, 1); err != nil {
return err
}
logger.Info(fmt.Sprintf("export key %s", args[0]))
key, err := s.kCmdSet.ExportKey(true, false, true, args[0])
if err != nil {
logger.Error("export key failed", "error", err)
return err
}
s.write(fmt.Sprintf("EXPORTED KEY\n%x\n\n", key))
return nil
}
func (s *Shell) commandKeycardSign(args ...string) error {
if err := s.requireArgs(args, 1); err != nil {
return err