mirror of
https://github.com/status-im/keycard-go.git
synced 2025-01-19 00:10:55 +00:00
check if card is already initialized
This commit is contained in:
parent
61bc1a2764
commit
41c186951c
@ -7,6 +7,8 @@ import (
|
||||
|
||||
const (
|
||||
InsInit = uint8(0xFE)
|
||||
|
||||
tagSelectResponsePreInitialized = uint8(0x80)
|
||||
)
|
||||
|
||||
func NewCommandInit(data []byte) *apdu.Command {
|
||||
|
@ -74,6 +74,11 @@ func (i *Installer) Init() (*Secrets, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.Data[0] != tagSelectResponsePreInitialized {
|
||||
err := fmt.Errorf("card already initialized (%x).", resp.Data[0])
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cardKeyData := resp.Data[2:]
|
||||
secureChannel, err := NewSecureChannel(i.c, cardKeyData)
|
||||
if err != nil {
|
||||
@ -91,8 +96,6 @@ func (i *Installer) Init() (*Secrets, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fmt.Printf("RESP: %+v\n", resp)
|
||||
|
||||
return secrets, nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user