add delete and load package methods to gp command set
This commit is contained in:
parent
d8a6a41ca7
commit
5f23138b45
|
@ -75,10 +75,9 @@ func (cs *CommandSet) DeleteKeycardInstancesAndPackage() error {
|
||||||
identifiers.PackageAID,
|
identifiers.PackageAID,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, id := range ids {
|
for _, aid := range ids {
|
||||||
cmd := NewCommandDelete(id)
|
err := cs.Delete(aid)
|
||||||
resp, err := cs.sc.Send(cmd)
|
if err != nil {
|
||||||
if cs.checkOK(resp, err, SwOK, SwReferencedDataNotFound) != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,12 +85,22 @@ func (cs *CommandSet) DeleteKeycardInstancesAndPackage() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cs *CommandSet) Delete(aid []byte) error {
|
||||||
|
cmd := NewCommandDelete(aid)
|
||||||
|
resp, err := cs.sc.Send(cmd)
|
||||||
|
return cs.checkOK(resp, err, SwOK, SwReferencedDataNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
func (cs *CommandSet) LoadKeycardPackage(capFile *os.File, callback LoadingCallback) error {
|
func (cs *CommandSet) LoadKeycardPackage(capFile *os.File, callback LoadingCallback) error {
|
||||||
|
return cs.LoadPackage(capFile, identifiers.PackageAID, callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *CommandSet) LoadPackage(capFile *os.File, pkgAID []byte, callback LoadingCallback) error {
|
||||||
if cs.sc == nil {
|
if cs.sc == nil {
|
||||||
return ErrSecureChannelNotOpen
|
return ErrSecureChannelNotOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
preLoad := NewCommandInstallForLoad(identifiers.PackageAID, []byte{})
|
preLoad := NewCommandInstallForLoad(pkgAID, []byte{})
|
||||||
resp, err := cs.sc.Send(preLoad)
|
resp, err := cs.sc.Send(preLoad)
|
||||||
if err = cs.checkOK(resp, err); err != nil {
|
if err = cs.checkOK(resp, err); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -115,7 +124,7 @@ func (cs *CommandSet) LoadKeycardPackage(capFile *os.File, callback LoadingCallb
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *CommandSet) InstallNDEFApplet(ndefRecord []byte) error {
|
func (cs *CommandSet) InstallNDEFApplet(ndefRecord []byte) error {
|
||||||
return cs.installForInstall(
|
return cs.InstallForInstall(
|
||||||
identifiers.PackageAID,
|
identifiers.PackageAID,
|
||||||
identifiers.NdefAID,
|
identifiers.NdefAID,
|
||||||
identifiers.NdefInstanceAID,
|
identifiers.NdefInstanceAID,
|
||||||
|
@ -128,14 +137,14 @@ func (cs *CommandSet) InstallKeycardApplet() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return cs.installForInstall(
|
return cs.InstallForInstall(
|
||||||
identifiers.PackageAID,
|
identifiers.PackageAID,
|
||||||
identifiers.KeycardAID,
|
identifiers.KeycardAID,
|
||||||
instanceAID,
|
instanceAID,
|
||||||
[]byte{})
|
[]byte{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *CommandSet) installForInstall(packageAID, appletAID, instanceAID, params []byte) error {
|
func (cs *CommandSet) InstallForInstall(packageAID, appletAID, instanceAID, params []byte) error {
|
||||||
cmd := NewCommandInstallForInstall(packageAID, appletAID, instanceAID, params)
|
cmd := NewCommandInstallForInstall(packageAID, appletAID, instanceAID, params)
|
||||||
resp, err := cs.sc.Send(cmd)
|
resp, err := cs.sc.Send(cmd)
|
||||||
return cs.checkOK(resp, err)
|
return cs.checkOK(resp, err)
|
||||||
|
|
Loading…
Reference in New Issue