mirror of
https://github.com/status-im/keycard-go.git
synced 2025-01-31 14:15:09 +00:00
add gp-send-apdu command
This commit is contained in:
parent
f42cbfe8b5
commit
00e7905c44
@ -42,6 +42,7 @@ func NewShell(t globalplatform.Transmitter) *Shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.commands = map[string]shellCommand{
|
s.commands = map[string]shellCommand{
|
||||||
|
"gp-send-apdu": s.commandGPSendAPDU,
|
||||||
"gp-select": s.commandGPSelect,
|
"gp-select": s.commandGPSelect,
|
||||||
"gp-open-secure-channel": s.commandGPOpenSecureChannel,
|
"gp-open-secure-channel": s.commandGPOpenSecureChannel,
|
||||||
"gp-delete": s.commandGPDelete,
|
"gp-delete": s.commandGPDelete,
|
||||||
@ -90,6 +91,27 @@ func (s *Shell) Run() error {
|
|||||||
return nil
|
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 {
|
func (s *Shell) commandGPSelect(args ...string) error {
|
||||||
if err := s.requireArgs(args, 0, 1); err != nil {
|
if err := s.requireArgs(args, 0, 1); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user