Skip to content

Commit

Permalink
add tmprnd() for adhoc rng
Browse files Browse the repository at this point in the history
  • Loading branch information
voidanix committed Dec 10, 2020
1 parent 8f0142d commit 2dc19ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/engine/master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void reqauth(masterclient &c, uint id, char *name, char *hostname)
a.reqtime = totalmillis;
a.id = id;
copystring(a.hostname, host);
uint seed[3] = { uint(starttime), uint(totalmillis), randomMT() };
uint seed[3] = { uint(starttime), uint(totalmillis), tmprnd() };
static vector<char> buf;
buf.setsize(0);
a.answer = genchallenge(u->pubkey, seed, sizeof(seed), buf);
Expand All @@ -270,7 +270,7 @@ void reqserverauth(masterclient &c, char *name)

c.serverauthreq.user = u;
c.serverauthreq.reqtime = totalmillis;
uint seed[3] = { uint(starttime), uint(totalmillis), randomMT() };
uint seed[3] = { uint(starttime), uint(totalmillis), tmprnd() };
static vector<char> buf;
buf.setsize(0);
c.serverauthreq.answer = genchallenge(u->pubkey, seed, sizeof(seed), buf);
Expand Down
6 changes: 6 additions & 0 deletions src/shared/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ int detrnd(int seed, int value)
return rnddet(algseed);
}

// randomMT has been renamed to tmprnd for adhoc RNG
uint tmprnd()
{
return rndalg();
}

///////////////////////// network ///////////////////////

// all network traffic is in 32bit ints, which are then compressed using the following simple scheme (assumes that most values are small).
Expand Down
1 change: 1 addition & 0 deletions src/shared/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,7 @@ extern void endianswap(void *, int, int);
extern int rnd(int);
extern float rndfloat(int);
extern int detrnd(int, int);
extern uint tmprnd();
extern void putint(ucharbuf &p, int n);
extern void putint(packetbuf &p, int n);
extern void putint(vector<uchar> &p, int n);
Expand Down

0 comments on commit 2dc19ba

Please sign in to comment.