diff --git a/command_set.go b/command_set.go index 387fcab..e69291e 100644 --- a/command_set.go +++ b/command_set.go @@ -161,6 +161,23 @@ func (cs *CommandSet) GetStatus() (*types.ApplicationStatus, error) { return types.ParseApplicationStatus(resp.Data) } +func (cs *CommandSet) VerifyPIN(pin string) error { + cmd := NewCommandVerifyPIN(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) + if err = cs.checkOK(resp, err); err != nil { + return nil, err + } + + return resp.Data, nil +} + func (cs *CommandSet) mutualAuthenticate() error { data := make([]byte, 32) if _, err := rand.Read(data); err != nil { diff --git a/commands.go b/commands.go index 017b018..4ccc198 100644 --- a/commands.go +++ b/commands.go @@ -11,6 +11,8 @@ const ( InsMutuallyAuthenticate = uint8(0x11) InsPair = uint8(0x12) InsGetStatus = uint8(0xF2) + InsGenerateKey = uint8(0xD4) + InsVerifyPIN = uint8(0x20) P1PairingFirstStep = uint8(0x00) P1PairingFinalStep = uint8(0x01) @@ -85,3 +87,23 @@ func NewCommandGetStatusApplication() *apdu.Command { func NewCommandGetStatusKeyPath() *apdu.Command { return NewCommandGetStatus(P1GetStatusKeyPath) } + +func NewCommandGenerateKey() *apdu.Command { + return apdu.NewCommand( + globalplatform.ClaGp, + InsGenerateKey, + uint8(0), + uint8(0), + []byte{}, + ) +} + +func NewCommandVerifyPIN(pin string) *apdu.Command { + return apdu.NewCommand( + globalplatform.ClaGp, + InsVerifyPIN, + uint8(0), + uint8(0), + []byte(pin), + ) +}