add install for install command
This commit is contained in:
parent
48ad7291b4
commit
fd2a1eda27
|
@ -17,7 +17,9 @@ const (
|
|||
InsDelete = uint8(0xE4)
|
||||
InsInstall = uint8(0xE6)
|
||||
|
||||
P1InstallForLoad = uint8(0x02)
|
||||
P1InstallForLoad = uint8(0x02)
|
||||
P1InstallForInstall = uint8(0x04)
|
||||
P1InstallForMakeSelectable = uint8(0x08)
|
||||
|
||||
Sw1ResponseDataIncomplete = uint8(0x61)
|
||||
|
||||
|
@ -112,6 +114,38 @@ func NewCommandInstallForLoad(aid, sdaid []byte) *apdu.Command {
|
|||
)
|
||||
}
|
||||
|
||||
func NewCommandInstallForInstall(pkgAID, appletAID, instanceAID, params []byte) *apdu.Command {
|
||||
data := []byte{byte(len(pkgAID))}
|
||||
data = append(data, pkgAID...)
|
||||
data = append(data, byte(len(appletAID)))
|
||||
data = append(data, appletAID...)
|
||||
data = append(data, byte(len(instanceAID)))
|
||||
data = append(data, instanceAID...)
|
||||
|
||||
// privileges
|
||||
priv := []byte{0x00}
|
||||
data = append(data, byte(len(priv)))
|
||||
data = append(data, priv...)
|
||||
|
||||
// params
|
||||
fullParams := []byte{byte(0xC9), byte(len(params))}
|
||||
fullParams = append(fullParams, params...)
|
||||
|
||||
data = append(data, byte(len(fullParams)))
|
||||
data = append(data, fullParams...)
|
||||
|
||||
// empty perform token
|
||||
data = append(data, byte(0x00))
|
||||
|
||||
return apdu.NewCommand(
|
||||
ClaGp,
|
||||
InsInstall,
|
||||
P1InstallForInstall|P1InstallForMakeSelectable,
|
||||
uint8(0x00),
|
||||
data,
|
||||
)
|
||||
}
|
||||
|
||||
func calculateHostCryptogram(encKey, cardChallenge, hostChallenge []byte) ([]byte, error) {
|
||||
var data []byte
|
||||
data = append(data, cardChallenge...)
|
||||
|
|
|
@ -78,3 +78,19 @@ func TestNewCommandInstallForLoad(t *testing.T) {
|
|||
expected := "0C53746174757357616C6C657408A000000151000000000000"
|
||||
assert.Equal(t, expected, hexutils.BytesToHex(cmd.Data))
|
||||
}
|
||||
|
||||
func TestNewCommandInstallForInstall(t *testing.T) {
|
||||
pkgAID := hexutils.HexToBytes("53746174757357616C6C6574")
|
||||
appletAID := hexutils.HexToBytes("53746174757357616C6C6574417070")
|
||||
instanceAID := hexutils.HexToBytes("53746174757357616C6C6574417070")
|
||||
params := hexutils.HexToBytes("AABBCC")
|
||||
|
||||
cmd := NewCommandInstallForInstall(pkgAID, appletAID, instanceAID, params)
|
||||
assert.Equal(t, uint8(0x80), cmd.Cla)
|
||||
assert.Equal(t, uint8(0xE6), cmd.Ins)
|
||||
assert.Equal(t, uint8(0x0C), cmd.P1)
|
||||
assert.Equal(t, uint8(0x00), cmd.P2)
|
||||
|
||||
expected := "0C53746174757357616C6C65740F53746174757357616C6C65744170700F53746174757357616C6C6574417070010005C903AABBCC00"
|
||||
assert.Equal(t, expected, hexutils.BytesToHex(cmd.Data))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue