59.

Learn Encryption Techniques with BASIC and C++
(Publisher: Wordware Publishing, Inc.)
Author(s): Gil Held
ISBN: 1556225989
Publication Date: 10/01/98

Previous Table of Contents Next


Pseudo-random Number Sequences

A pseudo-random number sequence is based on the use of an algorithm to generate a sequence of numbers. Any person who has access to the algorithm can exercise the algorithm and will eventually be able to reproduce the pseudo-random number sequence used by another person. Although this means that the use of pseudo-random number sequences makes an enciphered message decipherable by an unauthorized party, the time and effort required to do so may preclude this from actually happening. Some algorithms may generate millions to tens or hundreds of billions of unique key sequences, forcing those who illicitly obtain access to an enciphered message to use powerful mainframe computers for months or years in an attempt to decipher a message. The selection of an algorithm to generate pseudo-random numbers can provide a very high level of security even though the resulting enciphered message based on the use of that algorithm is breakable. One algorithm which provides a reasonable number of random number sequences is built into the BASIC programming language in the form of the RND function.

The RND Function

The BASIC RND function invokes a routine which generates pseudo-random decimal numbers in the range 0 to 1. In most versions of BASIC, including QuickBASIC, the format of the RND function is RND[(x)], where the value of x determines how the function generates the next random number. Table 6.1 indicates the number returned by the function based upon different argument values.

Table 6.1. Returned RND function number.

Argument Value Number Returned

x<0 Always returns the same number for any given x.
x>0 or x omitted Returns the next random number in the sequence.
x=0 Returns the last number generated.

When using the RND function in a program with a value of x>0, the same sequence of random numbers is generated each time you execute the program. This generation is illustrated in Listing 6.1 in which the top portion lists a simple program which prints five random numbers through the use of the RND function, while the lower portion shows the results obtained by executing the program three times. Note that each sequence of random numbers generated by the program is exactly the same.

Listing 6.1. Using the RND function.

 FOR I = 1 TO 5 PRINT RND(I); NEXT I PRINT .7055475       .533424         .5795186 .2895625 .301948 .7055475       .533424         .5795186 .2895625 .301948 .7055475       .533424         .5795186 .2895625 .301948 


Using random numbers for enciphering and deciphering messages dates to the modern spy. During World War II, Nazi agents, as well as Allied spies working in occupied Europe and in neutral countries, enciphered and deciphered messages based upon the use of what is known as a one-time pad.

Each one-time pad consists of a series of pages with each page containing a sequence of random numbers, usually blocked into groups of five digits for convenience. Each page of random numbers was to be used one time, providing the basis for the name of the pad.

To use this method, a spy first prepares his or her message in plaintext, positioning the characters in the message into groups of five letters. Then, the value of each letter in the group is added (using modulo 26 arithmetic) to the value of each random digit to produce the enciphered message. The following example illustrates the enciphering operation attributed to agent Maxwell Smart.

plaintext message SENDM OREMO NEYNO WXXXX
random digits 15829 31276 50341 92371
modulo 26 addition
enciphered message TJVFV RSGTU SEBRP FZAEY

At the spy’s home base, the received message is decoded through the use of a second one-time pad whose contents match the contents of the pad used by the spy. For example, the received enciphered message would be deciphered as follows:

received message TJVFV RSGTU SEBRP FZAEY
random digits 15829 31276 50341 92371
modulo 26 subtraction SENDM OREMO NEYNO WXXXX

Unless the one-time pad falls into the hands of enemy agents, the resulting enciphered message is unbreakable. This technique is so secure that its use has been documented in many spy trials occurring during the Cold War, although the capture of the spies was attributed to factors other than the ability of counterspies to read enciphered messages.



Previous Table of Contents Next


Learn Encryption Techniques with Basic and C++
Learn Encryption Techniques with BASIC and C++
ISBN: 1556225989
EAN: 2147483647
Year: 2005
Pages: 92
Authors: Gil Held

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net