patch-ext_mcrypt_mcrypt_c 730 B

123456789101112131415161718192021222324252627
  1. $OpenBSD: patch-ext_mcrypt_mcrypt_c,v 1.3 2016/12/19 20:35:09 martijn Exp $
  2. mcrypt IV creation. no /dev/{u,}random? yes, it is using the last hunk.
  3. --- ext/mcrypt/mcrypt.c.orig.port Wed Nov 9 02:22:57 2016
  4. +++ ext/mcrypt/mcrypt.c Thu Dec 8 10:55:26 2016
  5. @@ -1445,7 +1445,10 @@ PHP_FUNCTION(mcrypt_create_iv)
  6. }
  7. iv = ecalloc(size + 1, 1);
  8. -
  9. +#if defined(__OpenBSD__)
  10. + arc4random_buf(iv, (size_t) size);
  11. + n = size;
  12. +#else
  13. if (source == RANDOM || source == URANDOM) {
  14. #if PHP_WIN32
  15. /* random/urandom equivalent on Windows */
  16. @@ -1490,6 +1493,7 @@ PHP_FUNCTION(mcrypt_create_iv)
  17. iv[--size] = (char) (255.0 * php_rand(TSRMLS_C) / RAND_MAX);
  18. }
  19. }
  20. +#endif /* openbsd */
  21. RETURN_STRINGL(iv, n, 0);
  22. }
  23. /* }}} */