mirror of
https://github.com/allankoechke/Bcrypt.cpp.git
synced 2026-12-03 01:02:22 +00:00
Move functions in openbsd.cpp to openbsd.h
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
<Unit filename="src/bcrypt.cpp" />
|
||||
<Unit filename="src/blf.h" />
|
||||
<Unit filename="src/blowfish.cpp" />
|
||||
<Unit filename="src/openbsd.cpp" />
|
||||
<Unit filename="src/openbsd.h" />
|
||||
<Unit filename="test/main.cpp" />
|
||||
<Extensions>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#include "openbsd.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,29 @@
|
||||
#define ARC4RANDOM_H_INCLUDED
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user