mirror of
https://github.com/status-im/keycard-go.git
synced 2025-02-01 22:56:03 +00:00
add change pin command
This commit is contained in:
parent
bbc3c9ef8c
commit
d773b76890
@ -188,6 +188,13 @@ func (cs *CommandSet) VerifyPIN(pin string) error {
|
|||||||
return cs.checkOK(resp, err)
|
return cs.checkOK(resp, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cs *CommandSet) ChangePIN(pin string) error {
|
||||||
|
cmd := NewCommandChangePIN(pin)
|
||||||
|
resp, err := cs.sc.Send(cmd)
|
||||||
|
|
||||||
|
return cs.checkOK(resp, err)
|
||||||
|
}
|
||||||
|
|
||||||
func (cs *CommandSet) GenerateKey() ([]byte, error) {
|
func (cs *CommandSet) GenerateKey() ([]byte, error) {
|
||||||
cmd := NewCommandGenerateKey()
|
cmd := NewCommandGenerateKey()
|
||||||
resp, err := cs.sc.Send(cmd)
|
resp, err := cs.sc.Send(cmd)
|
||||||
|
28
commands.go
28
commands.go
@ -20,17 +20,21 @@ const (
|
|||||||
InsGenerateKey = uint8(0xD4)
|
InsGenerateKey = uint8(0xD4)
|
||||||
InsRemoveKey = uint8(0xD3)
|
InsRemoveKey = uint8(0xD3)
|
||||||
InsVerifyPIN = uint8(0x20)
|
InsVerifyPIN = uint8(0x20)
|
||||||
|
InsChangePIN = uint8(0x21)
|
||||||
InsDeriveKey = uint8(0xD1)
|
InsDeriveKey = uint8(0xD1)
|
||||||
InsSign = uint8(0xC0)
|
InsSign = uint8(0xC0)
|
||||||
InsSetPinlessPath = uint8(0xC1)
|
InsSetPinlessPath = uint8(0xC1)
|
||||||
|
|
||||||
P1PairingFirstStep = uint8(0x00)
|
P1PairingFirstStep = uint8(0x00)
|
||||||
P1PairingFinalStep = uint8(0x01)
|
P1PairingFinalStep = uint8(0x01)
|
||||||
P1GetStatusApplication = uint8(0x00)
|
P1GetStatusApplication = uint8(0x00)
|
||||||
P1GetStatusKeyPath = uint8(0x01)
|
P1GetStatusKeyPath = uint8(0x01)
|
||||||
P1DeriveKeyFromMaster = uint8(0x00)
|
P1DeriveKeyFromMaster = uint8(0x00)
|
||||||
P1DeriveKeyFromParent = uint8(0x01)
|
P1DeriveKeyFromParent = uint8(0x01)
|
||||||
P1DeriveKeyFromCurrent = uint8(0x10)
|
P1DeriveKeyFromCurrent = uint8(0x10)
|
||||||
|
P1ChangePinPIN = uint8(0x00)
|
||||||
|
P1ChangePinPUK = uint8(0x01)
|
||||||
|
P1ChangePinPairingSecret = uint8(0x02)
|
||||||
|
|
||||||
SwNoAvailablePairingSlots = 0x6A84
|
SwNoAvailablePairingSlots = 0x6A84
|
||||||
)
|
)
|
||||||
@ -135,6 +139,16 @@ func NewCommandVerifyPIN(pin string) *apdu.Command {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewCommandChangePIN(pin string) *apdu.Command {
|
||||||
|
return apdu.NewCommand(
|
||||||
|
globalplatform.ClaGp,
|
||||||
|
InsChangePIN,
|
||||||
|
P1ChangePinPIN,
|
||||||
|
uint8(0),
|
||||||
|
[]byte(pin),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func NewCommandDeriveKey(pathStr string) (*apdu.Command, error) {
|
func NewCommandDeriveKey(pathStr string) (*apdu.Command, error) {
|
||||||
startingPoint, path, err := derivationpath.Decode(pathStr)
|
startingPoint, path, err := derivationpath.Decode(pathStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user