openssl_random_pseudo_bytes () yavaş (PHP)

3 Cevap php

PHP) (opennssl_random_pseudo_bytes kullanıyorum ve yavaş yavaş ultra gerçekleştiriyor. Benim uygulama sık sık (yani yürütme zamanı sınırı hata atar) zaman aşımı. Bu yavaş rastgele OpenSSL için özel bir neden var mı? Şu anda benim geliştirici makineye Windows 7 x86 kullanıyorum.

3 Cevap

Bu görünüşte PHP

Fixed possible blocking behavior in openssl_random_pseudo_bytes on Windows. (Pierre)

http://php.net/ChangeLog-5.php#5.3.4

Windows'ta, openssl_random_pseudo_bytes () entropi oluşturmak için OpenSSL RAND_screen () çağırır. Oldukça yavaş ve PHP neredeyse bu karşı tükendi ilk unix-> pencereler liman. Sık tavsiye yerine RAND_seed () kullanmak gibi görünüyor.

Bu OpenSSL belgelerine durumları not da ilginç:

The RAND_screen() function is available for the convenience of Windows programmers. It adds the current contents of the screen to the PRNG. For applications that can catch Windows events, seeding the PRNG by calling RAND_event() is a significantly better source of randomness. **It should be noted that both methods cannot be used on servers that run without user interaction**.

Yani bu aslında bir sertifikalı hata olabilir - Ben zaten çekirdek Devs ile gündeme ettik. Win32 üzerinde OpenSSL için entropi üretmek için daha iyi bir yöntem kullanılabilir hale gelinceye kadar, bu kısa cevabı olduğu görülmektedir "Evet, Windows üzerinde yavaş. Bunun için üzgünüm."

Sorunu tartışmak Bazı ek bağlantılar:

Open Bug at rt.openssl.org
curl developers discuss alternative methods of collecting entropy on Win32
Google Groups archive of OpenSSL Users List discussing the slowness of RAND_poll() on Win32
Another discussion on the slowness of RAND_screen() on mail-archive.com's archive of OpenSSL Users

Bu PHP çalıştırmak nasıl bağlıdır. Benim win7-64bit PHP5.3.27 On

  1. Apache + PHP-CGI Bu 600ms alır =
  2. Apache + PHP5 Modül = Bu anlık bir