add tlv formatting to delete data

This commit is contained in:
Andrea Franz 2018-10-02 14:24:30 +02:00
parent c55b6e1593
commit 50bfda60e0
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 9 additions and 2 deletions

View File

@ -17,6 +17,8 @@ const (
InsDelete = uint8(0xE4)
Sw1ResponseDataIncomplete = uint8(0x61)
tagDeleteAID = byte(0x4F)
)
func NewCommandSelect(aid []byte) *apdu.Command {
@ -73,12 +75,15 @@ func NewCommandGetResponse(length uint8) *apdu.Command {
}
func NewCommandDelete(aid []byte) *apdu.Command {
data := []byte{tagDeleteAID, byte(len(aid))}
data = append(data, aid...)
return apdu.NewCommand(
ClaGp,
InsDelete,
uint8(0x00),
uint8(0x00),
aid,
data,
)
}

View File

@ -61,5 +61,7 @@ func TestNewCommandDelete(t *testing.T) {
assert.Equal(t, uint8(0xE4), cmd.Ins)
assert.Equal(t, uint8(0x00), cmd.P1)
assert.Equal(t, uint8(0x00), cmd.P2)
assert.Equal(t, aid, cmd.Data)
expected := "4F050102030405"
assert.Equal(t, expected, hexutils.BytesToHex(cmd.Data))
}