[squeak-dev] Cryptography: Fortuna>>nextInt:

C. David Shaffer cdshaffer at acm.org
Tue Jul 6 16:52:41 UTC 2010


On 07/06/10 12:05, Gary Chambers wrote:
> Having dealt with rather large encryption keys (2048 bit) here's the
> fix we've had for Random>>nextInt:
>
> nextInt: anInteger
> "Answer a random integer in the interval [1, anInteger].
> Handle large numbers too (for cryptography)."
>
> anInteger strictlyPositive ifFalse: [ self error: 'Range must be
> positive' ].
> anInteger asFloat isInfinite
>  ifTrue: [^(self next asFraction * anInteger) truncated + 1].
> ^ (self next * anInteger) truncated + 1
>
> Regards, Gary
>

This looks like a proposed patch to the base image's Random. 
Cryptography doesn't use this random generator.  Maybe this should be
added to the source.squeak.org inbox?

David



More information about the Squeak-dev mailing list