add change pin command

This commit is contained in:
Andrea Franz 2019-03-27 14:34:55 +01:00
parent bbc3c9ef8c
commit d773b76890
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 28 additions and 7 deletions

View File

@ -188,6 +188,13 @@ func (cs *CommandSet) VerifyPIN(pin string) error {
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) {
cmd := NewCommandGenerateKey()
resp, err := cs.sc.Send(cmd)

View File

@ -20,17 +20,21 @@ const (
InsGenerateKey = uint8(0xD4)
InsRemoveKey = uint8(0xD3)
InsVerifyPIN = uint8(0x20)
InsChangePIN = uint8(0x21)
InsDeriveKey = uint8(0xD1)
InsSign = uint8(0xC0)
InsSetPinlessPath = uint8(0xC1)
P1PairingFirstStep = uint8(0x00)
P1PairingFinalStep = uint8(0x01)
P1GetStatusApplication = uint8(0x00)
P1GetStatusKeyPath = uint8(0x01)
P1DeriveKeyFromMaster = uint8(0x00)
P1DeriveKeyFromParent = uint8(0x01)
P1DeriveKeyFromCurrent = uint8(0x10)
P1PairingFirstStep = uint8(0x00)
P1PairingFinalStep = uint8(0x01)
P1GetStatusApplication = uint8(0x00)
P1GetStatusKeyPath = uint8(0x01)
P1DeriveKeyFromMaster = uint8(0x00)
P1DeriveKeyFromParent = uint8(0x01)
P1DeriveKeyFromCurrent = uint8(0x10)
P1ChangePinPIN = uint8(0x00)
P1ChangePinPUK = uint8(0x01)
P1ChangePinPairingSecret = uint8(0x02)
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) {
startingPoint, path, err := derivationpath.Decode(pathStr)
if err != nil {