remove status and pair commands from cli in favour of shell scripts

This commit is contained in:
Andrea Franz 2021-11-09 12:10:28 +01:00
parent 5b293d23cd
commit 14ac70a305
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 0 additions and 88 deletions

View File

@ -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
View File

@ -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 {