< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] nonce delta incorrect when authenticating request


I believe the code, for windows only, in Timer.cxx::getSystemTime is causing
helper.cxx::advancedAuthenticateRequest to fail due to the nonce time delta
calculation.  For this scenario nonce is expected to most likely be the unix
epoch timestamp, getSystemTime can be normalized to return the unix-style
time on windows as follows.

UInt64
Timer::getSystemTime()
{
    assert( sizeof(UInt64) == 64/8 );
    UInt64 time=0;
#if defined(WIN32)      
    FILETIME ft;
        GetSystemTimeAsFileTime(&ft);
    ULARGE_INTEGER li;
    li.LowPart = ft.dwLowDateTime;
    li.HighPart = ft.dwHighDateTime;    

        /** Micro-second difference between windows and unix epoch time:
          * 01.01.1970 - 01.01.1601 = 11644473600000000
          */
    time = (li.QuadPart/10) - 11644473600000000ULL;
#else
    struct timeval now;
    gettimeofday( &now , NULL );
    //assert( now );
    time = now.tv_sec;
    time = time*1000000;
    time += now.tv_usec;
#endif
    return time;
}