diff options
author | Jack Lloyd <[email protected]> | 2016-01-29 17:18:38 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-02-07 03:00:53 -0500 |
commit | 9379336ba62e273601623bf28ece112946aec1e1 (patch) | |
tree | af57abfbe639d4f2662ed0830db0a262610cbdd5 /src/lib/utils/os_utils.h | |
parent | e23cfdeb6d079a2c8d147142f31934d2c8b3a881 (diff) |
Add explicit fork check to HMAC_RNG
Add OS functions get_process_id, get_processor_timestamp, and
get_system_timestamp_ns. HMAC_RNG uses the pid call to detect forks to
initiate a reseed. It also adds the output of all three functions (the
pid, the CPU cycle counter, and the system timestamp) into the PRF input.
Calls the new OS timer functions from hres_timer entropy source.
Removes the call to QPC in es_win32 which is mostly redundant with the
one in hres_timer.
Diffstat (limited to 'src/lib/utils/os_utils.h')
-rw-r--r-- | src/lib/utils/os_utils.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/lib/utils/os_utils.h b/src/lib/utils/os_utils.h index 0030f88c9..3335463f7 100644 --- a/src/lib/utils/os_utils.h +++ b/src/lib/utils/os_utils.h @@ -1,6 +1,6 @@ /* * OS specific utility functions -* (C) 2015 Jack Lloyd +* (C) 2015,2016 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ @@ -14,6 +14,26 @@ namespace Botan { namespace OS { +/** +* Returns the OS assigned process ID, if available. Otherwise returns 0. +*/ +uint32_t get_process_id(); + +/** +* Returns the value of the hardware cycle counter, if available. +* Returns 0 if not available. On Windows uses QueryPerformanceCounter. +* On other platforms reads the native cycle counter directly. +* The epoch and update rate are arbitrary and may not be constant +* (depending on the hardware). +*/ +uint64_t get_processor_timestamp(); + +/** +* Returns the value of the system clock with best resolution available, +* normalized to nanoseconds resolution. +*/ +uint64_t get_system_timestamp_ns(); + /* * Returns the maximum amount of memory (in bytes) we could/should * hyptothetically allocate. Reads "BOTAN_MLOCK_POOL_SIZE" from @@ -22,9 +42,9 @@ namespace OS { size_t get_memory_locking_limit(); /* -* Request so many bytes of page-aligned RAM locked into memory OS -* calls (mlock, VirtualLock, or similar). Returns null on failure. The -* memory returned is zeroed. Free it with free_locked_pages. +* Request so many bytes of page-aligned RAM locked into memory using +* mlock, VirtualLock, or similar. Returns null on failure. The memory +* returned is zeroed. Free it with free_locked_pages. */ void* allocate_locked_pages(size_t length); |