Abstract:
A method of generating a substitution box (S-box) involves generating an S-box with desired characteristics, forming a new S-box with another column such that the new S-box has the desired characteristics as well, and continuing to add columns in these ways until the S-box has the proper size.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
     This application claims the benefit of U.S. Provision application Ser. No. 60/021,983, filed Jul. 18, 1996. 
    
    
     BACKGROUND OF THE INVENTION 
     The present invention relates generally to cryptographic methods and systems to be used in digital data processing, and in particular, is directed to methods and systems for constructing large substitution boxes for use in improving the security of symmetric block ciphers. 
     There are two general types of key-based cryptographic algorithms: asymmetric, also known as public-key, and symmetric. Public-key algorithms are designed so that the key used to decrypt the message is different from that used to encrypt the message. The encryption keys may be made public because the decryption key cannot be calculated from the encryption key. By contrast, in symmetric algorithms, the encryption key and decryption keys are either the same or may be calculated from one another. 
     There are two types of symmetric algorithms: stream ciphers and block ciphers. Stream ciphers operate on data one bit at a time while block ciphers operate on blocks of data where each block can be as large as 64 bits or more. The U.S. government standard Data Encryption Standard (DES) is one example of a symmetric block algorithm that encrypts using 64-bit blocks. 
     The security of a cryptosystem depends on its ability to mask the unavoidable redundancies in the underlying plaintext to make it impossible or computationally infeasible for an interloper to recreate it from the ciphertext. Confusion and diffusion are two general methods of obscuring redundancies. Good block ciphers will perform a number of bit-for-bit substitutions to introduce confusion. Diffusion is obtained by transposing, or rearranging the order of, the bits of the plaintext or ciphertext. Block ciphers typically employ successive iterations of both confusion and diffusion. Each iteration, or &#34;round,&#34; contains both substitution and permutation. 
     Many block ciphers are based on Feistel networks because the underlying mathematical principles of Feistel networks guarantee that the cipher will be invertible. Both DES and the Northern Telecom-developed cipher, CAST, are examples of Feistel network-based ciphers. 
     FIGS. 1 and 2 are flow diagrams of the DES enciphering process. As shown in FIG. 1, DES is a typical Feistel network. To start, the algorithm takes a block of 64 bits and, after a permutation, divides the block into two equal-length halves. The cipher then performs a set of iterations where the output of the ith round is determined from the output of the previous round. In particular, 
     
         L.sub.i =R.sub.i-1 
    
     
         R.sub.i =L.sub.i-1 ⊕ƒ(R.sub.i-1,K.sub.i-1) 
    
     In each iteration, one of the halves, in this case the right half R, is input to a round function that also takes as input an internal key, K. In FIG. 1, the round function is indicated by f 1 , f 2 , . . . f n  (in DES, f 1  =f 2  = . . . =f 16 ). 
     FIG. 2 illustrates round function, f. Round function f takes two inputs, the right half R of the block and an internal key K (Step 220). Right half R is expanded to 48 bits (Step 222) and XORed with K (Step 224). The result is divided into 8 parts and each 6-bit section is input to one of eight different substitution boxes, or S-boxes (Step 226). An m×n S-box is simply a mapping of m input bits to n output bits, and may be implemented in hardware or software. In the DES process, each S-box is a nonlinear substitution, mapping 6 input bits into 4 output bits. The eight outputs of the S-boxes are concatenated (Step 228) and then permuted (Step 230). 
     Unauthorized persons will attempt to exploit cryptosystems such as DES using mathematical analytic attacks, such as differential and linear cryptanalysis. Differential cryptanalysis looks at pairs of plaintext blocks and their corresponding ciphertext blocks and constructs a table of possible input versus output differences. The resulting table, called an XOR table, may indicate characteristics that can lead to the key in use. Linear cryptanalysis is a cryptanalytic attack that uses linear approximations to compute the key bits. The attack uses S-box approximations and is very successful against S-boxes that have low nonlinearity. 
     Much of the security of block ciphers based on Feistel networks depends on the properties of the S-boxes used in the round function. Generally, the larger the S-box, the better the security of the block cipher. Although S-boxes may be nonlinear, S-boxes that are not carefully designed to exhibit certain ideal properties may generate a skewed distribution of XOR outputs for given XOR inputs, making them susceptible to differential cryptanalysis. For more information on the relationship between the distribution of output XORs and susceptibility to differential cryptanalysis, see Carlisle M. Adams, &#34;On immunity against Biham and Shamir&#39;s Differential Cryptanalysis,&#34; Information Processing Letters, vol. 41, Feb. 14, 1992, pp. 77-80. 
     Many scientists in the field have studied what theoretical operational properties S-boxes should have in order to be relatively resistant to cryptanalytic attack. Some scientists, for example, have proposed that an ideal S-box would have all entries in the XOR table equal to 0 or 2. See E. Biham and A. Shamir, &#34;Differential Cryptanalysis of DES-like Cryptosystems,&#34; Advances in Cryptology: Proceedings of CRYPTO &#39;90, Springer-Verlag, Berlin, 1991, pp. 1-21. 
     Other scientists have proposed that ideal S-boxes satisfy what is called &#34;strict avalanche criterion&#34; (SAC). See A. F. Webster and S. E. Tavares, &#34;On the Design of S-boxes&#34;, Advances in Cryptology: Proceedings of CRYPTO &#39;85, Springer-Verlag, New York, 1986, pp. 523-34 S-boxes algorithms that satisfy the strict avalanche criterion produce output bits that change with a probability of one half whenever a single input bit is complemented. 
     FIG. 3 shows a sample representation to illustrate the size and format of an S-box as known in the art. An m×n S-box may be represented as a 2 m  ×n binary matrix, M, where each column is a binary vector which corresponds to a Boolean function of the m input variables, and which defines the response of a single output bit to any given input. Row i of M, 1≦i≦2 m  is therefore the n-bit output vector that results from the ith input vector. An S-box with good avalanche properties would be one in which the sum (modulo 2) of any pair of rows in M would be approximately half zeros and half ones. 
     Furthermore, scientists have discovered that if bent function-based columns are used for columns of an S-box, the S-box will behave in an &#34;ideal&#34; fashion with respect to avalanche properties. Any change in the m input bits will cause each of the n output bits to change with probability 1/2. A column of M is considered bent if the normalized resultant vector of a two-dimensional Walsh-Hadamard transform of the binary column has all its coefficients either +1 or -1. The Walsh-Hadamard transform is a binary analog of the Fourier transform. 
     A very large number of known binary vectors may be used to construct the S-box matrix, M. It has been further proposed that if all linear combinations of S-box columns are also bent, the S-box will be more resistant to linear cryptanalytic attacks. See E. Biham, &#34;On Matsui&#39;s Linear Cryptanalysis&#34;, Advances in Cryptology-Proceedings of EUROCRYPT &#39;94, Springer-Verlag, Berlin, 1995, pp. 341-355. 
     In general, an ideal S-box would possess the following properties: 
     I1. All linear combinations of S-box columns are bent; 
     I2. All entries in the S-box XOR table are 0 or 2; 
     I3. The S-box satisfies a maximum order strict avalanche criterion; 
     I4. The S-box satisfies a maximum order bit independence criterion; 
     I5. The weights of rows has a binomial distribution with mean n/2; 
     I6. The weights of all pairs of rows has a binomial distribution with mean n/2; and 
     I7. The columns are each of Hamming weight 2 n-1 . (The Hamming weight is the number of 1s in a binary vector). 
     As mentioned earlier, S-boxes that have property I1 will be more resistant to linear cryptanalysis. S-boxes having property I2 would be protected against differential cryptanalysis. Properties I1, I5, and I7 help to ensure a good static characteristic which means that for any particular input, the output appears to have been randomly generated. Properties I2, I3, I4, and I6 help to ensure a good dynamic characteristic, meaning that as one of the inputs is changed, the change in the resulting output appears random. Not all of these properties, however, can be achieved simultaneously. 
     Although these properties have been studied extensively, relatively little work has been done to determine to what degree these properties are achievable in practice. Block ciphers that currently need large S-boxes often use random S-boxes rather than constructed S-boxes because the methods of construction of S-boxes traditionally have been computationally slow to implement. Furthermore, many scientists in the field believe that it would be difficult to construct S-boxes using specific mathematical techniques that would result in S-boxes that exhibited random-like properties. For this reason, existing systems typically generate random S-boxes and test them for the desired properties. This method is likewise computationally inefficient (particularly for large S-boxes). 
     It is therefore desirable to increase the security of existing ciphers that use S-boxes by constructing S-boxes with ideal characteristics rather than using randomly generated S-boxes. 
     In addition, it is desirable to construct an S-box that is resistant to known cryptanalytic attacks. 
     It is further desirable to provide a method of constructing an S-box with as many as possible of the &#34;ideal&#34; characteristics mentioned above. 
     It is still further desirable to reduce the processing time to construct S-boxes with ideal characteristics. 
     To meet these desires, a method consistent with this invention begins with an S-box smaller than desired but having certain characteristics. That S-box is augmented to form a larger S-box with those same characteristics, and this augmentation repeats until a S-box of the proper size is formed. 
     SUMMARY OF THE INVENTION 
     More specifically, a method consistent with the present invention of generating a substitution box (S-box) capable of receiving m inputs and producing n outputs, where m and n are positive integers greater than 1, comprises the steps of selecting desired operational characteristics for the target S-box and generating a first S-box having m inputs and having k outputs, wherein k is less than n and greater than 1. The method also includes the steps of performing iterations of (a) generating a column of m inputs; (b) determining the operational characteristics of a temporary S-box formed by the first S-box and the column; and (c) modifying the first S-box by appending the column if the temporary S-box possesses the desired operational characteristics. The method continues until the temporary S-box reaches the desired size. 
     According to another aspect of the invention, a method of generating an m×n substitution box (S-box), where m and n are positive integers greater than 1, comprises the steps of selecting a desired level nonlinearity, NL, for the m×n S-box; generating a first S-box having m inputs and k outputs, wherein k is less than n and greater than 1; generating a first column, C 1 , of length m; performing a first operational test using column C 1  ; performing a second operational test using column C 1  ; generating a second column, C 2 , of length m; performing the first operational test using column C 2  ; performing the second operational test using column C 2  ; determining X 1 , the XOR of C 1  and C 2 , if C 1  and C 2  both pass the first operational test and fail the second operational test; performing the first operational test using X 1  ; replacing the kth column of the first S-box with C 1  and appending C 2  to the first S-box as the k+1st column, if X 1  passes the first operational test; incrementing k by 1; and repeating the steps for generating and testing columns until k equals n. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate the invention and together with the description, serve to explain the principles of the invention. 
     FIG. 1 is a flow chart of the known DES encryption process; 
     FIG. 2 is a schematic diagram illustrating in detail a round function of the DES encryption process shown in FIG. 1; 
     FIG. 3 illustrates a format and size of an 8×32 S-box, whose format and size is known in the art. 
     FIGS. 4A-C contain a flow chart of a method of constructing m×n S-boxes; 
     FIG. 5 is a flow chart of an alternative method of constructing m×n S-boxes; 
     FIG. 6 shows a system for carrying out the method consistent with the present invention. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     Reference will now be made in detail to preferred implementations that are consistent with the present invention, an example of which is illustrated in the accompanying drawings. 
     FIGS. 4A through 4C contain a flow chart illustrating a method consistent with the present invention of building an S-box. For the sake of further clarification, reference also will be made specifically to the process of constructing S-boxes with 8 inputs and 32 outputs, that is, where m=8 and n=32. This is the size of the S-boxes used in the current implementation of the CAST cipher described above. 
     A process consistent with the present invention for constructing an S-box with a certain number of inputs and outputs will exhibit certain ideal operational characteristics. One of the ideal characteristics may be, for example, that the Hamming weight of rows and pairs of rows approaches weight n/2. For this reason, optimal ranges for the ideal operational characteristics are chosen. Thus, minimum and maximum values (a and b, respectively) for the Hamming weight of the rows of the desired m×n S-box are chosen (Step 104). The value, a, should be somewhat less than n/2 and the value, b, should be somewhat greater than n/2. Values a and b will be used later in the procedure to determine whether the weights of the rows of the intermediate S-boxes approach the &#34;ideal.&#34; 
     Next, a minimum value for the nonlinearity, NL, of the desired S-box is chosen (Step 106). This value may be any positive number; however, the strength of the algorithm generally will increase with a higher nonlinearity value. A CAST-based cipher using constructed S-boxes with nonlinearity equal to 74 generally will be more secure, that is, more resistant to cryptanalytic attack, than the same cipher using S-boxes with nonlinearity of 72. For example, 8×32 S-boxes with nonlinearity as high as 74 may be constructed using methods consistent with the present invention. 
     In the preferred embodiment, a maximum level of correlation between columns, C, is also chosen for the target S-box (Step 110). Using the method in FIGS. 4A-4C, 8×32 S-boxes with correlation between columns as low as 36 could be constructed. 
     Referring to FIGS. 4A-4C, the next step is to construct an m×k S-box with the same number of inputs but fewer outputs than the target S-box (Step 115). Generally, k must be a positive integer greater than one and less than n. Additionally, in the preferred embodiment k is chosen so that the m×k S-box is computationally easy and quick to generate and to verify. The m×k S-box may be generated using any known method but should have operational properties at least as good as those desired in the target size S-box (Step 115). The m×k S-box, for example, could be generated using a random collection of pre-stored columns. The S-box, however, should have nonlinearity at least equal to the minimum nonlinearity value, NL, and the maximum level of correlation value, C. 
     Once an initial S-box of ideal operational characteristics is generated, the S-box will be enlarged to the desired size by intelligently choosing additional columns that preserve, or at least do not materially deteriorate, the ideal operational characteristics. An S-box with high nonlinearity, low correlation between columns and an ideal XOR table can be modified by adding linear functions to the columns without disturbing these properties. 
     Enlarging the S-box involves an iterative process of generating a column and testing to see whether the new column may be added to the S-box without adversely affecting the operational characteristics. A temporary variable, ncols, is set to k (Step 135). The iterative process begins by generating a candidate column (Step 140). The candidate column may be generated using any known Boolean function; however, certain desirable operation characteristics, such as maximum order strict avalanche criteria (I3, above), will be guaranteed if bent functions are chosen for the Boolean functions. In the preferred embodiment, candidate columns are generated using Method A, which may be defined as follows: 
     Method A 
     Let a, b, c ε B 6  and let A, B, C be their respective Walsh Transforms. If ##EQU1## represents the Walsh transform of a function d:{0, 1} m  →{0, 1}, then d is bent. 
     Next, a temporary S-box is constructed comprising the current S-box and the new column (Step 142). The process then determines whether the addition of the candidate column will adversely or positively affect the operational characteristics of the S-box by testing the temporary S-box for the desired operational characteristics. 
     To do so, the nonlinearity of the temporary S-box is computed (Step 145). Nonlinearity may be computed in any commonly known manner; however, in the embodiment of the present invention, nonlinearity is calculated as follows: ##EQU2## where C is the set of all linear combinations of the columns of S and ##EQU3## The nonlinearity of the S-box is thus the minimum nonlinearity of the set of all combinations of the columns of the temporary S-box. If the nonlinearity of the temporary S-box is less than the threshold minimum the most recently added column is discarded (Step 147), and the process begins another iteration by generating a new column (Step 140). 
     If the nonlinearity of the temporary S-box is within acceptable parameters, the process computes the correlation between the columns of the temporary S-box (Step 155). Correlation between columns may be calculated using any known method, however, in the preferred embodiment of the present invention, correlation is calculated as follows: ##EQU4## M is the binary matrix corresponding to S, and the matrix multiplication is done using modulo 2 addition. 
     If the correlation between columns of the temporary S-box is greater than the minimum correlation, the most recently added column is discarded (Step 157), and the process begins another iteration by generating a new column (Step 140). 
     If a candidate column passes both the nonlinearity and correlation between column tests, the column is kept in the temporary S-box and the number of columns in the temporary S-box is incremented by 1 (Step 165). If the number of columns in the temporary S-box is less than that desired for the target S-box, the process of generating a new column is repeated. (Step 170). 
     Once the temporary S-box reaches the desired size, the process may terminate but other measures may be taken to decrease the exploitability of the S-box by cryptanalytic attack further. A determination is made whether the columns exhibit ideal distribution (Step 175). As mentioned earlier, columns have ideal weight distribution if they have Hamming weight approximately equal to half their length. Columns generated using bent functions, however, will have Hamming weight either equal to 2 n-1  -2 n/2-1  or 2 n-1  +2 n/2-1 . If the columns do not exhibit ideal distribution, complementing all of the bits of a randomly selected column may improve the overall distribution (Step 180). 
     Once the columns of the S-box are evenly distributed, the process tests the distribution of the rows of the S-box. If the Hamming weight of the rows is not between a and b, affine functions are added to selected columns. (Step 187) The nonlinearity and correlation between columns of an S-box is unaffected by the addition of linear functions to the columns; however, the distribution of the rows may be improved by this technique. 
     If the rows of the S-box are within acceptable parameters, the XORs of pairs of rows are also tested in this manner (Step 190). If the Hamming weight of the XORs of pairs of rows are not between a and b, affine functions are again added to selected columns (Step 187). 
     In the process described above, columns are simply discarded if they do not have the desired minimum nonlinearity with respect to any combination of columns already in the S-box. An alternative to this method is the construction method described below and depicted in FIG. 5. 
     In FIG. 5, the construction process begins by generating an S-box having m inputs and k inputs, wherein k is somewhat smaller than n, the number of outputs of the desired S-box (Step 505). The S-box may be generated in any manner, however, as in the first embodiment, the initial S-box should be chosen to exhibit the desired operational characteristics. Temporary variables, ncols and z, are initialized (Step 510). Variable ncols will denote the number of columns in the current S-box. The variable z will indicate the number of candidate columns temporarily set aside. 
     The iterative process begins by generating a candidate column, ƒ z  (Step 515). Column ƒ z  is tested first using Test 1 (Step 525). In the example shown in FIG. 5, Test 1 is performed by computing the minimum nonlinearity of all combinations of k-1 columns of the S-box. Any subset of k-1 columns may be used in Test 1, but for this example and ease of notation, it is assumed that the kth column is the column not used in the calculation. Column ƒ z  &#34;passes&#34; Test 1 if the minimum nonlinearity of all of the combinations exceeds a minimum threshold. For example, if, as in the example described above, the target S-box will have 8 inputs and 32 outputs, the minimum threshold for nonlinearity may be set to 74. 
     If column ƒ z  fails Test 1, the column is discarded and the process generates a new column (Step 515). If column ƒ z  passes Test 1, however, the column is tested using Test 2 (Step 530). In Test 2, the candidate column is tested for nonlinearity with respect to all combinations of columns involving the column not used in Test 1 which, in this example, is column k. Column ƒ z  &#34;passes&#34; Test 2 if the minimum nonlinearity of all of the combinations exceeds a minimum threshold. 
     If column ƒ z  passes Test 2, the column is appended to the S-box, z is set to 1 (Step 562), and variable ncols is incremented by 1 (Step 560). The process determines whether the number of columns in the current S-box is equal to the target size (Step 570). If so, the process ends (Step 575). If not, the iterative process begins again by generating a new column ƒ z  (Step 515). 
     If column ƒ z  fails Test 2, the candidate column is stored rather than discarded (Step 532). A determination is made whether ƒ z  is the first stored column (Step 535). If ƒ z  is the first stored column, variable z is incremented by 1 (Step 540) and the process continues by generating a new column (Step 515). 
     If ƒ z  is the second column to pass Test 1 but fail Test 2, the first and second columns are XORed together (Step 545). The result, ƒ z  ⊕ƒ z-1  is tested for nonlinearity using Test 1 (Step 550). Verifying that ƒ z  ⊕ƒ z-1  passes Test 1 involves only half the computation effort required to verify that a new candidate column passes both Tests 1 and 2 and, therefore, will typically decrease the time required to find columns for large S-boxes. If ƒ z  ⊕ƒ z-1  passes Test 1, ƒ z  replaces the kth column of the current S-box (Step 555). The variable z is reset to 1 (Step 565). The column ƒ z  =ƒ 1 , is appended to the S-box and the number of columns, ncols, is incremented by 1 (Step 570). If ƒ z  ⊕ƒ z-1  fails Test 1, the variable z is reset to 1 (Step 552) and the process generates a new candidate column. 
     This method could also be extended in any one of several different ways. For example, the process could save three or more columns that pass Test 1 but fail Test 2. Also, the process may be modified so that any two or more of the Test 2 failures may be XOR&#39;d together to produce a new candidate column. 
     FIG. 6 illustrates a system consistent with the present invention. As shown in FIG. 6, the present invention uses a processor 610 connected to one or more input/output (I/O) devices (615 and 620) via data links 602 and 604. In general, I/O devices 615 and 620 can be any devices that are capable of passing information to or receiving data from processor 610. By way of example only, I/O devices 615 and 620 may be monitors, keyboards, modems, printers, display devices or workstations. Each workstation can be a personal computer (PC) or other hardware that includes a visual display device and data entry device such as a keyboard or mouse. It should further be understood that FIG. 6 describes an exemplary network where each of the hardware components may be implemented by conventional, commercially available computer systems. 
     It will be apparent to those skilled in the art that various modifications and variations can be made in the methods and systems of the present invention without departing from the spirit or scope of the invention. For example, in addition to the tests for nonlinearity and correlation between columns disclosed other tests may be performed that are functionally equivalent. The true scope of the claims is defined by the following claims.