remove useless uint castings

This commit is contained in:
Andrea Franz 2019-03-28 11:52:17 +01:00
parent 848c32046a
commit 3cdaf543d7
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 88 additions and 88 deletions

View File

@ -11,30 +11,30 @@ import (
) )
const ( const (
InsInit = uint8(0xFE) InsInit = 0xFE
InsOpenSecureChannel = uint8(0x10) InsOpenSecureChannel = 0x10
InsMutuallyAuthenticate = uint8(0x11) InsMutuallyAuthenticate = 0x11
InsPair = uint8(0x12) InsPair = 0x12
InsUnpair = uint8(0x13) InsUnpair = 0x13
InsGetStatus = uint8(0xF2) InsGetStatus = 0xF2
InsGenerateKey = uint8(0xD4) InsGenerateKey = 0xD4
InsRemoveKey = uint8(0xD3) InsRemoveKey = 0xD3
InsVerifyPIN = uint8(0x20) InsVerifyPIN = 0x20
InsChangePIN = uint8(0x21) InsChangePIN = 0x21
InsDeriveKey = uint8(0xD1) InsDeriveKey = 0xD1
InsSign = uint8(0xC0) InsSign = 0xC0
InsSetPinlessPath = uint8(0xC1) InsSetPinlessPath = 0xC1
P1PairingFirstStep = uint8(0x00) P1PairingFirstStep = 0x00
P1PairingFinalStep = uint8(0x01) P1PairingFinalStep = 0x01
P1GetStatusApplication = uint8(0x00) P1GetStatusApplication = 0x00
P1GetStatusKeyPath = uint8(0x01) P1GetStatusKeyPath = 0x01
P1DeriveKeyFromMaster = uint8(0x00) P1DeriveKeyFromMaster = 0x00
P1DeriveKeyFromParent = uint8(0x01) P1DeriveKeyFromParent = 0x01
P1DeriveKeyFromCurrent = uint8(0x10) P1DeriveKeyFromCurrent = 0x10
P1ChangePinPIN = uint8(0x00) P1ChangePinPIN = 0x00
P1ChangePinPUK = uint8(0x01) P1ChangePinPUK = 0x01
P1ChangePinPairingSecret = uint8(0x02) P1ChangePinPairingSecret = 0x02
SwNoAvailablePairingSlots = 0x6A84 SwNoAvailablePairingSlots = 0x6A84
) )
@ -43,8 +43,8 @@ func NewCommandInit(data []byte) *apdu.Command {
return apdu.NewCommand( return apdu.NewCommand(
globalplatform.ClaGp, globalplatform.ClaGp,
InsInit, InsInit,
uint8(0x00), 0,
uint8(0x00), 0,
data, data,
) )
} }
@ -54,7 +54,7 @@ func NewCommandPairFirstStep(challenge []byte) *apdu.Command {
globalplatform.ClaGp, globalplatform.ClaGp,
InsPair, InsPair,
P1PairingFirstStep, P1PairingFirstStep,
uint8(0x00), 0,
challenge, challenge,
) )
} }
@ -64,7 +64,7 @@ func NewCommandPairFinalStep(cryptogramHash []byte) *apdu.Command {
globalplatform.ClaGp, globalplatform.ClaGp,
InsPair, InsPair,
P1PairingFinalStep, P1PairingFinalStep,
uint8(0x00), 0,
cryptogramHash, cryptogramHash,
) )
} }
@ -74,7 +74,7 @@ func NewCommandUnpair(index uint8) *apdu.Command {
globalplatform.ClaGp, globalplatform.ClaGp,
InsUnpair, InsUnpair,
index, index,
uint8(0), 0,
[]byte{}, []byte{},
) )
} }
@ -84,7 +84,7 @@ func NewCommandOpenSecureChannel(pairingIndex uint8, pubKey []byte) *apdu.Comman
globalplatform.ClaGp, globalplatform.ClaGp,
InsOpenSecureChannel, InsOpenSecureChannel,
pairingIndex, pairingIndex,
uint8(0x00), 0,
pubKey, pubKey,
) )
} }
@ -93,8 +93,8 @@ func NewCommandMutuallyAuthenticate(data []byte) *apdu.Command {
return apdu.NewCommand( return apdu.NewCommand(
globalplatform.ClaGp, globalplatform.ClaGp,
InsMutuallyAuthenticate, InsMutuallyAuthenticate,
uint8(0x00), 0,
uint8(0x00), 0,
data, data,
) )
} }
@ -104,7 +104,7 @@ func NewCommandGetStatus(p1 uint8) *apdu.Command {
globalplatform.ClaGp, globalplatform.ClaGp,
InsGetStatus, InsGetStatus,
p1, p1,
uint8(0x00), 0,
[]byte{}, []byte{},
) )
} }
@ -113,8 +113,8 @@ func NewCommandGenerateKey() *apdu.Command {
return apdu.NewCommand( return apdu.NewCommand(
globalplatform.ClaGp, globalplatform.ClaGp,
InsGenerateKey, InsGenerateKey,
uint8(0), 0,
uint8(0), 0,
[]byte{}, []byte{},
) )
} }
@ -123,8 +123,8 @@ func NewCommandRemoveKey() *apdu.Command {
return apdu.NewCommand( return apdu.NewCommand(
globalplatform.ClaGp, globalplatform.ClaGp,
InsRemoveKey, InsRemoveKey,
uint8(0), 0,
uint8(0), 0,
[]byte{}, []byte{},
) )
} }
@ -133,8 +133,8 @@ func NewCommandVerifyPIN(pin string) *apdu.Command {
return apdu.NewCommand( return apdu.NewCommand(
globalplatform.ClaGp, globalplatform.ClaGp,
InsVerifyPIN, InsVerifyPIN,
uint8(0), 0,
uint8(0), 0,
[]byte(pin), []byte(pin),
) )
} }
@ -144,7 +144,7 @@ func NewCommandChangePIN(pin string) *apdu.Command {
globalplatform.ClaGp, globalplatform.ClaGp,
InsChangePIN, InsChangePIN,
P1ChangePinPIN, P1ChangePinPIN,
uint8(0), 0,
[]byte(pin), []byte(pin),
) )
} }
@ -154,7 +154,7 @@ func NewCommandChangePUK(puk string) *apdu.Command {
globalplatform.ClaGp, globalplatform.ClaGp,
InsChangePIN, InsChangePIN,
P1ChangePinPUK, P1ChangePinPUK,
uint8(0), 0,
[]byte(puk), []byte(puk),
) )
} }
@ -164,7 +164,7 @@ func NewCommandChangePairingSecret(secret []byte) *apdu.Command {
globalplatform.ClaGp, globalplatform.ClaGp,
InsChangePIN, InsChangePIN,
P1ChangePinPairingSecret, P1ChangePinPairingSecret,
uint8(0), 0,
secret, secret,
) )
} }
@ -198,7 +198,7 @@ func NewCommandDeriveKey(pathStr string) (*apdu.Command, error) {
globalplatform.ClaGp, globalplatform.ClaGp,
InsDeriveKey, InsDeriveKey,
p1, p1,
uint8(0), 0,
data.Bytes(), data.Bytes(),
), nil ), nil
} }
@ -223,8 +223,8 @@ func NewCommandSetPinlessPath(pathStr string) (*apdu.Command, error) {
return apdu.NewCommand( return apdu.NewCommand(
globalplatform.ClaGp, globalplatform.ClaGp,
InsSetPinlessPath, InsSetPinlessPath,
uint8(0), 0,
uint8(0), 0,
data.Bytes(), data.Bytes(),
), nil ), nil
} }
@ -237,8 +237,8 @@ func NewCommandSign(data []byte) (*apdu.Command, error) {
return apdu.NewCommand( return apdu.NewCommand(
globalplatform.ClaGp, globalplatform.ClaGp,
InsSign, InsSign,
uint8(0), 0,
uint8(0), 0,
data, data,
), nil ), nil
} }

