Skip to content

Commit

Permalink
allow execution under qemu virtualization (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
abarisani authored Mar 20, 2024
1 parent c364329 commit 39c05ac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ support (requires a `tap0` device routing the Trusted Applet IP address).
> support by QEMU.
```bash
make DEBUG=1 make qemu
make DEBUG=1 FAKE_STORAGE=1 BEE=0 trusted_os_embedded_applet log_os qemu
...
00:00:00 tamago/arm • TEE security monitor (Secure World system/monitor)
00:00:00 SM applet verification
Expand Down
7 changes: 5 additions & 2 deletions trusted_os/ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ func getStatus() (s *api.Status) {
}

s = &api.Status{
Serial: fmt.Sprintf("%X", imx6ul.UniqueID()),
HAB: imx6ul.SNVS.Available(),
SRKHash: SRKHash,
Revision: Revision,
Build: Build,
Expand All @@ -100,6 +98,11 @@ func getStatus() (s *api.Status) {
s.Link = err != nil && mode == usbarmory.STATE_ATTACHED_SRC
}

if imx6ul.Native {
s.HAB = imx6ul.SNVS.Available()
s.Serial = fmt.Sprintf("%X", imx6ul.UniqueID())
}

return
}

Expand Down
8 changes: 5 additions & 3 deletions trusted_os/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func main() {
SRKHash: SRKHash,
}

if imx6ul.SNVS.Available() {
if imx6ul.Native && imx6ul.SNVS.Available() {
log.Printf("SM version verification (%s)", Version)

if err = rpmb.init(); err != nil {
Expand Down Expand Up @@ -250,8 +250,10 @@ func main() {
}
}()

// start USB control interface
ctl.Start()
if imx6ul.Native {
// start USB control interface
ctl.Start()
}

// never returns
handleInterrupts()
Expand Down
9 changes: 7 additions & 2 deletions trusted_os/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,14 @@ func (r *RPC) ReadRPMB(buf []byte, n *uint32) error {
//
// The diversifier is AES-CBC encrypted using the internal OTPMK key.
func (r *RPC) DeriveKey(diversifier [aes.BlockSize]byte, key *[sha256.Size]byte) (err error) {
if !imx6ul.SNVS.Available() && !debug {
switch {
case imx6ul.Native && !debug && !imx6ul.SNVS.Available():
return errors.New("Weird - SNVS not available but we're not in debug?!")
case !imx6ul.Native && debug:
// we support emulation only on debug builds, use input buffer as dummy key
return
case !imx6ul.Native && !debug:
return errors.New("Weird - under emulation but we're not in debug?!")
}

switch {
Expand All @@ -188,7 +194,6 @@ func (r *RPC) DeriveKey(diversifier [aes.BlockSize]byte, key *[sha256.Size]byte)
var k []byte
k, err = imx6ul.DCP.DeriveKey(r.Diversifier[:], diversifier[:], -1)
copy(key[:], k)
case debug && !imx6ul.Native:
default:
err = errors.New("unsupported hardware")
}
Expand Down

0 comments on commit 39c05ac

Please sign in to comment.