add install commands to installer

This commit is contained in:
Andrea Franz 2018-10-03 16:26:57 +02:00
parent 415fe350bf
commit 93171625e3
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
1 changed files with 31 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"crypto/rand"
"errors"
"fmt"
"os"
"github.com/status-im/status-go/smartcard/apdu"
"github.com/status-im/status-go/smartcard/globalplatform"
@ -28,7 +29,7 @@ func NewInstaller(t Transmitter) *Installer {
}
}
func (i *Installer) Install() error {
func (i *Installer) Install(capFile *os.File) error {
sel := globalplatform.NewCommandSelect(sdaid)
resp, err := i.send("select", sel)
if err != nil {
@ -82,6 +83,35 @@ func (i *Installer) Install() error {
}
}
// install for load
preLoad := globalplatform.NewCommandInstallForLoad(statusPkgAID, sdaid)
resp, err = i.send("install for load", preLoad)
if err != nil {
return err
}
// load
load, err := globalplatform.NewLoadCommandStream(capFile)
if err != nil {
return err
}
for load.Next() {
cmd := load.GetCommand()
resp, err = i.send(fmt.Sprintf("load %d", load.Index()), cmd)
if err != nil {
return err
}
}
// install for install
params := []byte{0xAA, 0xBB}
install := globalplatform.NewCommandInstallForInstall(statusPkgAID, statusAppletAID, statusAppletAID, params)
resp, err = i.send("install for install", install)
if err != nil {
return err
}
return nil
}