View File

@ -7,43 +7,43 @@ import (
// Constants used in apdu commands and responses as defined by iso7816 and globalplatform. // Constants used in apdu commands and responses as defined by iso7816 and globalplatform.
const ( const (
ClaISO7816 = uint8(0x00) ClaISO7816 = 0x00
ClaGp = uint8(0x80) ClaGp = 0x80
ClaMac = uint8(0x84) ClaMac = 0x84
InsSelect = uint8(0xA4) InsSelect = 0xA4
InsInitializeUpdate = uint8(0x50) InsInitializeUpdate = 0x50
InsExternalAuthenticate = uint8(0x82) InsExternalAuthenticate = 0x82
InsGetResponse = uint8(0xC0) InsGetResponse = 0xC0
InsDelete = uint8(0xE4) InsDelete = 0xE4
InsLoad = uint8(0xE8) InsLoad = 0xE8
InsInstall = uint8(0xE6) InsInstall = 0xE6
InsGetStatus = uint8(0xF2) InsGetStatus = 0xF2
P1ExternalAuthenticateCMAC = uint8(0x01) P1ExternalAuthenticateCMAC = 0x01
P1InstallForLoad = uint8(0x02) P1InstallForLoad = 0x02
P1InstallForInstall = uint8(0x04) P1InstallForInstall = 0x04
P1InstallForMakeSelectable = uint8(0x08) P1InstallForMakeSelectable = 0x08
P1LoadMoreBlocks = uint8(0x00) P1LoadMoreBlocks = 0x00
P1LoadLastBlock = uint8(0x80) P1LoadLastBlock = 0x80
P1GetStatusIssuerSecurityDomain = uint8(0x80) P1GetStatusIssuerSecurityDomain = 0x80
P1GetStatusApplications = uint8(0x40) P1GetStatusApplications = 0x40
P1GetStatusExecLoadFiles = uint8(0x20) P1GetStatusExecLoadFiles = 0x20
P1GetStatusExecLoadFilesAndModules = uint8(0x10) P1GetStatusExecLoadFilesAndModules = 0x10
P2GetStatusTLVData = uint8(0x02) P2GetStatusTLVData = 0x02
Sw1ResponseDataIncomplete = uint8(0x61) Sw1ResponseDataIncomplete = 0x61
SwOK = uint16(0x9000) SwOK = 0x9000
SwFileNotFound = uint16(0x6A82) SwFileNotFound = 0x6A82
SwReferencedDataNotFound = uint16(0x6A88) SwReferencedDataNotFound = 0x6A88
SwSecurityConditionNotSatisfied = uint16(0x6982) SwSecurityConditionNotSatisfied = 0x6982
SwAuthenticationMethodBlocked = uint16(0x6983) SwAuthenticationMethodBlocked = 0x6983
tagDeleteAID = byte(0x4F) tagDeleteAID = 0x4F
tagLoadFileDataBlock = byte(0xC4) tagLoadFileDataBlock = 0xC4
tagGetStatusAID = byte(0x4F) tagGetStatusAID = 0x4F
) )
// NewCommandSelect returns a Select command as defined in the globalplatform specifications. // NewCommandSelect returns a Select command as defined in the globalplatform specifications.
@ -51,8 +51,8 @@ func NewCommandSelect(aid []byte) *apdu.Command {
c := apdu.NewCommand( c := apdu.NewCommand(
ClaISO7816, ClaISO7816,
InsSelect, InsSelect,
uint8(0x04), 0x04,
uint8(0x00), 0,
aid, aid,
) )
@ -68,8 +68,8 @@ func NewCommandInitializeUpdate(challenge []byte) *apdu.Command {
c := apdu.NewCommand( c := apdu.NewCommand(
ClaGp, ClaGp,
InsInitializeUpdate, InsInitializeUpdate,
uint8(0x00), 0,
uint8(0x00), 0,
challenge, challenge,
) )
@ -91,7 +91,7 @@ func NewCommandExternalAuthenticate(encKey, cardChallenge, hostChallenge []byte)
ClaMac, ClaMac,
InsExternalAuthenticate, InsExternalAuthenticate,
P1ExternalAuthenticateCMAC, P1ExternalAuthenticateCMAC,
uint8(0x00), 0,
hostCryptogram, hostCryptogram,
), nil ), nil
} }
@ -101,8 +101,8 @@ func NewCommandGetResponse(length uint8) *apdu.Command {
c := apdu.NewCommand( c := apdu.NewCommand(
ClaISO7816, ClaISO7816,
InsGetResponse, InsGetResponse,
uint8(0), 0,
uint8(0), 0,
nil, nil,
) )
@ -119,8 +119,8 @@ func NewCommandDelete(aid []byte) *apdu.Command {
return apdu.NewCommand( return apdu.NewCommand(
ClaGp, ClaGp,
InsDelete, InsDelete,
uint8(0x00), 0,
uint8(0x00), 0,
data, data,
) )
} }
@ -138,7 +138,7 @@ func NewCommandInstallForLoad(aid, sdaid []byte) *apdu.Command {
ClaGp, ClaGp,
InsInstall, InsInstall,
P1InstallForLoad, P1InstallForLoad,
uint8(0x00), 0,
data, data,
) )
} }
@ -171,7 +171,7 @@ func NewCommandInstallForInstall(pkgAID, appletAID, instanceAID, params []byte)
ClaGp, ClaGp,
InsInstall, InsInstall,
P1InstallForInstall|P1InstallForMakeSelectable, P1InstallForInstall|P1InstallForMakeSelectable,
uint8(0x00), 0,
data, data,
) )
} }