home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!rpi!utcsri!newsflash.concordia.ca!IRO.UMontreal.CA!CC.UMontreal.CA!pigeons
- From: pigeons@JSP.UMontreal.CA (Pigeon Steven)
- Subject: Re: Encryption and Random Numbers
- Message-ID: <1992Nov18.030335.15774@cc.umontreal.ca>
- Sender: news@cc.umontreal.ca (Administration de Cnews)
- Organization: Universite de Montreal
- References: <1992Nov17.211502.18511@lynx.dac.northeastern.edu>
- Date: Wed, 18 Nov 1992 03:03:35 GMT
- Lines: 55
-
- In article <1992Nov17.211502.18511@lynx.dac.northeastern.edu> cschmidt@lynx.dac.northeastern.edu (Christopher Schmidt) writes:
- >Duncan Murdoch's interesting STREAMS package includes some
- >clever encryption logic that uses the TP random number
- >generator. It's a nice technique, except that if Borland
- >modifies the TP random number generator, then you and your
- >customers will be locked out of your encrypted data.
- >
- >What exactly are the chances Borland will modify the TP
- >random number generator? Do you feel lucky?
- >
- >Simple solution: Include your own random number generator in
- >your program. Anybody have such in TP? I notice there is a
- >random number generator in C in the SIMTEL directory
- ><MSDOS.C>, but I have not looked at it yet.
-
- Good solution!... Better yet if you know that a simple random
- generator (such as one found in TP, at least, up to version 6.0)
- is ... simple to program:
-
-
- procedure randomize;
- begin
- RandSeed := timer;
- end;
-
- procedure random(m:word):word;
- begin
- RandSeed:=(RandSeed*C+b) mod (2^32); {keep only the first 32 bits of
- result }
- random:=(RandSeed and $0000ffff) mod m; {keep lower part, and >=0}
- end;
-
-
-
- The big deal about this method, is to find a C that will make
- your random generator look random. An arbitrarly (sp!) large
- relatively prime number C will do, and B can be any odd constant.
- C is relatively prime to 2^32, which does not mean that it is
- prime, only that it has no factor smaller (or equals) to (2^32-1).
-
- (also note that computing (Randseed*C+b) mod (2^32) may cause
- some problems with overflow... Some assembly lang, and it's done!)
-
-
- >
- >Christopher Schmidt
- >Waltham, Massachusetts, USA
- >cschmidt@lynx.northeastern.edu
-
-
- --
- _ ___ __ __ _ | Steven Pigeon
- (_ | (__ \ / (__ |\ | (a.k.a)
- __) | (__ \/ (__ | \| pigeons@JSP.UMONTREAL.CA
- ==Computer Science & Operation Research, Universite de Montreal==
-