mirror of
https://github.com/status-im/keycard-go.git
synced 2025-02-12 11:56:51 +00:00
add verify in and generate key methods
This commit is contained in:
parent
fa2a5514a2
commit
19e1a9ade1
@ -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 {
|
||||
|
22
commands.go
22
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),
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user