php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62375 Add constant "GMP_LIMB_BITS" to GMP
Submitted: 2012-06-20 18:16 UTC Modified: 2018-07-02 16:06 UTC
Votes:8
Avg. Score:3.5 ± 1.2
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: info at bastian-born dot de Assigned:
Status: Wont fix Package: GNU MP related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: info at bastian-born dot de
New email:
PHP Version: OS:

 

 [2012-06-20 18:16 UTC] info at bastian-born dot de
Description:
------------
For the gmp_random() function you need the number of bits per limb to calculate the correct limiter value (parameter).
This patch will register the constant "GMP_LIMB_BITS".

Test script:
---------------
<?php

echo "Bitcount: " . GMP_LIMB_BITS . "\n";
echo "Random with 128bit length: " . gmp_strval( gmp_random( 128 / GMP_LIMB_BITS ) );

Expected result:
----------------
Bitcount: 64
Random with 128bit length: 100835271651583136351260143038692948194


Patches

201206201530-gmp.c.patch (last revision 2012-06-20 18:17 UTC by info at bastian-born dot de)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-24 20:43 UTC] rainer dot jung at kippdata dot de
Agreed, that patch would be very useful. For example the ext/gmp/tests/gmp_random_seed.phpt test currently fails on Solaris, because it only works when GMP_LIMB_BITS is 64. On Solaris 32 Bits Sparc it is 32 and gmp_random() produces other values.
 [2016-03-26 11:35 UTC] nikic@php.net
-Status: Open +Status: Wont fix
 [2016-03-26 11:35 UTC] nikic@php.net
As PHP 5.6 introduced gmp_random_bits(), which does not depend on the limb size, this should no longer be relevant. (We would be able to introduce this constant only on versions of PHP that already have gmp_random_bits.)
 [2016-03-27 12:55 UTC] info at bastianborn dot de
Nice to see there is a proper function for that now. But the old gmp_random() still exists and can never work properly. Maybe we should mark it as deprecated?
 [2018-07-02 16:06 UTC] nikic@php.net
Just for the record, gmp_random() has indeed been deprecated in PHP 7.2.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC