add gp-send-apdu command

This commit is contained in:
Andrea Franz 2019-03-15 16:13:14 +01:00
parent f42cbfe8b5
commit 00e7905c44
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D

View File

@ -42,6 +42,7 @@ func NewShell(t globalplatform.Transmitter) *Shell {
}
s.commands = map[string]shellCommand{
"gp-send-apdu": s.commandGPSendAPDU,
"gp-select": s.commandGPSelect,
"gp-open-secure-channel": s.commandGPOpenSecureChannel,
"gp-delete": s.commandGPDelete,
@ -90,6 +91,27 @@ func (s *Shell) Run() error {
return nil
}
func (s *Shell) commandGPSendAPDU(args ...string) error {
if err := s.requireArgs(args, 1); err != nil {
return err
}
apdu, err := hex.DecodeString(args[0])
if err != nil {
return err
}
logger.Info(fmt.Sprintf("send apdu %x", apdu))
resp, err := s.t.Transmit(apdu)
if err != nil {
logger.Error("send apdu failed", "error", err)
return err
}
logger.Info(fmt.Sprintf("raw response: %x", resp))
return nil
}
func (s *Shell) commandGPSelect(args ...string) error {
if err := s.requireArgs(args, 0, 1); err != nil {
return err