mirror of
https://github.com/status-im/keycard-go.git
synced 2025-02-08 10:05:13 +00:00
remove useless uint castings
This commit is contained in:
parent
848c32046a
commit
3cdaf543d7
92
commands.go
92
commands.go
@ -11,30 +11,30 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
InsInit = uint8(0xFE)
|
||||
InsOpenSecureChannel = uint8(0x10)
|
||||
InsMutuallyAuthenticate = uint8(0x11)
|
||||
InsPair = uint8(0x12)
|
||||
InsUnpair = uint8(0x13)
|
||||
InsGetStatus = uint8(0xF2)
|
||||
InsGenerateKey = uint8(0xD4)
|
||||
InsRemoveKey = uint8(0xD3)
|
||||
InsVerifyPIN = uint8(0x20)
|
||||
InsChangePIN = uint8(0x21)
|
||||
InsDeriveKey = uint8(0xD1)
|
||||
InsSign = uint8(0xC0)
|
||||
InsSetPinlessPath = uint8(0xC1)
|
||||
InsInit = 0xFE
|
||||
InsOpenSecureChannel = 0x10
|
||||
InsMutuallyAuthenticate = 0x11
|
||||
InsPair = 0x12
|
||||
InsUnpair = 0x13
|
||||
InsGetStatus = 0xF2
|
||||
InsGenerateKey = 0xD4
|
||||
InsRemoveKey = 0xD3
|
||||
InsVerifyPIN = 0x20
|
||||
InsChangePIN = 0x21
|
||||
InsDeriveKey = 0xD1
|
||||
InsSign = 0xC0
|
||||
InsSetPinlessPath = 0xC1
|
||||
|
||||
P1PairingFirstStep = uint8(0x00)
|
||||
P1PairingFinalStep = uint8(0x01)
|
||||
P1GetStatusApplication = uint8(0x00)
|
||||
P1GetStatusKeyPath = uint8(0x01)
|
||||
P1DeriveKeyFromMaster = uint8(0x00)
|
||||
P1DeriveKeyFromParent = uint8(0x01)
|
||||
P1DeriveKeyFromCurrent = uint8(0x10)
|
||||
P1ChangePinPIN = uint8(0x00)
|
||||
P1ChangePinPUK = uint8(0x01)
|
||||
P1ChangePinPairingSecret = uint8(0x02)
|
||||
P1PairingFirstStep = 0x00
|
||||
P1PairingFinalStep = 0x01
|
||||
P1GetStatusApplication = 0x00
|
||||
P1GetStatusKeyPath = 0x01
|
||||
P1DeriveKeyFromMaster = 0x00
|
||||
P1DeriveKeyFromParent = 0x01
|
||||
P1DeriveKeyFromCurrent = 0x10
|
||||
P1ChangePinPIN = 0x00
|
||||
P1ChangePinPUK = 0x01
|
||||
P1ChangePinPairingSecret = 0x02
|
||||
|
||||
SwNoAvailablePairingSlots = 0x6A84
|
||||
)
|
||||
@ -43,8 +43,8 @@ func NewCommandInit(data []byte) *apdu.Command {
|
||||
return apdu.NewCommand(
|
||||
globalplatform.ClaGp,
|
||||
InsInit,
|
||||
uint8(0x00),
|
||||
uint8(0x00),
|
||||
0,
|
||||
0,
|
||||
data,
|
||||
)
|
||||
}
|
||||
@ -54,7 +54,7 @@ func NewCommandPairFirstStep(challenge []byte) *apdu.Command {
|
||||
globalplatform.ClaGp,
|
||||
InsPair,
|
||||
P1PairingFirstStep,
|
||||
uint8(0x00),
|
||||
0,
|
||||
challenge,
|
||||
)
|
||||
}
|
||||
@ -64,7 +64,7 @@ func NewCommandPairFinalStep(cryptogramHash []byte) *apdu.Command {
|
||||
globalplatform.ClaGp,
|
||||
InsPair,
|
||||
P1PairingFinalStep,
|
||||
uint8(0x00),
|
||||
0,
|
||||
cryptogramHash,
|
||||
)
|
||||
}
|
||||
@ -74,7 +74,7 @@ func NewCommandUnpair(index uint8) *apdu.Command {
|
||||
globalplatform.ClaGp,
|
||||
InsUnpair,
|
||||
index,
|
||||
uint8(0),
|
||||
0,
|
||||
[]byte{},
|
||||
)
|
||||
}
|
||||
@ -84,7 +84,7 @@ func NewCommandOpenSecureChannel(pairingIndex uint8, pubKey []byte) *apdu.Comman
|
||||
globalplatform.ClaGp,
|
||||
InsOpenSecureChannel,
|
||||
pairingIndex,
|
||||
uint8(0x00),
|
||||
0,
|
||||
pubKey,
|
||||
)
|
||||
}
|
||||
@ -93,8 +93,8 @@ func NewCommandMutuallyAuthenticate(data []byte) *apdu.Command {
|
||||
return apdu.NewCommand(
|
||||
globalplatform.ClaGp,
|
||||
InsMutuallyAuthenticate,
|
||||
uint8(0x00),
|
||||
uint8(0x00),
|
||||
0,
|
||||
0,
|
||||
data,
|
||||
)
|
||||
}
|
||||
@ -104,7 +104,7 @@ func NewCommandGetStatus(p1 uint8) *apdu.Command {
|
||||
globalplatform.ClaGp,
|
||||
InsGetStatus,
|
||||
p1,
|
||||
uint8(0x00),
|
||||
0,
|
||||
[]byte{},
|
||||
)
|
||||
}
|
||||
@ -113,8 +113,8 @@ func NewCommandGenerateKey() *apdu.Command {
|
||||
return apdu.NewCommand(
|
||||
globalplatform.ClaGp,
|
||||
InsGenerateKey,
|
||||
uint8(0),
|
||||
uint8(0),
|
||||
0,
|
||||
0,
|
||||
[]byte{},
|
||||
)
|
||||
}
|
||||
@ -123,8 +123,8 @@ func NewCommandRemoveKey() *apdu.Command {
|
||||
return apdu.NewCommand(
|
||||
globalplatform.ClaGp,
|
||||
InsRemoveKey,
|
||||
uint8(0),
|
||||
uint8(0),
|
||||
0,
|
||||
0,
|
||||
[]byte{},
|
||||
)
|
||||
}
|
||||
@ -133,8 +133,8 @@ func NewCommandVerifyPIN(pin string) *apdu.Command {
|
||||
return apdu.NewCommand(
|
||||
globalplatform.ClaGp,
|
||||
InsVerifyPIN,
|
||||
uint8(0),
|
||||
uint8(0),
|
||||
0,
|
||||
0,
|
||||
[]byte(pin),
|
||||
)
|
||||
}
|
||||
@ -144,7 +144,7 @@ func NewCommandChangePIN(pin string) *apdu.Command {
|
||||
globalplatform.ClaGp,
|
||||
InsChangePIN,
|
||||
P1ChangePinPIN,
|
||||
uint8(0),
|
||||
0,
|
||||
[]byte(pin),
|
||||
)
|
||||
}
|
||||
@ -154,7 +154,7 @@ func NewCommandChangePUK(puk string) *apdu.Command {
|
||||
globalplatform.ClaGp,
|
||||
InsChangePIN,
|
||||
P1ChangePinPUK,
|
||||
uint8(0),
|
||||
0,
|
||||
[]byte(puk),
|
||||
)
|
||||
}
|
||||
@ -164,7 +164,7 @@ func NewCommandChangePairingSecret(secret []byte) *apdu.Command {
|
||||
globalplatform.ClaGp,
|
||||
InsChangePIN,
|
||||
P1ChangePinPairingSecret,
|
||||
uint8(0),
|
||||
0,
|
||||
secret,
|
||||
)
|
||||
}
|
||||
@ -198,7 +198,7 @@ func NewCommandDeriveKey(pathStr string) (*apdu.Command, error) {
|
||||
globalplatform.ClaGp,
|
||||
InsDeriveKey,
|
||||
p1,
|
||||
uint8(0),
|
||||
0,
|
||||
data.Bytes(),
|
||||
), nil
|
||||
}
|
||||
@ -223,8 +223,8 @@ func NewCommandSetPinlessPath(pathStr string) (*apdu.Command, error) {
|
||||
return apdu.NewCommand(
|
||||
globalplatform.ClaGp,
|
||||
InsSetPinlessPath,
|
||||
uint8(0),
|
||||
uint8(0),
|
||||
0,
|
||||
0,
|
||||
data.Bytes(),
|
||||
), nil
|
||||
}
|
||||
@ -237,8 +237,8 @@ func NewCommandSign(data []byte) (*apdu.Command, error) {
|
||||
return apdu.NewCommand(
|
||||
globalplatform.ClaGp,
|
||||
InsSign,
|
||||
uint8(0),
|
||||
uint8(0),
|
||||
0,
|
||||
0,
|
||||
data,
|
||||
), nil
|
||||
}
|
||||
|
@ -7,43 +7,43 @@ import (
|
||||
|
||||
// Constants used in apdu commands and responses as defined by iso7816 and globalplatform.
|
||||
const (
|
||||
ClaISO7816 = uint8(0x00)
|
||||
ClaGp = uint8(0x80)
|
||||
ClaMac = uint8(0x84)
|
||||
ClaISO7816 = 0x00
|
||||
ClaGp = 0x80
|
||||
ClaMac = 0x84
|
||||
|
||||
InsSelect = uint8(0xA4)
|
||||
InsInitializeUpdate = uint8(0x50)
|
||||
InsExternalAuthenticate = uint8(0x82)
|
||||
InsGetResponse = uint8(0xC0)
|
||||
InsDelete = uint8(0xE4)
|
||||
InsLoad = uint8(0xE8)
|
||||
InsInstall = uint8(0xE6)
|
||||
InsGetStatus = uint8(0xF2)
|
||||
InsSelect = 0xA4
|
||||
InsInitializeUpdate = 0x50
|
||||
InsExternalAuthenticate = 0x82
|
||||
InsGetResponse = 0xC0
|
||||
InsDelete = 0xE4
|
||||
InsLoad = 0xE8
|
||||
InsInstall = 0xE6
|
||||
InsGetStatus = 0xF2
|
||||
|
||||
P1ExternalAuthenticateCMAC = uint8(0x01)
|
||||
P1InstallForLoad = uint8(0x02)
|
||||
P1InstallForInstall = uint8(0x04)
|
||||
P1InstallForMakeSelectable = uint8(0x08)
|
||||
P1LoadMoreBlocks = uint8(0x00)
|
||||
P1LoadLastBlock = uint8(0x80)
|
||||
P1GetStatusIssuerSecurityDomain = uint8(0x80)
|
||||
P1GetStatusApplications = uint8(0x40)
|
||||
P1GetStatusExecLoadFiles = uint8(0x20)
|
||||
P1GetStatusExecLoadFilesAndModules = uint8(0x10)
|
||||
P1ExternalAuthenticateCMAC = 0x01
|
||||
P1InstallForLoad = 0x02
|
||||
P1InstallForInstall = 0x04
|
||||
P1InstallForMakeSelectable = 0x08
|
||||
P1LoadMoreBlocks = 0x00
|
||||
P1LoadLastBlock = 0x80
|
||||
P1GetStatusIssuerSecurityDomain = 0x80
|
||||
P1GetStatusApplications = 0x40
|
||||
P1GetStatusExecLoadFiles = 0x20
|
||||
P1GetStatusExecLoadFilesAndModules = 0x10
|
||||
|
||||
P2GetStatusTLVData = uint8(0x02)
|
||||
P2GetStatusTLVData = 0x02
|
||||
|
||||
Sw1ResponseDataIncomplete = uint8(0x61)
|
||||
Sw1ResponseDataIncomplete = 0x61
|
||||
|
||||
SwOK = uint16(0x9000)
|
||||
SwFileNotFound = uint16(0x6A82)
|
||||
SwReferencedDataNotFound = uint16(0x6A88)
|
||||
SwSecurityConditionNotSatisfied = uint16(0x6982)
|
||||
SwAuthenticationMethodBlocked = uint16(0x6983)
|
||||
SwOK = 0x9000
|
||||
SwFileNotFound = 0x6A82
|
||||
SwReferencedDataNotFound = 0x6A88
|
||||
SwSecurityConditionNotSatisfied = 0x6982
|
||||
SwAuthenticationMethodBlocked = 0x6983
|
||||
|
||||
tagDeleteAID = byte(0x4F)
|
||||
tagLoadFileDataBlock = byte(0xC4)
|
||||
tagGetStatusAID = byte(0x4F)
|
||||
tagDeleteAID = 0x4F
|
||||
tagLoadFileDataBlock = 0xC4
|
||||
tagGetStatusAID = 0x4F
|
||||
)
|
||||
|
||||
// NewCommandSelect returns a Select command as defined in the globalplatform specifications.
|
||||
@ -51,8 +51,8 @@ func NewCommandSelect(aid []byte) *apdu.Command {
|
||||
c := apdu.NewCommand(
|
||||
ClaISO7816,
|
||||
InsSelect,
|
||||
uint8(0x04),
|
||||
uint8(0x00),
|
||||
0x04,
|
||||
0,
|
||||
aid,
|
||||
)
|
||||
|
||||
@ -68,8 +68,8 @@ func NewCommandInitializeUpdate(challenge []byte) *apdu.Command {
|
||||
c := apdu.NewCommand(
|
||||
ClaGp,
|
||||
InsInitializeUpdate,
|
||||
uint8(0x00),
|
||||
uint8(0x00),
|
||||
0,
|
||||
0,
|
||||
challenge,
|
||||
)
|
||||
|
||||
@ -91,7 +91,7 @@ func NewCommandExternalAuthenticate(encKey, cardChallenge, hostChallenge []byte)
|
||||
ClaMac,
|
||||
InsExternalAuthenticate,
|
||||
P1ExternalAuthenticateCMAC,
|
||||
uint8(0x00),
|
||||
0,
|
||||
hostCryptogram,
|
||||
), nil
|
||||
}
|
||||
@ -101,8 +101,8 @@ func NewCommandGetResponse(length uint8) *apdu.Command {
|
||||
c := apdu.NewCommand(
|
||||
ClaISO7816,
|
||||
InsGetResponse,
|
||||
uint8(0),
|
||||
uint8(0),
|
||||
0,
|
||||
0,
|
||||
nil,
|
||||
)
|
||||
|
||||
@ -119,8 +119,8 @@ func NewCommandDelete(aid []byte) *apdu.Command {
|
||||
return apdu.NewCommand(
|
||||
ClaGp,
|
||||
InsDelete,
|
||||
uint8(0x00),
|
||||
uint8(0x00),
|
||||
0,
|
||||
0,
|
||||
data,
|
||||
)
|
||||
}
|
||||
@ -138,7 +138,7 @@ func NewCommandInstallForLoad(aid, sdaid []byte) *apdu.Command {
|
||||
ClaGp,
|
||||
InsInstall,
|
||||
P1InstallForLoad,
|
||||
uint8(0x00),
|
||||
0,
|
||||
data,
|
||||
)
|
||||
}
|
||||
@ -171,7 +171,7 @@ func NewCommandInstallForInstall(pkgAID, appletAID, instanceAID, params []byte)
|
||||
ClaGp,
|
||||
InsInstall,
|
||||
P1InstallForInstall|P1InstallForMakeSelectable,
|
||||
uint8(0x00),
|
||||
0,
|
||||
data,
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user