sxt: sxt_reseed()
This commit is contained in:
parent
9e3da0fd3f
commit
967f161887
@ -51,5 +51,6 @@ SHA512CTX sha512_init(void);
|
|||||||
void sha512_update(SHA512CTX c, const void *data, unsigned long len);
|
void sha512_update(SHA512CTX c, const void *data, unsigned long len);
|
||||||
void sha512_final(unsigned char *md, SHA512CTX c);
|
void sha512_final(unsigned char *md, SHA512CTX c);
|
||||||
|
|
||||||
|
int lcrypt_reseed(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,4 +31,6 @@ int sxt_init(void);
|
|||||||
|
|
||||||
int sxt_finish(void);
|
int sxt_finish(void);
|
||||||
|
|
||||||
|
int sxt_reseed(void);
|
||||||
|
|
||||||
#endif /* __SXT_SXT_H__ */
|
#endif /* __SXT_SXT_H__ */
|
||||||
|
@ -72,6 +72,11 @@ int sxt_finish(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sxt_reseed(void)
|
||||||
|
{
|
||||||
|
return lcrypt_reseed();
|
||||||
|
}
|
||||||
|
|
||||||
int sxt_get_random(void *data, int len, int pseudo)
|
int sxt_get_random(void *data, int len, int pseudo)
|
||||||
{
|
{
|
||||||
if(pseudo) return RAND_bytes(data, len);
|
if(pseudo) return RAND_bytes(data, len);
|
||||||
|
12
sxt/lcrypt.c
12
sxt/lcrypt.c
@ -27,9 +27,11 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <openssl/aes.h>
|
#include <openssl/aes.h>
|
||||||
#include <openssl/blowfish.h>
|
#include <openssl/blowfish.h>
|
||||||
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
#include <sxt/errno.h>
|
#include <sxt/errno.h>
|
||||||
#include <sxt/ciphers.h>
|
#include <sxt/ciphers.h>
|
||||||
@ -171,3 +173,13 @@ int lcrypt_init_ciphers(void)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* misc */
|
||||||
|
int lcrypt_reseed(void)
|
||||||
|
{
|
||||||
|
#ifndef WIN32
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
RAND_add(&tv, sizeof(struct timeval), 0.0);
|
||||||
|
#endif
|
||||||
|
return SXT_SUCCESS;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user