Title of Invention

METHOD OF GENERATING A STREAM CIPHER USING MULTIPLE KEYS

Abstract A method of generating a stream cipher having length x bytes, the method comprising the steps of: i) selecting a number n representing a number of sub- keys, and n unique prime numbers mn each representing a unique non-repeating sub-key length mn bytes; ii) generating n unique random numbers, each having non-repeating length mn bytes; iii) generating a n+1 st random number R; iv) for each byte whose position in said n random number is p, where p= Modmn(R), consecutively applying a function to each p byte of each of said n random numbers to generate a value; v) incrementing the value of p by 1; and vi) repeating step iv) and v) and concatenating each said value produced in step iv) to the previous value produced in step iv) until said stream cipher of X bytes in length has been produced.
Full Text FORM 2
THE PATENTS ACT, 1970
(39 OF 1970)
COMPLETE SPECIFICATION
(See Section 10)
METHOD OF GENERATING A
STREAM CIPHER USING
MULTIPLE KEYS
(a) BOREN, Stephen Laurence, Canadian National, residing at #209-188 Milross Avenue Vancouver British Columbia V6A 4J4, Canada
(b) BRISSON, Andre Jacques, Canadian National, residing at #701-1736 West, 10th Avenue, Vancouver British Columbia V6J2A6, Canada
The following Specification describes the nature of this invention and the manner in which it is to be performed:-

Original
Granted
13-6-2005


13/6/2005

Method of Generating a Stream Cipher Using Multiple Keys
Cross-Reference to Related Applications
This application is a continuation-in-part of United States patent
Application no. 10/299,847 filed November 20, 2002, which is pending.
Technical Field
The invention relates to the field of encryption methods and more
particularly to a method of generating a stream cipher to encrypt electronic communications which may be extremely long.
Background Art

Various methods of encryption to provide secure electronic communications are well known in the art. In symmetric methods of encryption, the sender and the recipient use the same code or key to encrypt and decrypt the message. The only completely secure cipher
which cannot possibly be broken or deciphered is the One-Time Pad (OTP). A OTP takes a stream of bits that contains the plaintext message, and a secret random bit-stream of the same length as the plaintext (the key). To encrypt the plaintext with the key, each pair of bits from the key and plaintext is sequentially acted on by the exclusive-or function to
obtain the ciphertext bit. The ciphertext cannot be deciphered if the key is truly random and the key is kept secret from an unauthorised party. The


problem with this method is that the key should be at least the same length as the message. If a shorter key is used and repeated then the cipher can be broken. In some cases the data which needs to be encrypted is extremely large.
There is therefore a need for a method of generating a random key, or OTP, which is of variable length and that allows for encryption of very large amounts of data.
Disclosure of Invention
The present invention therefore provides a method of generating a stream cipher having length x bytes, the method comprising the steps of i) selecting a number n of sub-keys each having a unique non-repeating
length mn bytes; ii) generating n random numbers, one for each sub-key, each having length mn bytes; iii) generating a n+lst random number R; iv) set p= Modmn(R); v) for each byte whose position in the nth random number is p applying a function to all n bytes to generate a value; vi) concatenating the value to the end of the stream cipher; vii) set p=p+l;
and viii) repeating step v), vi) and vii) until the stream cipher is x bytes in length. Preferably the selected length m of each sub-key is a prime number. The method may also include the further step of applying a delinearization function to the stream cipher.
According to one aspect of the invention, each of the n random
numbers is generated by: i) generating a n + 2nd random number which is not a perfect square; ii) calculating the square root of the n + 2nd random


number; iii) generating a n + 3rd random number; iv) commencing with a digit whose position in the n + 2nd random number is calculated based on the n + 3rd random number, taking finite strings of digits sequentially and converting each finite string into a byte; v) concatenating each byte sequentially until the selected length mn of said each of the n random numbers has been reached.
The invention further provides a computer program product, an article for carrying out the method, and a data processing system for carrying out the method.
Brief Description of Drawings
In drawings which disclose a preferred embodiment of the invention:
Fig. 1 is a schematic illustration of a computer system for carrying out the method of the invention; and Fig. 2 is a flow chart illustrating the method of the invention.
Best Mode(s) For Carrying Out the Invention
Fig. 2 illustrates by way of a flowchart the method of generating
the encryption key of the present invention. In particular an encryption
key, a non-repeating stream cipher of indefinite length referred to herein


