OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/include/fxcrt/fx_basic.h" | 7 #include "core/include/fxcrt/fx_basic.h" |
8 #include "core/include/fxcrt/fx_ext.h" | 8 #include "core/include/fxcrt/fx_ext.h" |
9 #include "core/src/fxcrt/extension.h" | 9 #include "core/src/fxcrt/extension.h" |
10 | 10 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 ::GetSystemTime(&st1); | 325 ::GetSystemTime(&st1); |
326 do { | 326 do { |
327 ::GetSystemTime(&st2); | 327 ::GetSystemTime(&st2); |
328 } while (FXSYS_memcmp(&st1, &st2, sizeof(SYSTEMTIME)) == 0); | 328 } while (FXSYS_memcmp(&st1, &st2, sizeof(SYSTEMTIME)) == 0); |
329 FX_DWORD dwHash1 = | 329 FX_DWORD dwHash1 = |
330 FX_HashCode_String_GetA((const FX_CHAR*)&st1, sizeof(st1), TRUE); | 330 FX_HashCode_String_GetA((const FX_CHAR*)&st1, sizeof(st1), TRUE); |
331 FX_DWORD dwHash2 = | 331 FX_DWORD dwHash2 = |
332 FX_HashCode_String_GetA((const FX_CHAR*)&st2, sizeof(st2), TRUE); | 332 FX_HashCode_String_GetA((const FX_CHAR*)&st2, sizeof(st2), TRUE); |
333 ::srand((dwHash1 << 16) | (FX_DWORD)dwHash2); | 333 ::srand((dwHash1 << 16) | (FX_DWORD)dwHash2); |
334 #else | 334 #else |
335 time_t tmLast = time(NULL), tmCur; | 335 time_t tmLast = time(NULL); |
336 while ((tmCur = time(NULL)) == tmLast) | 336 time_t tmCur; |
337 ; | 337 while ((tmCur = time(NULL)) == tmLast) { |
| 338 continue; |
| 339 } |
| 340 |
338 ::srand((tmCur << 16) | (tmLast & 0xFFFF)); | 341 ::srand((tmCur << 16) | (tmLast & 0xFFFF)); |
339 #endif | 342 #endif |
340 while (iCount-- > 0) { | 343 while (iCount-- > 0) { |
341 *pBuffer++ = (FX_DWORD)((::rand() << 16) | (::rand() & 0xFFFF)); | 344 *pBuffer++ = (FX_DWORD)((::rand() << 16) | (::rand() & 0xFFFF)); |
342 } | 345 } |
343 } | 346 } |
344 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 347 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
345 FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount) { | 348 FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount) { |
346 HCRYPTPROV hCP = NULL; | 349 HCRYPTPROV hCP = NULL; |
347 if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) || !hCP) { | 350 if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) || !hCP) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 b = ((const uint8_t*)pGUID)[i]; | 390 b = ((const uint8_t*)pGUID)[i]; |
388 *pBuf++ = gs_FX_pHexChars[b >> 4]; | 391 *pBuf++ = gs_FX_pHexChars[b >> 4]; |
389 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; | 392 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; |
390 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 393 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
391 *pBuf++ = L'-'; | 394 *pBuf++ = L'-'; |
392 } | 395 } |
393 } | 396 } |
394 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 397 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
395 } | 398 } |
396 #endif // PDF_ENABLE_XFA | 399 #endif // PDF_ENABLE_XFA |
OLD | NEW |