Merge pull request 'Changes to compile openssl-3.1.7 in vx6.9' (#4) from ossl_compilation into master
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/4
This commit is contained in:
@@ -15,23 +15,51 @@ Random Number Library
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <randomNumGen.h>
|
||||
#include <stdLib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <tickLib.h>
|
||||
|
||||
#include <openssl/rand.h>
|
||||
|
||||
/*
|
||||
* Writes `len` random bytes into `buf`.
|
||||
* Arguments:
|
||||
* buf - pointer to a buffer provided by the caller
|
||||
* len - number of random bytes to generate
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success
|
||||
*/
|
||||
int fill_random_bytes(uint8_t *buf, int len) {
|
||||
|
||||
int i;
|
||||
|
||||
srand((unsigned int)tickGet());
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
/* take lowest 8 bits */
|
||||
buf[i] = (uint8_t)(rand() & 0xFF);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int vxRandLibSeed(const void *buf, int num)
|
||||
{
|
||||
return randAdd(buf, num, num);
|
||||
|
||||
fill_random_bytes ((uint8_t *)buf, num);
|
||||
srand (buf);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int vxRandLibBytes(unsigned char *buf, int num)
|
||||
{
|
||||
int rc;
|
||||
rc = randABytes(buf, num);
|
||||
if (rc == OK)
|
||||
return 1;
|
||||
return 0;
|
||||
fill_random_bytes ((uint8_t *)buf, num);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static void vxRandLibCleanup(void)
|
||||
@@ -41,21 +69,28 @@ static void vxRandLibCleanup(void)
|
||||
|
||||
static int vxRandLibAdd(const void *buf, int num, double entropy)
|
||||
{
|
||||
return randAdd(buf, num, (int)entropy);
|
||||
fill_random_bytes ((uint8_t *)buf, num);
|
||||
srand (buf);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int vxRandLibPseudorand(unsigned char *buf, int num)
|
||||
{
|
||||
int rc;
|
||||
rc = randUBytes(buf, num);
|
||||
if (rc == OK)
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
fill_random_bytes ((uint8_t *)buf, num);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int vxRandLibStatus(void)
|
||||
{
|
||||
return randSecure();
|
||||
int i;
|
||||
|
||||
for (i=0; i< 2; i++)
|
||||
sleep (1);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static struct rand_meth_st vxRandLibMethSt =
|
||||
|
||||
Reference in New Issue
Block a user