as the Super Key, is formed by combining sub-keys. Any number n of sub keys K1, K2, ..., K can be specified depending on the application. The greater the number of sub-keys, the greater the length of the non¬repeating Super Key. The length of each sub key is a prime number of bytes (preferably with prime numbers larger than 10).
The first step in the process is to determine how large a Super Key, or stream cipher, to deploy. The number n of sub-keys and the non¬repeating length m, of each sub-key, in bytes, are selected. The sub-keys
each have a unique non-repeating length, that is, no two sub-keys are of the same non-repeating length. Preferably the sub-key non-repeating lengths are prime numbers of bytes. Preferably the length of the sub-keys, in bytes, are prime numbers in the range 2, 3, 5, ..., 1021, as there are 172 different prime numbers in this range. The selection may be done
by manually entering the number of sub- keys and their prime number nori-repeating lengths. Alternatively, the number of keys and their prime number non-repeating lengths is programmed into an application, or a program randomly selects the number of sub-keys and their non-repeating length. For n sub-keys K„, the non-repeating length of the Super Key will
be Size (Kj) X Size (K2) X Size (K3) ..:X Size (Kn). For example, assume 10 sub- keys of the following prime number non-repeating lengths are used:
Sub Key 1 = 13 bytes = K,
Sub Key 2- 17 bytes-= K2
Sub Key 3 = 19 bytes= K3-


Sub Key 4 = 23 bytes = K4 Sub Key 5 = 29 bytes = K5 Sub Key 6 = 31 bytes-K6 Sub Key 7 = 37 bytes = K7 Sub Key 8 = 41 bytes = KS Sub Key 9 = 43 bytes = K9 Sub Key 10 = 47 bytes = K10
The resulting non-repeating'Super Key length is 13X 17 X 19 X 23 X 29 X 31 X 37 X 41 X 43 X 47 = 266,186,053,068,611 bytes. Thus, using a small number of sub-keys, each of small prime number non-repeating length results in an extremely long non-repeating Super Key. The total definition for the size of the Super Key above is contained in 300 bytes (the sum of the lengths of the non-repeating sub-keys) and the header (number of sub-keys and their lengths). Thus the total definition for a Super Key will be a fraction of the size of the Super Key.
While preferably the non-repeating length of each sub-key is a prime number of bytes, to improve the randomness of the resulting cipher, the method will also work if non-prime nuniber lengths are used, as long as the resulting cipher is very large.
To select the number of sub-keys, preferably this is calculated by talcing the first two digits generated by a random stream, MODed by 50 and adding 50 to provide a number of keys between 50 and 99.


Each sub-key of the multi-key process may be created as follows First a random number which is not a perfect square is generated, preferably by a highly random source. Preferably it is an integer in the range of 500 to 700 digits. This serves as a "first seed value" O. It is verified that the selected value 0 is not a perfect square. If it is, then additional random values will be generated until one meets this criterion. The second seed value is a 32-bit value that is used to seed the rand function of the computer. Random number generators that are included in the operating systems of most computers are pseudo-random and not very robust. Tliese values, however, are sufficient as a starting point. The second random number P is also generated from the computer's rand function. It is then MODed by 100 to set the starting point. The square root Q of the first seed value O is calculated, resulting in an irrational number Q (one that extends infinitely after the decimal point and is non- repeating). The resultant string of digits after the decimal point is potentially infinite in length and is highly random. The computer discards the digits in front of the decimal and computes the number Q up to P digits after the decimal. Then, starting at the Pth digit of Q after the decimal point, the computer sequentially selects 4 digits at a time, and calculates the Mod 256 value of the 4 digits. This results in an 8-bit value. This value is used as the first byte of the sub-key. This process is repeated 4 digits at a time, continuing with the next digits in sequence, until a string of random data equal to the prime number non-repeating length of the sub-key being created is completed. This process is repeated for all the sub keys until the non-repeating length for all the sub keys are created. Each sub-key then is formed by talcing the non-


