Skip to content

Commit

Permalink
use improved GoTEE RPC API
Browse files Browse the repository at this point in the history
  • Loading branch information
abarisani committed Mar 18, 2024
1 parent 4266740 commit f980ed7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/transparency-dev/armored-witness-common v0.0.0-20240313170947-0b19d0fb8b95
github.com/transparency-dev/merkle v0.0.2
github.com/transparency-dev/serverless-log v0.0.0-20231215122707-66f68a7705f5
github.com/usbarmory/GoTEE v0.0.0-20240215171108-77a6b38432d5
github.com/usbarmory/GoTEE v0.0.0-20240314122327-40179239ad36
github.com/usbarmory/armory-boot v0.0.0-20230922092524-e66d926bc36c
github.com/usbarmory/crucible v0.0.0-20240221192724-1595f2219655
github.com/usbarmory/imx-usbnet v0.0.0-20240304152630-ca189bf3b3c1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ github.com/u-root/u-root v0.11.0 h1:6gCZLOeRyevw7gbTwMj3fKxnr9+yHFlgF3N7udUVNO8=
github.com/u-root/u-root v0.11.0/go.mod h1:DBkDtiZyONk9hzVEdB/PWI9B4TxDkElWlVTHseglrZY=
github.com/usbarmory/GoTEE v0.0.0-20240215171108-77a6b38432d5 h1:XJjhY/+my6o+h4hll02s7rMJrNtI2XqQBBcrx7Lp/2U=
github.com/usbarmory/GoTEE v0.0.0-20240215171108-77a6b38432d5/go.mod h1:YlZVucqxy/z5QWKerml3Vm5T14UOzZEs2kXfS1nilx8=
github.com/usbarmory/GoTEE v0.0.0-20240314122327-40179239ad36 h1:rZfhjJpgKuwos6KBdHKouDJmYmpV/FJv4q34eIjtPjw=
github.com/usbarmory/GoTEE v0.0.0-20240314122327-40179239ad36/go.mod h1:YlZVucqxy/z5QWKerml3Vm5T14UOzZEs2kXfS1nilx8=
github.com/usbarmory/armory-boot v0.0.0-20230922092524-e66d926bc36c h1:qQL3CljMNrk9TyG8EUvCAPU7/bTVitJMhqlKSNhskis=
github.com/usbarmory/armory-boot v0.0.0-20230922092524-e66d926bc36c/go.mod h1:20DIzHJntbLDOptGT7TOm8DkT5mL2jRyzPzVXAYVHJ8=
github.com/usbarmory/crucible v0.0.0-20240221192724-1595f2219655 h1:n3JkWqsxKsbX2SKy+ac3v2rgEmTWfA/s0SC5kHlJGBY=
Expand Down
35 changes: 19 additions & 16 deletions trusted_os/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package main

import (
"errors"
"fmt"
"net"

"github.com/usbarmory/tamago/soc/nxp/enet"
Expand Down Expand Up @@ -71,36 +71,39 @@ func asyncTx() (buf []byte) {
}

func rxFromApplet(ctx *monitor.ExecCtx) (err error) {
var n uint

select {
case buf := <-rxQueue:
off := ctx.A1() - ctx.Memory.Start()
n = uint(len(buf))
off, n, err := ctx.TransferRegion()

if !(off >= 0 && off < (ctx.Memory.Size()-n)) {
return errors.New("invalid offset")
if err != nil {
return err
}

ctx.Memory.Write(ctx.Memory.Start(), int(off), buf)
r := len(buf)

if r > n {
return fmt.Errorf("invalid transfer size (%d > %d)", r, n)
}

ctx.Memory.Write(ctx.Memory.Start(), off, buf)
ctx.Ret(r)
default:
ctx.Ret(0)
}

ctx.Ret(n)

return
}

func txFromApplet(ctx *monitor.ExecCtx) (err error) {
off := ctx.A1() - ctx.Memory.Start()
n := ctx.A2()
buf := make([]byte, n)
off, n, err := ctx.TransferRegion()

if !(off >= 0 && off < (ctx.Memory.Size()-uint(n))) {
return errors.New("invalid offset")
if err != nil {
return
}

ctx.Memory.Read(ctx.Memory.Start(), int(off), buf)
buf := make([]byte, n)

ctx.Memory.Read(ctx.Memory.Start(), off, buf)

switch {
case LAN != nil:
Expand Down

0 comments on commit f980ed7

Please sign in to comment.