remove SelectNotInitialized

This commit is contained in:
Andrea Franz 2018-11-28 12:42:20 +01:00
parent d92ae609b7
commit a2d65ea700
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 7 additions and 30 deletions

View File

@ -16,6 +16,8 @@ var (
errAppletNotInstalled = errors.New("applet not installed")
errCardNotInitialized = errors.New("card not initialized")
errCardAlreadyInitialized = errors.New("card already initialized")
ErrNotInitialized = errors.New("card not initialized")
)
// Initializer defines a struct with methods to install applets and initialize a card.
@ -87,11 +89,15 @@ func (i *Initializer) Init() (*lightwallet.Secrets, error) {
}
func (i *Initializer) Pair(pairingPass, pin string) (*lightwallet.PairingInfo, error) {
_, err := actions.SelectInitialized(i.c, lightwallet.WalletAID)
appInfo, err := actions.Select(i.c, lightwallet.WalletAID)
if err != nil {
return nil, err
}
if !appInfo.Initialized {
return nil, ErrNotInitialized
}
return actions.Pair(i.c, pairingPass, pin)
}

View File

@ -15,7 +15,6 @@ import (
var (
ErrAlreadyInitialized = errors.New("card already initialized")
ErrNotInitialized = errors.New("card not initialized")
ErrWrongApplicationInfoTemplate = errors.New("wrong application info template")
ErrApplicationStatusTemplateNotFound = errors.New("application status template not found")
)
@ -48,34 +47,6 @@ func Select(c globalplatform.Channel, aid []byte) (*lightwallet.ApplicationInfo,
return parseApplicationInfo(resp.Data, info)
}
func SelectNotInitialized(c globalplatform.Channel, aid []byte) ([]byte, error) {
sel := globalplatform.NewCommandSelect(aid)
resp, err := c.Send(sel)
if err = checkOKResponse(err, resp); err != nil {
return nil, err
}
if resp.Data[0] != lightwallet.TagSelectResponsePreInitialized {
return nil, ErrAlreadyInitialized
}
return resp.Data[2:], nil
}
func SelectInitialized(c globalplatform.Channel, aid []byte) (*lightwallet.ApplicationInfo, error) {
sel := globalplatform.NewCommandSelect(aid)
resp, err := c.Send(sel)
if err = checkOKResponse(err, resp); err != nil {
return nil, err
}
if resp.Data[0] == lightwallet.TagSelectResponsePreInitialized {
return nil, ErrNotInitialized
}
return parseApplicationInfo(resp.Data, &lightwallet.ApplicationInfo{})
}
func Init(c globalplatform.Channel, cardPubKey []byte, secrets *lightwallet.Secrets, aid []byte) error {
secureChannel, err := lightwallet.NewSecureChannel(c, cardPubKey)
if err != nil {