repeating string of bytes thus created, and repeating it as often as necessaiy to form a sub-key of sufficient length to create the Super Key in combination with the other sub-keys.
The algorithm for generating the sub-keys can be described as
follows:
1. Treat seed1 as the decimal representation of an integer in the range of 500-700 digits. 2. Let X:= seedl
3. Let Y: = -Jx is the irrational number generated by square rooting X
4. Let Z\, Z2, Z3, Z4,.. be the digits after the decimal point in the decimal
representation of Y. Each Z1 is in the range 0,..,9.
5. Call srand(seed2). // only the first time
6. Call rand() to get the irrational starting point, start.
7. Let start :=rand() mod 100. start is in the range 0,1,..,99.
8. Throw away Zi and Z2 all the way to Zstart.
9. Let tmp := 10*Z(Start+i) + Z(start+2) Throw away those used values.
10. Let n := 50 + (tmp mod 50). n is in the range 50,51,..,99.
' ll.For i:=l,2,..,n,do:
12. Letj = 3*(i-1)
13. Let tmp be the next byte from the Z stream.
14. Let tmp := 100*Zj+I + 10*Zj+2 + Zj+3
15. Let t := 172 - (tmp mod 172). t is in the range 1,2,.., 172. 16. Let u be the tth prime among the sequence 2,3,5,.., 1021'."""""

17. If u is equal to any of I1, l2,.., 1{M}, set t to (t+l)mod 172 goto 16
18. Setlj = u.
19. Next I: goto 11 until all subkey sizes are set.
20.Fori"l,2,..,n, do:
21. Forj:=0,l,2J..,li,do:
22. Let k:=4*j
23. Let tmp be the next byte from the Z stream.
24. Let tmp := (1000*Zk + 100*Zk+1 + 10*Zk+2 + Zk+3) mod 256
25. Let s):-tmp
26. Next j : Next subkey byte


27. Next.I: Next subkey 28.For i:=0,l,2,..,255,do:
29. Let j:=4*i
30. Let tmp := (1000*Zj + 100*Zj+1 + 10*Zj+2 + Zj+3) mod 256
31. If tmp is equal to any of S[0], S[l],.., S[i-1], set to (tmp+l)mod 256 goto 31
32. SetS[i]:=tmp.
33. Next i
34. Let offset := ZjZj+i...Z,-+9
35. Return n, (l1,!2,../), (sl,s2,..,sn), S[256] and offset.
36. Save in keyfile and add seed1 and start value to DB
37. Increment seedl and goto 2 //repeat until enough keys are created
Once all the sub-keys are created as above, the Super Key (cipher)
is created to the length required. This means the Super Key will continue to be created to encrypt the associated data to be encrypted, and continues to be created only until all the data is encrypted. First a random number R ("third seed value", or the starting offset for the Super Key, as opposed
to the starting point P for the number Q) is generated. Starting with any one of the n sub-keys, having length mn, the Modmn of R is calculated and the Modmn(R)th byte of each sub-key is consecutively exclusive-or'd (X/OR'd) with the corresponding Modmn(R)th byte of every other sub-key. For example, if R=100, and the length of the first sub-key is 91
bytes and the second sub-key 43 bytes, then the 3rd byte of sub-key 1 is selected and X|OR'd with the 14th byte of sub-key 2 and corresponding bytes of the other remaining sub-keys selected in the same way based on R. The process is repeated until all the selected bytes from each sub-key have been X/OR'd. The resulting value may then be put through a
substitution cipher or another deimearization function to delinearize the


Super Key stream, as described further below. The resultant binary value is then added to the Super Key by concatenation. The next, subsequent byte of sub-key 1 is then X|OR'd with the next byte of sub-key 2 and so on. Again the process is repeated until all the selected bytes from each sub-key have been X/OR'd and delinearized. The resulting binary value of each function is again added to the Super Key by concatenation. While the XOR function is preferred, it will be apparent that other functions can be applied. For example, mathematical functions of addition or subtraction can be used. As each byte of the Super Key is
generated, the corresponding byte of the plaintext message is then encrypted with the con'esponding byte of the Super Key by the exclusive-or function or some other mathematical function. Once all the bytes of the plaintext message have been encrypted the generation of the Super Key terminates. The encrypted message can then be decrypted applying
the inverse of the encrypting function to it and the Super Key.
To illustrate further the generation of the Super Key from the sub-keys, let sf denote the j-th byte of the i-th "sub key". Let £{l) denote
the length of the i-th sub-key. For example, we might have ix = 13,
17, and so on. Create from the "sub key" i the unending sequence of bytes



