aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime/rand_hwrng.go
blob: 2c690b449071441afb7fbfa0c2ff9e1314a43b82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//go:build baremetal && (nrf || (stm32 && !(stm32f103 || stm32l0x1)) || (sam && atsamd51) || (sam && atsame5x) || esp32c3 || tkey)

// If you update the above build constraint, you'll probably also need to update
// src/crypto/rand/rand_baremetal.go.

package runtime

import "machine"

func hardwareRand() (n uint64, ok bool) {
	n1, err1 := machine.GetRNG()
	n2, err2 := machine.GetRNG()
	n = uint64(n1)<<32 | uint64(n2)
	ok = err1 == nil && err2 == nil
	return
}