FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to generate cryptographically-secure random big-integers?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
How to generate cryptographically-secure random big-integers? [message #170213] Wed, 20 October 2010 06:57 Go to previous message
seeWebInstead is currently offline  seeWebInstead
Messages: 14
Registered: October 2010
Karma:
Junior Member
I need to generate a random integer uniformly distributed from 0 to
165704257009980305087908956205223296585688096305918417966291411066008093135 190411324365527113804568013399264982255120906812142560021321323875432044092 494966970218269418334085525290028472777766273110227504712320
The following code:
srand(time());
$random = (rand()%9); ...etc...
:is no good because time returns 1287555603 currently, and it would
be relatively easy for somebody who has access to my source code to
try all possible values for the time seed, a 10-digit integer, and
thus crack my cryptosystem. I'm doing personal research to try to
find something that is truly random for two hundred and ten
independently random cryptographically secure digits. My current
idea is to call the microsecond-time function a moderately large
number of times in succession, subtract adacent values (result
usually 4, often 5, rarely any other value), build a Markovian
model for the sequence, and then apply interval refinement directly
to the interval where I want the value until the length of the
interval is small enough to specify a single integer. But before I
go to a lot of effort to develop this idea, maybe one of you has an
idea for some method somebody else already did that I could use
instead?

P.S. Here's a sample run of the microsecond-time differences:
33 6 4 4 4 5 4 4 6 4 4 5 5 5 4 4 5 4 4 4 4 5 4 4 4 4 4 4 5 4 4 4 5 4 5 4 4 4 4 5 4 4 4 5 4 4 6 5 4 4 4 5 4 4 4 4 4 4 4 5 5 4 4 5 5 4 4 5 4 4 4 4 4 5 4 4 4 4 5 4 4 5 5 4 5 3 5 4 4 4 4 5 4 4 4 4 4 4 4 4 5 4 4 4 4 4 4 4 4 5 4 4 4 4 4 4 4 4 4 4 4 5 4 4 4 5 6 4 7 4 4 4 4 5 4 4 4 4 4 4 4 3 5 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 4 4 4 4 5 4 4 4 4 7 5 3 5 4 4 4 4 4 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 4 4 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 14
[4] => 570
[5] => 106
[6] => 4
[7] => 2
[8] => 1
[10] => 1
[33] => 1
)
Unfortunately, adjacent differences are highly correlated, as you
can see by visual examination of the raw differences, so the
null-context tally is not a good model for the data. Only a small
number of sequences of data are likely, hence only a small number
of the values from 0 to the maximum integer would actually be
likely to appear, and somebody could guess them all and thus crack
my cryptosystem. Instead, I'll need to dynamically choose a set of
non-null left-contexts, which is messy to optimize, especially in
real time as I'm bootstrapping a cryptosystem to a remote site, and
then compile a set of tallies for each left context being used, and
then consider each difference in the appropriate left context i.e.
use the appropriate tally for converting that difference into an
interval refinement.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Anyone here follows the mailing list php-general(at)lists(dot)php(dot)net?
Next Topic: Having trouble writing/copying/renaming file to sub-directory
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 09:57:20 GMT 2024

Total time taken to generate the page: 0.04923 seconds