Let s j denote the j'-th. byte of the above sequence, if j is any natural number 0 to co; the lowest value of j in the subscript of is Rmodulo
where R is a random number. Then, they'-thbyte of the "Super Key," call it Zj, is defined by

Here, " " denotes the XOR operation. The first byte of the Super Key is:

Where Rmod returns an integer in the range 0,1,2,..., The "SuperKey" has a j value that ranges from 0 to

Let P0,P1,P2,P3,-. be the bytes of the plaintext, and C0,C1,... the bytes of the ciphertext, in order. Also, zo,z1,... denotes the bytes of the "Super Key" (computed as already described above). We define the ciphertext by Ci := P; xor S[z]. The ciphertext C is formed by concatenating the bytes Co,C1,..,and then C is returned as the result of the encryption process. Decryption works in reverse in the obvious manner.


To encrypt an L-byte plaintext, an L-byte Super Key is generated, and a big number counter T is used to count the number of bytes in the plaintext. The output is an L-byte ciphertext. To decrypt the ciphertext, the same big number counter T is used and the output is the L-byte plaintext.
In order to reduce the linearity of the ciphertext using the present method, a further step may be applied to the Super Key before the plaintext message is encrypted. In the preferred embodiment, a substitution cipher is applied to the Super key, and the resultant string is then used to encrypt the plaintext message. For example, an array of 256 unique bytes is created, from 1 to 256 ordered randomly. The first byte in the Super Key then has substituted for it the value of the x+1 st byte in the Super Key, where x is the first value in the 256 byte array. The second byte in the Super Key then has substituted for it the value of the y+2nd byte in the Super Key, where y is the second value in the 256 byte array, and so on. The 256-byte array can be formed from one of the sub-keys, plugging in bytes from a sub-key into the array so long as they don't repeat a previous entry in the array.
The linearity of the cipher text can be reduced also by applying the substitution cipher to the encrypted message (ciphertext) however it is more effective to apply the substitution cipher to the Super Key prior to encrypting. Other utilities besides a substitution cipher can be used to break linearity, such as invertible non-mear function (INLF) utilities


available from SANDIA labs. These are useful to provide protection against the Berlekamp-Massey attack.
While preferably the random non-repeating string which forms each sub-key is generated as described above, the method will also work if the non-repeating string of each sub-key is simply generated by a random number generator to form each sub-key, as long as the overall resultant length of the Super key is sufficiently large so that the resultant Super Key is at least double the size of the data to be encrypted.

The foregoing method can be used to produce a personal security system whereby the key is used to encrypt personal files that the user wishes to secure. In that case no method of distribution of the key will be required. As each file is encrypted a new file named
{OLDFILENAME}.{OFFSET}.wn. The OLDFILENAME includes the extension to allow for easy decryption and maintaining the same file format for functionality. As each file is encrypted, it is immediately decrypted and compared to the original and then both the test copy and the original file are deleted using a clean sweep deletion process (entire
file rewritten as 0's and then 1 's and then deleted).
A preferred key file format is defined as follows:
typedef struct wnkeyfiletype { char field[2]; //must be WN to identify file format
long version; // file type version number to allow changes
BIGNLTMBER offset; // the offset is a large number stored as a
// string of decimal digits delineated by '""s


long numsk; // the number of subkeys long sklen[numsk]; // the individual subkey lengths char skl[sklen[l]]; // the 1st subkey char skl [slden[2]];//the 2nd subkey char skl[sklen[3]];//the 3rd subkey
char sknumsk[sklen[numsk]]; // the numskth subkey
char substit[256]; // the substitution cipher key } WNKEYFILE;
The foregoing key file format is standard. The only different value is the
offset that is stored in a string of decimal digits that are delineated by '"s.
An example of this would be "987654321", this allows for values ranging
up to 1000 digits long which prevents the reuse of sections of the key
stream if the offset is implemented properly.
The present invention is described above as a computer-implemented method, for example to encrypt and decrypt communi¬cations between computers 14 and 16 over network 12. It may also be
embodied as a computer hardware apparatus, computer software code or a combination of same. The invention may' also be embodied as a computer-readable storage medium embodying code for implementing the invention. Such storage medium may be magnetic or optical, hard or floppy disk, CD-ROM, firmware or other storage media. The invention
may also be embodied on a computer readable modulated carrier signal.
As will be apparent to those skilled in the art in the light of the foregoing disclosure, many alterations and modifications are possible in the practice of this invention without departing from the spirit or scope


WHAT IS CLAIMED IS;
1. A method of generating a stream cipher having length x bytes, the
method comprising the steps of:
i) selecting a number n representing a number of sub-
keys, and n unique prime numbers mn each representing a unique non-repeating sub-key length mn bytes;
ii) generating n unique random numbers, each having
non-repeating length mn bytes;
iii) generating a n+1 st random number R;
iv) for each byte whose position in said n random
number is p, where p= Modmn(R), consecutively applying a
function to each p byte of each of said n random numbers to
generate a value;
v) incrementing the value of p by 1; and
vi) repeating step iv) and v) and concatenating each said value produced in step iv) to the previous value produced in step iv) until said stream cipher of X bytes in length has been produced.
2. The method of claim 1 wherein said selected length mn of each said sub-key is a prime number greater than 10.
3. The method of claim 1 wherein said function applied consecutively
to each said p bytes of said n random numbers is the exclusive-or
function, which is applied by obtaining the result of applying the
exclusive-or function initially to the nth and the n+lst pair of p
AMENDED SHEET

