add delete command

This commit is contained in:
Andrea Franz 2018-10-02 13:44:14 +02:00
parent 02fb9f848c
commit c55b6e1593
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 21 additions and 0 deletions

View File

@ -14,6 +14,7 @@ const (
InsInitializeUpdate = uint8(0x50)
InsExternalAuthenticate = uint8(0x82)
InsGetResponse = uint8(0xC0)
InsDelete = uint8(0xE4)
Sw1ResponseDataIncomplete = uint8(0x61)
)
@ -71,6 +72,16 @@ func NewCommandGetResponse(length uint8) *apdu.Command {
return c
}
func NewCommandDelete(aid []byte) *apdu.Command {
return apdu.NewCommand(
ClaGp,
InsDelete,
uint8(0x00),
uint8(0x00),
aid,
)
}
func calculateHostCryptogram(encKey, cardChallenge, hostChallenge []byte) ([]byte, error) {
var data []byte
data = append(data, cardChallenge...)

View File

@ -53,3 +53,13 @@ func TestNewCommandExternalAuthenticate(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, expected, hexutils.BytesToHexWithSpaces(raw))
}
func TestNewCommandDelete(t *testing.T) {
aid := hexutils.HexToBytes("0102030405")
cmd := NewCommandDelete(aid)
assert.Equal(t, uint8(0x80), cmd.Cla)
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)
}