keycard-go/lightwallet/commands.go

59 lines
1.1 KiB
Go
Raw Normal View History

2018-10-22 19:33:53 +02:00
package lightwallet
import (
2018-11-06 10:25:54 +01:00
"github.com/status-im/hardware-wallet-go/apdu"
"github.com/status-im/hardware-wallet-go/globalplatform"
2018-10-22 19:33:53 +02:00
)
const (
2018-10-24 18:16:14 +02:00
InsInit = uint8(0xFE)
InsOpenSecureChannel = uint8(0x10)
InsPair = uint8(0x12)
2018-10-23 12:06:00 +02:00
2018-10-24 13:42:00 +02:00
TagSelectResponsePreInitialized = uint8(0x80)
TagApplicationInfoTemplate = uint8(0xA4)
2018-10-24 18:16:14 +02:00
P1PairingFirstStep = uint8(0x00)
P1PairingFinalStep = uint8(0x01)
2018-10-22 19:33:53 +02:00
)
func NewCommandInit(data []byte) *apdu.Command {
return apdu.NewCommand(
globalplatform.ClaGp,
InsInit,
uint8(0x00),
uint8(0x00),
data,
)
}
2018-10-24 18:16:14 +02: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,
)
}