patch-ext_mcrypt_mcrypt_c 724 B

1234567891011121314151617181920212223242526
  1. $OpenBSD: patch-ext_mcrypt_mcrypt_c,v 1.2 2016/06/25 18:54:15 sthen Exp $
  2. mcrypt IV creation. no /dev/{u,}random? yes, it is using the last hunk.
  3. --- ext/mcrypt/mcrypt.c.orig.port Tue Jun 21 12:11:59 2016
  4. +++ ext/mcrypt/mcrypt.c Sat Jun 25 13:41:19 2016
  5. @@ -1411,6 +1411,10 @@ PHP_FUNCTION(mcrypt_create_iv)
  6. iv = ecalloc(size + 1, 1);
  7. +#if defined(__OpenBSD__)
  8. + arc4random_buf(iv, (size_t) size);
  9. + n = size;
  10. +#else
  11. if (source == RANDOM || source == URANDOM) {
  12. #if PHP_WIN32
  13. /* random/urandom equivalent on Windows */
  14. @@ -1455,6 +1459,7 @@ PHP_FUNCTION(mcrypt_create_iv)
  15. iv[--size] = (char) (255.0 * php_rand(TSRMLS_C) / RAND_MAX);
  16. }
  17. }
  18. +#endif /* openbsd */
  19. RETURN_STRINGL(iv, n, 0);
  20. }
  21. /* }}} */