Utility for using the RDRAND instruction
On some x86_64 hardware the RDRAND instruction returns 64bits of entropy from an on-chip random number generator. RDRAND is not recommended as an exclusive source of entropy for cryptographic applications. https://en.wikipedia.org/wiki/RdRand
This commit is contained in:
committed by
Norman Feske
parent
85751b6f12
commit
2f760075a7
33
include/world/rdrand.h
Normal file
33
include/world/rdrand.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* \brief Utility for reading hardware RNG
|
||||
* \date 2019-02-05
|
||||
* \author Emery Hemingway
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2019 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__OS__RDRAND_H_
|
||||
#define _INCLUDE__OS__RDRAND_H_
|
||||
|
||||
#include <base/stdint.h>
|
||||
#include <base/log.h>
|
||||
|
||||
namespace Genode { namespace Rdrand {
|
||||
|
||||
constexpr
|
||||
bool supported() { return false; }
|
||||
|
||||
uint64_t random64()
|
||||
{
|
||||
error("RDRAND not available on this architecture");
|
||||
throw Exception();
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
#endif /* _INCLUDE__OS__RDRAND_H_ */
|
||||
Reference in New Issue
Block a user