add install for load command
This commit is contained in:
parent
f718e4accc
commit
48ad7291b4
|
@ -15,6 +15,9 @@ const (
|
|||
InsExternalAuthenticate = uint8(0x82)
|
||||
InsGetResponse = uint8(0xC0)
|
||||
InsDelete = uint8(0xE4)
|
||||
InsInstall = uint8(0xE6)
|
||||
|
||||
P1InstallForLoad = uint8(0x02)
|
||||
|
||||
Sw1ResponseDataIncomplete = uint8(0x61)
|
||||
|
||||
|
@ -92,6 +95,23 @@ func NewCommandDelete(aid []byte) *apdu.Command {
|
|||
)
|
||||
}
|
||||
|
||||
func NewCommandInstallForLoad(aid, sdaid []byte) *apdu.Command {
|
||||
data := []byte{byte(len(aid))}
|
||||
data = append(data, aid...)
|
||||
data = append(data, byte(len(sdaid)))
|
||||
data = append(data, sdaid...)
|
||||
// empty hash length and hash
|
||||
data = append(data, []byte{0x00, 0x00, 0x00}...)
|
||||
|
||||
return apdu.NewCommand(
|
||||
ClaGp,
|
||||
InsInstall,
|
||||
P1InstallForLoad,
|
||||
uint8(0x00),
|
||||
data,
|
||||
)
|
||||
}
|
||||
|
||||
func calculateHostCryptogram(encKey, cardChallenge, hostChallenge []byte) ([]byte, error) {
|
||||
var data []byte
|
||||
data = append(data, cardChallenge...)
|
||||
|
|
|
@ -65,3 +65,16 @@ func TestNewCommandDelete(t *testing.T) {
|
|||
expected := "4F050102030405"
|
||||
assert.Equal(t, expected, hexutils.BytesToHex(cmd.Data))
|
||||
}
|
||||
|
||||
func TestNewCommandInstallForLoad(t *testing.T) {
|
||||
aid := hexutils.HexToBytes("53746174757357616C6C6574")
|
||||
sdaid := hexutils.HexToBytes("A000000151000000")
|
||||
cmd := NewCommandInstallForLoad(aid, sdaid)
|
||||
assert.Equal(t, uint8(0x80), cmd.Cla)
|
||||
assert.Equal(t, uint8(0xE6), cmd.Ins)
|
||||
assert.Equal(t, uint8(0x02), cmd.P1)
|
||||
assert.Equal(t, uint8(0x00), cmd.P2)
|
||||
|
||||
expected := "0C53746174757357616C6C657408A000000151000000000000"
|
||||
assert.Equal(t, expected, hexutils.BytesToHex(cmd.Data))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue