• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2016 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package unix
6
7import (
8	"syscall"
9	"unsafe"
10)
11
12// getentropy(2)'s syscall number, from /usr/src/sys/kern/syscalls.master
13const entropyTrap uintptr = 7
14
15// GetEntropy calls the OpenBSD getentropy system call.
16func GetEntropy(p []byte) error {
17	_, _, errno := syscall.Syscall(entropyTrap,
18		uintptr(unsafe.Pointer(&p[0])),
19		uintptr(len(p)),
20		0)
21	if errno != 0 {
22		return errno
23	}
24	return nil
25}
26