Thank you for reply
My code is pretty long so I'm not sure of uploading it, I guess I could upload a part of it, where I think cause the error.
Code:
#include "stdafx.h"
#include "openssl/sha.h"
#include <stdio.h>
#include <stdlib.h> /* required for randomize() and random() */
#include <time.h> /* required for time()*/
#include <math.h>
#include <fcntl.h>
#include <string.h>
#include "unistd.h"
#include "function.h"
#pragma once
#define Q 60
#define D 8
unsigned long B;
unsigned long ** key;
unsigned long rounds;
unsigned long rest;
unsigned long a,i,j,k,l,r;
int fd;
int RUSAGE_SELF;
int openssl(unsigned long rounds, unsigned long B )
{
unsigned char key[][32]= {""};//use to store all the 256-bit keys ,key[B][32] 8*32
unsigned char message[48]; //the first 64 bit of message stands for N,
//and 2nd 64 bits stands for R and the rest stands for key.
//definition de msg
unsigned char result[21];
unsigned char result_temp[22];
srand((unsigned) time(NULL));
for(r=0;r<rounds;r++)
{
fd = _open( "/dev/urandom", O_RDONLY );
_read( fd, (void *) key, B*32 );//2^16*16*2
_read(fd, (void *)message, 16);//64*2
_close(fd);
rand_1=rand() /64 %256;
rand_2=rand() /64 %256;
ID = rand_1+rand_2*256;
ID = ID%B;//in case ID >B
memcpy(message+16, key[ID],32);
SHA1(message,48,result);//instead of Ff fct
B=64;
for (i=0; i <B; i++)
{
memcpy(message+16, key[i],32);
SHA1(message,48,result_temp);
for(j=0; j<20; j++)
{
if(result_temp[j]!=result[j])
{
break;
}
}
if (j==20)
{
break;
}
}
}//end of rounds
return 0;
}