refactor export key params constants

This commit is contained in:
Andrea Franz 2019-04-24 15:30:14 +02:00
parent 951cadcecc
commit d95853db0f
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 29 additions and 29 deletions

View File

@ -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)

View File

@ -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 {