bytes where n=l and then consecutively incrementing n by 1 and applying the exclusive-or function to said result and the next pth byte.
The method of claim 1 comprising the further step of applying a delinearization function to said stream cipher.
The method of claim 4 wherein said delinearization function is a substitution cipher.
The method of claim 1 wherein each of said n random numbers are generated by:
i) generating a n + 2nd random number which is not a perfect square;
ii) calculating the square root of said n + 2nd random number;
iii) generating a n + 3rd random number;
iv) commencing with a digit whose position in said n + 2nd random number is calculated based on said n + 3rd random number, taking finite strings of digits sequentially and converting each said finite string into a byte;
v) concatenating each byte sequentially until the selected length mn of said each of said n random numbers has been reached.
The method of claim 6 wherein said finite strings of digits are at least 4 digits long.
AMENDED SHEET


8. The method of claim 7 wherein said finite string is converted into a. byte by applying a mod function.
9. The method of claim 8 wherein said finite string is converted into a byte by applying a mod 256 function.


Date:-13th June 2005

Documents:

606-mumnp-2005-claims(granted)-(13-6-2005).doc

606-mumnp-2005-claims(granted)-(13-6-2005).pdf

606-mumnp-2005-correspondence(4-10-2007).pdf

606-mumnp-2005-correspondence(ipo)-(20-6-2008).pdf

606-mumnp-2005-form 1(13-6-2005).pdf

606-mumnp-2005-form 18(18-11-2005).pdf

606-mumnp-2005-form 2(granted)-(13-6-2005).doc

606-mumnp-2005-form 2(granted)-(13-6-2005).pdf

606-mumnp-2005-form 26(5-5-2005).pdf

606-mumnp-2005-form 3(10-6-2005).pdf

606-mumnp-2005-form 3(25-7-2005).pdf

606-mumnp-2005-form 5(10-6-2005).pdf

606-mumnp-2005-form-pct-isa-210(12-6-2005).pdf

606-mumnp-2005-form-pct-ispea(18-1-2007).pdf


Patent Number 221493
Indian Patent Application Number 606/MUMNP/2005
PG Journal Number 42/2008
Publication Date 17-Oct-2008
Grant Date 24-Jun-2008
Date of Filing 13-Jun-2005
Name of Patentee BOREN,STEPHEN LAURENCE
Applicant Address #209-188 MILROSS AVENUE VANCOUVER BRITISH COLUMBIA V6A 4J4,
Inventors:
# Inventor's Name Inventor's Address
1 BOREN,STEPHEN LAURENCE #209-188 MILROSS AVENUE VANCOUVER BRITISH COLUMBIA V6A 4J4,
2 BRISSON, ANDRE JACQUES # 701-1736 WEST, 10TH AVENUE, VANCOUVER BRITISH COULMBIA V6J2A6,
PCT International Classification Number H04L 9/22
PCT International Application Number PCT/CA2003/001538
PCT International Filing date 2003-10-06
PCT Conventions:
# PCT Application Number Date of Convention Priority Country
1 10/299,847 2002-11-20 Canada