test
This commit is contained in:
@@ -1056,16 +1056,49 @@ double OS_milliseconds()
|
|||||||
return(millis);
|
return(millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OS_portable_randombytes(unsigned char *x,long xlen)
|
||||||
|
{
|
||||||
|
static int fd = -1;
|
||||||
|
int32_t i;
|
||||||
|
if (fd == -1) {
|
||||||
|
for (;;) {
|
||||||
|
fd = open("/dev/urandom",O_RDONLY);
|
||||||
|
if (fd != -1) break;
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (xlen > 0) {
|
||||||
|
if (xlen < 1048576) i = (int32_t)xlen; else i = 1048576;
|
||||||
|
i = (int32_t)read(fd,x,i);
|
||||||
|
if (i < 1) {
|
||||||
|
sleep(1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( 0 )
|
||||||
|
{
|
||||||
|
int32_t j;
|
||||||
|
for (j=0; j<i; j++)
|
||||||
|
printf("%02x ",x[j]);
|
||||||
|
printf("-> %p\n",x);
|
||||||
|
}
|
||||||
|
x += i;
|
||||||
|
xlen -= i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void komodo_configfile(char *symbol,uint16_t port)
|
void komodo_configfile(char *symbol,uint16_t port)
|
||||||
{
|
{
|
||||||
FILE *fp; long long buf2[8]; char fname[512],buf[128],line[4096],*str,*rpcuser,*rpcpassword; uint32_t crc,r,r2;
|
FILE *fp; uint8_t buf2[512]; char fname[512],buf[128],line[4096],*str,*rpcuser,*rpcpassword; uint32_t crc,r,r2;
|
||||||
r = (uint32_t)time(NULL);
|
r = (uint32_t)time(NULL);
|
||||||
r2 = OS_milliseconds();
|
r2 = OS_milliseconds();
|
||||||
memcpy(buf,&r,sizeof(r));
|
memcpy(buf,&r,sizeof(r));
|
||||||
memcpy(&buf[sizeof(r)],&r2,sizeof(r2));
|
memcpy(&buf[sizeof(r)],&r2,sizeof(r2));
|
||||||
memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol));
|
memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol));
|
||||||
crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol)));
|
crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol)));
|
||||||
vcalc_sha256(line,(uint8_t *)buf2,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol)));
|
OS_randombytes(buf2,sizeof(buf2));
|
||||||
|
for (i=0; i<sizeof(buf2); i++)
|
||||||
|
sprintf(&line[i*2],"%02x",buf2[i]);
|
||||||
|
line[i*2] = 0;
|
||||||
sprintf(buf,"%s.conf",symbol);
|
sprintf(buf,"%s.conf",symbol);
|
||||||
BITCOIND_PORT = port;
|
BITCOIND_PORT = port;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|||||||
Reference in New Issue
Block a user