< Previous by Date | Date Index | Next by Date > |
< Previous in Thread | Thread Index | Next in Thread > |
We are using Linux RedHat 5 and there is seriously an
insufficient randomness issue. Look at the given code (uses the logic from Resiprocate
source code). I see that the random numbers generated are repeated in
re-invite scenario between 200 – 300 millsecs., leading to
branch/transaction-ids not unique. Trying to come up something using Boost library’s random
number generators at this point. Resiprocate developers have to definitely
think of something for this issue. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/time.h> #include <unistd.h> #include <map> #include <iostream> typedef unsigned long long UInt64; using namespace std; UInt64 getSystemTime() { struct timeval now; UInt64 time=0; gettimeofday( &now , NULL ); time = now.tv_sec; time = time*1000000; time += now.tv_usec; return time; } int main() { map<int,
int> random_map; unsigned int
seed = static_cast<unsigned int> (getSystemTime()/1000LL); srandom(seed); int fd =
open("/dev/urandom", O_RDONLY); if ( fd != -1 ) {
int s = read( fd,&seed,sizeof(seed) ); //!ah! blocks if /dev/random on
embedded sys
if ( s != sizeof(seed) )
{
cout << "System is short of randomness" << endl ;
// !ah! never prints
} ::close(fd); } else {
cout << "Could not open /dev/urandom" ; } for (int i = 0;
i < 100000; i++) {
pair<map<int, int>::iterator,bool> ret;
int rand = random();
ret=random_map.insert(make_pair(rand, 0));
if (ret.second==false)
{
cout << "ERROR !!! sizeofmap:" << random_map.size()
<< endl;
break;
} } random_map.clear(); return 0; } From: Jeremy Geras
[mailto:jgeras@xxxxxxxxxxxxxxx] We've
hit this before as well -- it manifested itself in our unit tests, where
generation of branch parameters, etc., happens more frequently than in typical real-life
usage. I've
attached our version of Random which uses RtlGenRandom on Windows to get around
the insufficient randomness issue. (Note
that this fix is sitting around on our last contrib branch at https://svn.resiprocate.org/rep/resiprocate/branches/b-ctpc-fixes-20090113 --
the branch is somewhat old, but nonetheless if anyone has time to give it a
review then maybe we can merge it to mainline...) Jeremy From:
resiprocate-users-bounces@xxxxxxxxxxxxxxx
[resiprocate-users-bounces@xxxxxxxxxxxxxxx] on behalf of Vasanthi Ramasamy
[Vasanthi.Ramasamy@xxxxxxxxxx] Yes I’m using provideOffer(). I’m looking at the random number generation code in
rutil/Random.cxx to crack it down. I will update you with my
findings. From: slgodin@xxxxxxxxx [mailto:slgodin@xxxxxxxxx] On Behalf Of Scott
Godin That
doesn't sound right - resip will automatically generate a new via for each
outbound request. I don't remember any known issues with this in the
past. Are you using DUM and the provideOffer API to send the re-invite? On Tue, Nov 23, 2010 at 2:21 PM, Vasanthi
Ramasamy <Vasanthi.Ramasamy@xxxxxxxxxx>
wrote: Hi, |