changed why2_random to boolean
This commit is contained in:
parent
fc2d3e1360
commit
25782d1263
@ -25,6 +25,8 @@ extern "C" {
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <why2/flags.h>
|
||||||
|
|
||||||
//MACROS
|
//MACROS
|
||||||
#define WHY2_SUM_SEGMENT_SIZE 32 //SEGMENT SIZE FOR CALCULATING SUM
|
#define WHY2_SUM_SEGMENT_SIZE 32 //SEGMENT SIZE FOR CALCULATING SUM
|
||||||
#define WHY2_SUM_BASE_PRIME 31 //PRIME FOR SUM BASE
|
#define WHY2_SUM_BASE_PRIME 31 //PRIME FOR SUM BASE
|
||||||
@ -35,7 +37,7 @@ extern "C" {
|
|||||||
|
|
||||||
//FUNCTIONS
|
//FUNCTIONS
|
||||||
unsigned long long why2_sum_segment(char *input); //CALCULATE SUM++ FOR input; USED FOR PADDING SEED
|
unsigned long long why2_sum_segment(char *input); //CALCULATE SUM++ FOR input; USED FOR PADDING SEED
|
||||||
ssize_t why2_random(void *dest, size_t size); //WRITE CRYPTO-SECURE RANDOM NUMBER INTO dest
|
why2_bool why2_random(void *dest, size_t size); //WRITE CRYPTO-SECURE RANDOM NUMBER INTO dest
|
||||||
void why2_seed_random(unsigned int seed); //SEED why2_seeded_random OUTPUT
|
void why2_seed_random(unsigned int seed); //SEED why2_seeded_random OUTPUT
|
||||||
int why2_seeded_random(); //GENERATE RANDOM NUMBER BASED ON SEED PASSED IN why2_seed_random
|
int why2_seeded_random(); //GENERATE RANDOM NUMBER BASED ON SEED PASSED IN why2_seed_random
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
|
#include <why2/flags.h>
|
||||||
|
|
||||||
unsigned long long why2_sum_segment(char *input) //THE OUTPUT IS GOING TO GROW A LOT WITH LONG input, BUT IT SHOULDN'T BE A BIG PROBLEM. I TESTED FOR OVERFLOWS UP TO 4096-CHAR input AND ONLY GOT TO (14*10^(-7))% OF FULL ULL RANGE LMAO
|
unsigned long long why2_sum_segment(char *input) //THE OUTPUT IS GOING TO GROW A LOT WITH LONG input, BUT IT SHOULDN'T BE A BIG PROBLEM. I TESTED FOR OVERFLOWS UP TO 4096-CHAR input AND ONLY GOT TO (14*10^(-7))% OF FULL ULL RANGE LMAO
|
||||||
{
|
{
|
||||||
unsigned long input_size = strlen(input);
|
unsigned long input_size = strlen(input);
|
||||||
@ -50,7 +52,7 @@ unsigned long long why2_sum_segment(char *input) //THE OUTPUT IS GOING TO GROW A
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t why2_random(void *dest, size_t size)
|
why2_bool why2_random(void *dest, size_t size)
|
||||||
{
|
{
|
||||||
return RAND_bytes((unsigned char*) dest, size) == 1;
|
return RAND_bytes((unsigned char*) dest, size) == 1;
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@ char *why2_generate_key(int key_length)
|
|||||||
for (int i = 0; i < key_length; i++)
|
for (int i = 0; i < key_length; i++)
|
||||||
{
|
{
|
||||||
//GET RANDOM NUMBER
|
//GET RANDOM NUMBER
|
||||||
if (why2_random(&random_buffer, sizeof(unsigned int)) == -1) why2_die("getrandom fn failed!");
|
if (!why2_random(&random_buffer, sizeof(unsigned int))) why2_die("getrandom fn failed!");
|
||||||
|
|
||||||
//SET numberBuffer TO RANDOM NUMBER BETWEEN 0 AND 52
|
//SET numberBuffer TO RANDOM NUMBER BETWEEN 0 AND 52
|
||||||
number_buffer = (random_buffer % 52) + 1;
|
number_buffer = (random_buffer % 52) + 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user