From 9106ae80d2196e3217b0749ae137c167bf8dbf6c Mon Sep 17 00:00:00 2001 From: Christoph Hilchenbach Date: Fri, 27 Dec 2019 16:52:10 +0100 Subject: [PATCH] Move functions in openbsd.cpp to openbsd.h --- bcrypt.cbp | 1 - src/openbsd.cpp | 24 ------------------------ src/openbsd.h | 25 ++++++++++++++++++++++--- 3 files changed, 22 insertions(+), 28 deletions(-) delete mode 100644 src/openbsd.cpp diff --git a/bcrypt.cbp b/bcrypt.cbp index 7ef8f0e..ba5e6a8 100644 --- a/bcrypt.cbp +++ b/bcrypt.cbp @@ -37,7 +37,6 @@ - diff --git a/src/openbsd.cpp b/src/openbsd.cpp deleted file mode 100644 index 644900f..0000000 --- a/src/openbsd.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "openbsd.h" -#include -#include -#include - - -void arc4random_buf(void *buf, size_t nbytes) -{ - for( size_t n = 0; n < nbytes; ++ n) - ((char*)(buf))[n] = rand() %256; -} - -void arc4random_init(void) -{ - srand( (unsigned int) time(NULL)); -} - -void explicit_bzero(void *b, size_t len) -{ - volatile void * dont_optimize = memset( b, 0, len ); - dont_optimize = dont_optimize; -} - - diff --git a/src/openbsd.h b/src/openbsd.h index e6e2029..33cfa76 100644 --- a/src/openbsd.h +++ b/src/openbsd.h @@ -2,10 +2,29 @@ #define ARC4RANDOM_H_INCLUDED #include +#include +#include + +inline +void arc4random_buf(void *buf, size_t nbytes) +{ + for( size_t n = 0; n < nbytes; ++ n) + ((char*)(buf))[n] = rand() %256; +} + +inline +void arc4random_init(void) +{ + srand( (unsigned int) time(NULL)); +} + +inline +void explicit_bzero(void *b, size_t len) +{ + volatile void * dont_optimize = memset( b, 0, len ); + dont_optimize = dont_optimize; +} -void arc4random_buf(void *buf, size_t nbytes); -void explicit_bzero(void *b, size_t len); -void arc4random_init(void); #endif // ARC4RANDOM_H_INCLUDED