github.com/usbarmory/GoTEE@v0.0.0-20240405084336-c52770d9fcdb/applet/applet.go (about) 1 // Copyright (c) WithSecure Corporation 2 // https://foundry.withsecure.com 3 // 4 // Use of this source code is governed by the license 5 // that can be found in the LICENSE file. 6 7 package applet 8 9 import ( 10 _ "unsafe" 11 12 "github.com/usbarmory/GoTEE/syscall" 13 ) 14 15 //go:linkname printk runtime.printk 16 func printk(c byte) { 17 syscall.Print(c) 18 } 19 20 //go:linkname initRNG runtime.initRNG 21 func initRNG() { 22 // no initialization required in supervised mode 23 } 24 25 //go:linkname getRandomData runtime.getRandomData 26 func getRandomData(b []byte) { 27 syscall.GetRandom(b, uint(len(b))) 28 } 29 30 // Exit signals the applet termination to its supervisor. 31 func Exit() { 32 syscall.Exit() 33 } 34 35 // Crash forces a nil pointer dereference to terminate the applet through an 36 // exception, it is meant to be used as runtime.Exit to yield to monitor on 37 // runtime panic. 38 func Crash() { 39 *(*int)(nil) = 0 40 }