| 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 "extension.h" | 9 #include "extension.h" |
| 10 | 10 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 ; | 283 ; |
| 284 ::srand((tmCur << 16) | (tmLast & 0xFFFF)); | 284 ::srand((tmCur << 16) | (tmLast & 0xFFFF)); |
| 285 #endif | 285 #endif |
| 286 while (iCount-- > 0) { | 286 while (iCount-- > 0) { |
| 287 *pBuffer++ = (FX_DWORD)((::rand() << 16) | (::rand() & 0xFFFF)); | 287 *pBuffer++ = (FX_DWORD)((::rand() << 16) | (::rand() & 0xFFFF)); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 290 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 291 FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount) { | 291 FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount) { |
| 292 HCRYPTPROV hCP = NULL; | 292 HCRYPTPROV hCP = NULL; |
| 293 if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) || | 293 if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) || !hCP) { |
| 294 hCP == NULL) { | |
| 295 return FALSE; | 294 return FALSE; |
| 296 } | 295 } |
| 297 ::CryptGenRandom(hCP, iCount * sizeof(FX_DWORD), (uint8_t*)pBuffer); | 296 ::CryptGenRandom(hCP, iCount * sizeof(FX_DWORD), (uint8_t*)pBuffer); |
| 298 ::CryptReleaseContext(hCP, 0); | 297 ::CryptReleaseContext(hCP, 0); |
| 299 return TRUE; | 298 return TRUE; |
| 300 } | 299 } |
| 301 #endif | 300 #endif |
| 302 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { | 301 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { |
| 303 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 302 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 304 FX_GenerateCryptoRandom(pBuffer, iCount); | 303 FX_GenerateCryptoRandom(pBuffer, iCount); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 334 b = ((const uint8_t*)pGUID)[i]; | 333 b = ((const uint8_t*)pGUID)[i]; |
| 335 *pBuf++ = gs_FX_pHexChars[b >> 4]; | 334 *pBuf++ = gs_FX_pHexChars[b >> 4]; |
| 336 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; | 335 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; |
| 337 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 336 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
| 338 *pBuf++ = L'-'; | 337 *pBuf++ = L'-'; |
| 339 } | 338 } |
| 340 } | 339 } |
| 341 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 340 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
| 342 } | 341 } |
| 343 #endif // PDF_ENABLE_XFA | 342 #endif // PDF_ENABLE_XFA |
| OLD | NEW |