add change PUK and Pairing Secret commands

This commit is contained in:
Andrea Franz 2019-03-27 15:16:02 +01:00
parent d773b76890
commit 1f5f2a9eeb
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 35 additions and 0 deletions

View File

@ -195,6 +195,21 @@ func (cs *CommandSet) ChangePIN(pin string) error {
return cs.checkOK(resp, err)
}
func (cs *CommandSet) ChangePUK(puk string) error {
cmd := NewCommandChangePUK(puk)
resp, err := cs.sc.Send(cmd)
return cs.checkOK(resp, err)
}
func (cs *CommandSet) ChangePairingSecret(password string) error {
secret := generatePairingToken(password)
cmd := NewCommandChangePairingSecret(secret)
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

@ -149,6 +149,26 @@ func NewCommandChangePIN(pin string) *apdu.Command {
)
}
func NewCommandChangePUK(puk string) *apdu.Command {
return apdu.NewCommand(
globalplatform.ClaGp,
InsChangePIN,
P1ChangePinPUK,
uint8(0),
[]byte(puk),
)
}
func NewCommandChangePairingSecret(secret []byte) *apdu.Command {
return apdu.NewCommand(
globalplatform.ClaGp,
InsChangePIN,
P1ChangePinPairingSecret,
uint8(0),
secret,
)
}
func NewCommandDeriveKey(pathStr string) (*apdu.Command, error) {
startingPoint, path, err := derivationpath.Decode(pathStr)
if err != nil {