Skip to content

Commit

Permalink
Move Linux-specific test from general package.
Browse files Browse the repository at this point in the history
  • Loading branch information
NullHypothesis committed Oct 12, 2024
1 parent b27bcb0 commit 10c7e78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
24 changes: 0 additions & 24 deletions internal/system/system.go

This file was deleted.

19 changes: 19 additions & 0 deletions internal/system/system_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@ package system

import (
"log"
"os"
"syscall"
)

const (
pathToRNG = "/sys/devices/virtual/misc/hw_random/rng_current"
wantRNG = "nsm-hwrng"
)

// HasSecureRNG checks if the enclave is configured to use the Nitro hardware
// RNG. This was suggested in:
// https://blog.trailofbits.com/2024/09/24/notes-on-aws-nitro-enclaves-attack-surface/
func HasSecureRNG() bool {
haveRNG, err := os.ReadFile(pathToRNG)
if err != nil {
log.Printf("Error reading %s: %v", pathToRNG, err)
return false
}
log.Printf("Have RNG: %s", haveRNG)
return string(haveRNG) == wantRNG
}

func HasSecureKernelVersion() bool {
var uname syscall.Utsname
if err := syscall.Uname(&uname); err != nil {
Expand Down

0 comments on commit 10c7e78

Please sign in to comment.