remove status and pair commands from cli in favour of shell scripts
This commit is contained in:
parent
5b293d23cd
commit
14ac70a305
|
@ -95,58 +95,3 @@ func (i *Initializer) Info() (*types.ApplicationInfo, *types.CashApplicationInfo
|
|||
|
||||
return cmdSet.ApplicationInfo, cashCmdSet.CashApplicationInfo, err
|
||||
}
|
||||
|
||||
func (i *Initializer) Pair(pairingPass string) (*types.PairingInfo, error) {
|
||||
logger.Info("pairing started")
|
||||
cmdSet := keycard.NewCommandSet(i.c)
|
||||
|
||||
logger.Info("select keycard applet")
|
||||
err := cmdSet.Select()
|
||||
if err != nil {
|
||||
logger.Error("select failed", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !cmdSet.ApplicationInfo.Initialized {
|
||||
logger.Error("pairing failed", "error", ErrNotInitialized)
|
||||
return nil, ErrNotInitialized
|
||||
}
|
||||
|
||||
logger.Info("pairing")
|
||||
err = cmdSet.Pair(pairingPass)
|
||||
return cmdSet.PairingInfo, err
|
||||
}
|
||||
|
||||
func (i *Initializer) Status(key []byte, index int) (*types.ApplicationStatus, error) {
|
||||
logger.Info("pairing started")
|
||||
cmdSet := keycard.NewCommandSet(i.c)
|
||||
|
||||
logger.Info("select keycard applet")
|
||||
err := cmdSet.Select()
|
||||
if err != nil {
|
||||
logger.Error("select failed", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !cmdSet.ApplicationInfo.Initialized {
|
||||
logger.Error("pairing failed", "error", ErrNotInitialized)
|
||||
return nil, ErrNotInitialized
|
||||
}
|
||||
|
||||
logger.Info("open secure channel")
|
||||
cmdSet.SetPairingInfo(key, index)
|
||||
err = cmdSet.OpenSecureChannel()
|
||||
if err != nil {
|
||||
logger.Error("open secure channel failed", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logger.Info("get status")
|
||||
appStatus, err := cmdSet.GetStatusApplication()
|
||||
if err != nil {
|
||||
logger.Error("get status failed", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return appStatus, nil
|
||||
}
|
||||
|
|
33
main.go
33
main.go
|
@ -57,8 +57,6 @@ func init() {
|
|||
"info": commandInfo,
|
||||
"delete": commandDelete,
|
||||
"init": commandInit,
|
||||
"pair": commandPair,
|
||||
"status": commandStatus,
|
||||
"shell": commandShell,
|
||||
}
|
||||
|
||||
|
@ -317,37 +315,6 @@ func commandInit(card *scard.Card) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func commandPair(card *scard.Card) error {
|
||||
i := NewInitializer(card)
|
||||
pairingPass := ask("Pairing password")
|
||||
info, err := i.Pair(pairingPass)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Pairing key 0x%x\n", info.Key)
|
||||
fmt.Printf("Pairing Index %d\n", info.Index)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func commandStatus(card *scard.Card) error {
|
||||
i := NewInitializer(card)
|
||||
key := askHex("Pairing key")
|
||||
index := askInt("Pairing index")
|
||||
|
||||
appStatus, err := i.Status(key, index)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Pin retry count: %d\n", appStatus.PinRetryCount)
|
||||
fmt.Printf("PUK retry count: %d\n", appStatus.PUKRetryCount)
|
||||
fmt.Printf("Key initialized: %v\n", appStatus.KeyInitialized)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func commandShell(card *scard.Card) error {
|
||||
fi, _ := os.Stdin.Stat()
|
||||
if (fi.Mode() & os.ModeCharDevice) == 0 {
|
||||
|
|
Loading…
Reference in New Issue