This preview shows page 1. Sign up to view the full content.
Unformatted text preview: me Use of this site is subject to certain Terms & Conditions, Copyright © 19962000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. To access the contents, click the chapter and section titles. Applied Cryptography, Second Edition: Protocols, Algorthms, and Source Code in C (cloth)
Go!
Keyword
Brief Full Advanced Search Search Tips (Publisher: John Wiley & Sons, Inc.) Author(s): Bruce Schneier ISBN: 0471128457 Publication Date: 01/01/96 Search this book:
Go! Previous Table of Contents Next  Linear congruential generators remain useful for noncryptographic applications, however, such as simulations. They are efficient and show good statistical behavior with respect to most reasonable empirical tests. Considerable information on linear congruential generators and their implementations can be found in [942]. Combining Linear Congruential Generators
Various people examined the combination of linear congruential generators [1595,941]. The results are no more cryptographically secure, but the combinations have longer periods and perform better in some randomness tests. Use this generator for 32bit computers [941]: static long s1 = 1 ; /* A “long” must be 32 bits long. */ static long s2 = 1 ; #define MODMULT(a,b,c,m,s) q = s/a; s = b*(sa*q)  c*q; if (s<0) s+=m ; /* MODMULT(a,b,c,m,s) computes s*b mod m, provided that m=a*b+c and 0 <= c < m. */ /* combinedLCG returns a pseudorandom real value in the range * (0,1). It combines linear congruential generators with * periods of 23185 and 231249, and has a period that is the * product of these two prime numbers. */ double combinedLCG ( void ) { long q ; long z ; MODMULT ( 53668, 40014, 12211, 2147483563L, s1 ) MODMULT ( 52774, 40692, 3791, 2147483399L, s2 ) z = s1  s2 ; if ( z < 1 ) z += 2147483562 ; return z * 4.656613e10 ; } /* In general, call initLCG before using combinedLCG. */ void initLCG ( long InitS1, long InitS2 ) { s1 = InitS1 ; s2 = InitS2 ; } This generator works as long as the machine can represent all integers between231 + 85 and 231  85. The variables, s1 and s2, are global; they hold the current state of the generator. Before the first call, they must be initialized. The variable s1 needs an initial value between 1 and 2147483562; the variable s2 needs an initial value between 1 and 2147483398. The generator has a period...
View
Full
Document
This note was uploaded on 10/18/2010 for the course MATH CS 301 taught by Professor Aliulger during the Fall '10 term at Koç University.
 Fall '10
 ALIULGER
 Cryptography

Click to edit the document details