add DeleteObject and DeleteObjectAndRelatedObject to gp cmdSet
This commit is contained in:
parent
9d48af884d
commit
96c3596fca
|
@ -57,29 +57,19 @@ func (cs *CommandSet) DeleteKeycardInstancesAndPackage() error {
|
|||
return ErrSecureChannelNotOpen
|
||||
}
|
||||
|
||||
instanceAID, err := identifiers.KeycardInstanceAID(identifiers.KeycardDefaultInstanceIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ids := [][]byte{
|
||||
identifiers.NdefInstanceAID,
|
||||
instanceAID,
|
||||
identifiers.PackageAID,
|
||||
}
|
||||
|
||||
for _, aid := range ids {
|
||||
err := cs.Delete(aid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return cs.DeleteObjectAndRelatedObject(identifiers.PackageAID)
|
||||
}
|
||||
|
||||
func (cs *CommandSet) Delete(aid []byte) error {
|
||||
cmd := NewCommandDelete(aid)
|
||||
func (cs *CommandSet) DeleteObject(aid []byte) error {
|
||||
return cs.Delete(aid, P2DeleteObject)
|
||||
}
|
||||
|
||||
func (cs *CommandSet) DeleteObjectAndRelatedObject(aid []byte) error {
|
||||
return cs.Delete(aid, P2DeleteObjectAndRelatedObject)
|
||||
}
|
||||
|
||||
func (cs *CommandSet) Delete(aid []byte, p2 uint8) error {
|
||||
cmd := NewCommandDelete(aid, p2)
|
||||
resp, err := cs.sc.Send(cmd)
|
||||
return cs.checkOK(resp, err, SwOK, SwReferencedDataNotFound)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,9 @@ const (
|
|||
P1GetStatusExecLoadFiles = 0x20
|
||||
P1GetStatusExecLoadFilesAndModules = 0x10
|
||||
|
||||
P2GetStatusTLVData = 0x02
|
||||
P2GetStatusTLVData = 0x02
|
||||
P2DeleteObject = 0x00
|
||||
P2DeleteObjectAndRelatedObject = 0x80
|
||||
|
||||
Sw1ResponseDataIncomplete = 0x61
|
||||
|
||||
|
@ -108,7 +110,7 @@ func NewCommandGetResponse(length uint8) *apdu.Command {
|
|||
}
|
||||
|
||||
// NewCommandDelete returns a Delete command as defined in the globalplatform specifications.
|
||||
func NewCommandDelete(aid []byte) *apdu.Command {
|
||||
func NewCommandDelete(aid []byte, p2 uint8) *apdu.Command {
|
||||
data := []byte{tagDeleteAID, byte(len(aid))}
|
||||
data = append(data, aid...)
|
||||
|
||||
|
@ -116,7 +118,7 @@ func NewCommandDelete(aid []byte) *apdu.Command {
|
|||
ClaGp,
|
||||
InsDelete,
|
||||
0,
|
||||
0,
|
||||
p2,
|
||||
data,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue