mirror of
https://github.com/status-im/keycard-go.git
synced 2025-02-09 10:33:53 +00:00
refactor export key params constants
This commit is contained in:
parent
951cadcecc
commit
d95853db0f
@ -231,23 +231,23 @@ func (cs *CommandSet) DeriveKey(path string) error {
|
||||
|
||||
func (cs *CommandSet) ExportKey(derive bool, makeCurrent bool, onlyPublic bool, path string) ([]byte, error) {
|
||||
var p1 uint8
|
||||
if (derive == false) {
|
||||
p1 = EXPORT_KEY_CURRENT
|
||||
} else if (makeCurrent == false) {
|
||||
p1 = EXPORT_KEY_DERIVE
|
||||
if derive == false {
|
||||
p1 = P1ExportKeyCurrent
|
||||
} else if makeCurrent == false {
|
||||
p1 = P1ExportKeyDerive
|
||||
} else {
|
||||
p1 = EXPORT_KEY_DERIVE_AND_MAKE_CURRENT
|
||||
p1 = P1ExportKeyDeriveAndMakeCurrent
|
||||
}
|
||||
var p2 uint8
|
||||
if (onlyPublic == true) {
|
||||
p2 = EXPORT_KEY_PUB
|
||||
if onlyPublic == true {
|
||||
p2 = P2ExportKeyPublicOnly
|
||||
} else {
|
||||
p2 = EXPORT_KEY_PRIV_PUB
|
||||
p2 = P2ExportKeyPrivateAndPublic
|
||||
}
|
||||
cmd, err := NewCommandExportKey(p1, p2, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := cs.sc.Send(cmd)
|
||||
err = cs.checkOK(resp, err)
|
||||
|
40
commands.go
40
commands.go
@ -26,28 +26,28 @@ const (
|
||||
InsSign = 0xC0
|
||||
InsSetPinlessPath = 0xC1
|
||||
|
||||
P1PairingFirstStep = 0x00
|
||||
P1PairingFinalStep = 0x01
|
||||
P1GetStatusApplication = 0x00
|
||||
P1GetStatusKeyPath = 0x01
|
||||
P1DeriveKeyFromMaster = 0x00
|
||||
P1DeriveKeyFromParent = 0x40
|
||||
P1DeriveKeyFromCurrent = 0x80
|
||||
P1ChangePinPIN = 0x00
|
||||
P1ChangePinPUK = 0x01
|
||||
P1ChangePinPairingSecret = 0x02
|
||||
P1SignCurrentKey = 0x00
|
||||
P1SignDerive = 0x01
|
||||
P1SignDeriveAndMakeCurrent = 0x02
|
||||
P1SignPinless = 0x03
|
||||
P1PairingFirstStep = 0x00
|
||||
P1PairingFinalStep = 0x01
|
||||
P1GetStatusApplication = 0x00
|
||||
P1GetStatusKeyPath = 0x01
|
||||
P1DeriveKeyFromMaster = 0x00
|
||||
P1DeriveKeyFromParent = 0x40
|
||||
P1DeriveKeyFromCurrent = 0x80
|
||||
P1ChangePinPIN = 0x00
|
||||
P1ChangePinPUK = 0x01
|
||||
P1ChangePinPairingSecret = 0x02
|
||||
P1SignCurrentKey = 0x00
|
||||
P1SignDerive = 0x01
|
||||
P1SignDeriveAndMakeCurrent = 0x02
|
||||
P1SignPinless = 0x03
|
||||
P1ExportKeyCurrent = uint8(0x00)
|
||||
P1ExportKeyDerive = uint8(0x01)
|
||||
P1ExportKeyDeriveAndMakeCurrent = uint8(0x02)
|
||||
|
||||
P2ExportKeyPrivateAndPublic = uint8(0x00)
|
||||
P2ExportKeyPublicOnly = uint8(0x01)
|
||||
|
||||
SwNoAvailablePairingSlots = 0x6A84
|
||||
|
||||
EXPORT_KEY_CURRENT = uint8(0x00)
|
||||
EXPORT_KEY_DERIVE = uint8(0x01)
|
||||
EXPORT_KEY_DERIVE_AND_MAKE_CURRENT = uint8(0x02)
|
||||
EXPORT_KEY_PRIV_PUB = uint8(0x00)
|
||||
EXPORT_KEY_PUB = uint8(0x01)
|
||||
)
|
||||
|
||||
func NewCommandInit(data []byte) *apdu.Command {
|
||||
|
Loading…
x
Reference in New Issue
Block a user