keycard-go/lightwallet/commands.go

59 lines
1.1 KiB
Go
Raw Normal View History

2018-10-22 17:33:53 +00:00
package lightwallet
import (
"github.com/status-im/smartcard-go/apdu"
"github.com/status-im/smartcard-go/globalplatform"
)
const (
2018-10-24 16:16:14 +00:00
InsInit = uint8(0xFE)
InsOpenSecureChannel = uint8(0x10)
InsPair = uint8(0x12)
2018-10-23 10:06:00 +00:00
2018-10-24 11:42:00 +00:00
TagSelectResponsePreInitialized = uint8(0x80)
TagApplicationInfoTemplate = uint8(0xA4)
2018-10-24 16:16:14 +00:00
P1PairingFirstStep = uint8(0x00)
P1PairingFinalStep = uint8(0x01)
2018-10-22 17:33:53 +00:00
)
func NewCommandInit(data []byte) *apdu.Command {
return apdu.NewCommand(
globalplatform.ClaGp,
InsInit,
uint8(0x00),
uint8(0x00),
data,
)
}
2018-10-24 16:16:14 +00:00
func NewCommandPairFirstStep(challenge []byte) *apdu.Command {
return apdu.NewCommand(
globalplatform.ClaGp,
InsPair,
P1PairingFirstStep,
uint8(0x00),
challenge,
)
}
func NewCommandPairFinalStep(cryptogramHash []byte) *apdu.Command {
return apdu.NewCommand(
globalplatform.ClaGp,
InsPair,
P1PairingFinalStep,
uint8(0x00),
cryptogramHash,
)
}
func NewCommandOpenSecureChannel(pairingIndex uint8, pubKey []byte) *apdu.Command {
return apdu.NewCommand(
globalplatform.ClaGp,
InsOpenSecureChannel,
pairingIndex,
uint8(0x00),
pubKey,
)
}