Constructing Symmetric Ciphers Using The CAST Design Procedure
Constructing Symmetric Ciphers Using The CAST Design Procedure
Constructing Symmetric Ciphers Using The CAST Design Procedure
CARLISLE M. ADAMS Entrust Technologies, P.O. Box 3511 Station C, Ottawa, Canada, K1Y 4H7 cadams@entrust.com Keywords: Design of Encryption Algorithms, Block Ciphers, Substitution Boxes, Key Scheduling, Differential Cryptanalysis, Linear Cryptanalysis Abstract. This paper describes the CAST design procedure for constructing a family of DES-like Substitution-Permutation Network (SPN) cryptosystems which appear to have good resistance to differential cryptanalysis, linear cryptanalysis, and related-key cryptanalysis, along with a number of other desirable cryptographic properties. Details of the design choices in the procedure are given, including those regarding the component substitution boxes (s-boxes), the overall framework, the key schedule, and the round function. An example CAST cipher, an output of this design procedure, is presented as an aid to understanding the concepts and to encourage detailed analysis by the cryptologic community.
1. Introduction and Motivation This paper describes the CAST design procedure for a family of encryption algorithms. The ciphers produced, known as CAST ciphers, appear to have good resistance to differential cryptanalysis [8], linear cryptanalysis [33], and related-key cryptanalysis [9]. Furthermore, they can be shown to possess a number of desirable cryptographic properties such as avalanche [18, 19], Strict Avalanche Criterion (SAC) [54], Bit Independence Criterion (BIC) [54], and an absence of weak and semi-weak keys [25, 12, 40]. CAST ciphers are based on the well-understood and extensively-analyzed framework of the Feistel cipher [18, 19] the framework used in DES but with a number of improvements (compared to DES) in both the round function and the key schedule which provide good cryptographic properties in fewer rounds than DES. These ciphers therefore have very good encryption / decryption performance (comparing very favourably with many alternatives of similar cryptographic strength) and can be designed with parameters which make them particularly suitable for software implementations on 32-bit machines. The search for a general-purpose design procedure for symmetric encryption algorithms is motivated by a number of factors, including the following. Despite years of speculation and warning regarding the inevitable limit to the useful lifetime of the Data Encryption Standard (as originally defined in [41]), this algorithm remains firmly entrenched in a number of environments partly because there is no obvious candidate for a DES replacement with acceptable speed and security. New and powerful cryptanalytic attacks have forced re-designs of suggested candidates such as FEAL [38, 39, 8], LOKI [10, 8, 11], and IDEA [29, 30]. Thus, such attacks
must be accounted for and avoided in the design procedure itself, so that algorithms produced by the procedure are known to be immune to these attacks. The continued disparity between domestic-strength cryptography and exportablestrength cryptography, along with the potential for multiple flavours of exportablestrength cryptography (perhaps depending on commercial escrow considerations), means that the paradigm of a single DES replacement algorithm almost certainly has to be abandoned in favour of a design procedure describing a family of algorithms where keysize is at least one parameter defining a specific instance of the family. Recent cipher proposals such as SAFER [32], Blowfish [49], and RC5 [48] have recognized and addressed this requirement. 1.1. Background Some aspects of the CAST design procedure were discussed in [1, 5-7]. Analysis of CAST-like ciphers containing purely randomly-generated s-boxes with respect to both linear and differential cryptanalysis was presented in [24, 31]. As well, cryptanalysis of a 6-round CAST cipher was described in [47]; this statistical attack requires a work factor of roughly 248 operations and requires 82 known plaintexts. 1.2. Outline of the Paper The remainder of the paper is organized as follows. Section 2 presents an overview of the CAST design procedure, with subsections covering substitution box design, Feisteltype Substitution-Permutation Network (SPN) considerations, the importance of key scheduling, and possibilities for the round function. Section 3 presents a deeper treatment of the design procedure, giving further details, along with assertions and theorems, regarding these four main aspects of CAST cipher design. The fourth section covers design alternatives available for both the SPN framework and the implementation of the round function. Section 5, along with Appendix A, gives the specification for an example CAST cipher, one produced using the design procedure described in this paper. Finally, Section 6 closes the paper with some concluding comments. 2. Overview of the CAST Design Procedure This section gives a brief overview of the concepts and considerations relevant to the CAST design procedure. The four main aspects of a CAST cipher (s-boxes, framework, key schedule, and round function) are covered separately.
2.1. S-Box Design Overview An mn substitution box is a 2mn lookup table, mapping m input bits to n output bits. It substitutes, or replaces, the input with the output such that any change to the input vector results in a random-looking change to the output vector which is returned. The substitution layer in an SPN cipher is of critical importance to security since it is the primary source of nonlinearity in the algorithm (note that the permutation layer is a linear mapping from input to output). The dimensions m and n can be of any size; however, the larger the dimension m, the (exponentially) larger the lookup table. For this reason m is typically chosen to be less than 10. The CAST design procedure makes use of substitution boxes which have fewer input bits than output bits (e.g., 832); this is the opposite of DES and many other ciphers which use s-boxes with more input bits than output bits (e.g., 64)1. Research into cipher design and analysis suggests that s-boxes with specific properties are of great importance in avoiding certain classes of cryptanalytic attacks such as differential and linear cryptanalysis. However, it can be very difficult (and, in some cases, impossible) to satisfy some of these properties using small s-boxes. The CAST design procedure therefore incorporates a construction algorithm for large (e.g., 832) s-boxes which possess several important cryptographic properties. 2.2. Framework Design Overview Ciphers designed around a new basis for cryptographic security (most notably RC5 [48], based upon the conjectured security of data-dependent rotation operations) may prove to be extremely attractive candidates for DES replacement algorithms, but are not yet mature enough to be recommended for widespread use. The CAST procedure is instead based upon a framework which has been extensively analyzed by the cryptologic community for well over 20 years. The CAST framework is the Substitution-Permutation Network (SPN) concept as originally put forward by Shannon [51]. SPNs are schemes which alternate layers of bit substitutions with layers of bit permutations, where the number of layers has a direct impact on the security of the cipher. Furthermore, CAST uses the Feistel structure [18, 19]
that the use of 832 s-boxes was first suggested by Ralph Merkle for the hash function Snefru [36] and for the block ciphers Khufu and Khafre [37].
1Note
to implement the SPN. This is because the Feistel structure is well-studied and appears to be free of basic structural weaknesses, whereas some other forms of the SPN, such as the tree structure [22, 23] have some inherent weaknesses [22, 45] unless a significant number of layers are added (which may destroy the one property, completeness2, which tree structures are provably able to achieve). Note that some other forms of SPN, such as that employed in SAFER [32], also appear currently to be free of basic structural weaknesses, but have not been subject to intense analysis for nearly as long as the Feistel structure. The following diagram illustrates a general Feistel-structured SPN. Basic operation is as follows. A message block of 2n bits is input and split into a left half L1 and a right half R1. The right half and a subkey K1 are input to a round function, f1, the output of which is used to modify (through XOR addition) the left half. Swapping the left and right halves completes round one. This process continues for as many rounds as are defined for the cipher. After the final round (which does not contain a swap in order to simplify implementation of the decryption process), the left and right halves are concatenated to form the ciphertext.
plaintext L1 + L2 + L3 R1
f1
R2
f2
R3
Ln + L n+1
Rn
fn
Rn+1
2Completeness
states that output bit j can be changed by inverting only input bit i in some input vector, for
all i, j [26].
The parameters which can be selected for the framework are the blocksizes (the number of bits in both the plaintext and ciphertext data blocks) and the number of rounds. For all cases higher typically means greater security but (particularly for the number of rounds) reduced encryption / decryption speed. Except for the use of randomized encryption, the plaintext and ciphertext blocksizes are chosen to be equal so that the encryption process results in no data expansion (an important consideration in many applications). As is evident in the work by Biham [8] and by Knudsen [27], good s-box design is not sufficient to guarantee good SPN cryptosystems (both results show that finding 64 sboxes resistant to differential cryptanalysis in isolation that is, with relatively flat Output XOR distributions and putting them directly in DES makes the improved algorithm much more susceptible to differential cryptanalysis than the original). It is therefore of great importance to design the substitution-permutation network such that it takes advantage of the good properties of the s-boxes without introducing any cryptographic weaknesses. 2.3. Key Schedule Design Overview Keying in the CAST design procedure is done in the manner typical for Feistel networks. That is, an input key (a primary key) is used to create a number of subkeys according to a specified key scheduling algorithm; the subkey for a given round is input to the round function for use in modifying the input data for that round. The design of a good key schedule is a crucial aspect of cipher design. A key schedule should possess a number of properties, including some guarantee of key/ciphertext Strict Avalanche Criterion3 and Bit Independence Criterion4 in order to avoid certain key clustering5 attacks [17, 23, 53]. Furthermore, it should ensure that the primary key bits
Strict Avalanche Criterion (SAC) states that s-box output bit j should change with probability 1/2 when any single input bit i is inverted, for all i, j (note that for a given i and j the probability is computed over the set of all pairs of input vectors which differ only in bit i) [53, 54].
4The
3The
(output) Bit Independence Criterion (BIC) states that s-box output bits j and k should change independently when any single input bit i is inverted, for all i, j, k (note that for a given i, j, and k the independence is computed over the set of all pairs of input vectors which differ only in bit i) [53, 54].
keys which are close to each other in Hamming distance result in ciphertexts which are likely also to be close in Hamming distance, then it may be possible to find a key faster than exhaustive search in a known
5If
used in round i to create subkey i are different from those used in round i+1 to create subkey i+1 (this is due to the work of Grossman and Tuckerman [20], who showed that DES-like cryptosystems without a key that varies through successive rounds can be broken). Finally, all key bits should be used by round N/2 (in an N-round cipher) and then reused in the remaining rounds (to ensure good key avalanche for both encryption and decryption). The critical difference between the key schedule proposed in the CAST design procedure and other schedules described in the open literature is the dependence upon substitution boxes for the creation of the subkeys. Other key schedules (the one in DES, for example) typically use a complex bit-selection algorithm to select bits of the primary key for the subkey for round i. As is clear from the work by Knudsen [28] and by Biham [9], any weaknesses in this bit selection algorithm can lead to simple cryptanalysis of the cipher, regardless of the number of rounds. The schedule proposed in CAST instead uses a very simple bit-selection algorithm and a set of key schedule s-boxes to create the subkey for each round. These s-boxes must possess specific properties to ensure cryptographically good key schedules (see Section 3.3 below). 2.4. Round Function Design Overview The round function in CAST, as stated above, makes use of s-boxes which have fewer input bits than output bits. This is accomplished as follows. Within the round function the input data half is modified by the subkey for that round and is split into several pieces. Each piece is input to a separate substitution box; the s-box outputs are combined using XOR or other binary operations; and the result is the output of the round function. Although each mn s-box on its own necessarily causes data expansion (since m<n), using the set of s-boxes in this way results in no expansion of the message half, allowing the SPN to have input and output blocksizes which are equal. 2.4.1. Avoiding Certain Attacks Another aspect of round function design involves a specific proposal to guard against differential and linear attacks. Differential [8] and linear [33] cryptanalysis are generalpurpose attacks which may be applied to a variety of substitution-permutation network (DES-like) ciphers. Both methods work on the principle of finding high-probability attacks
plaintext attack by searching for the correct key cluster and then searching for the correct key within that cluster.
on a single round and then building up characteristics (sets of consecutive rounds which interact in useful ways); characteristics which include a sufficient number of rounds can lead to cryptanalysis of the cipher. The probability of a characteristic is equal to the product of the probabilities of the included rounds6; this characteristic probability determines the work factor7 of the attack. If the work factor of the attack is less than the work factor for exhaustive search of the key space, the cipher is theoretically broken. Resistance to these attacks can be achieved either by adding rounds (which reduces the speed of the cipher) or by improving the properties of the round s-boxes (which may or may not make the round probability low enough to avoid the need to add rounds in a given cipher). The latter approach has been pursued by a number of researchers (see [4, 5, 16, 43, 50, 52], for example). The approach proposed in the CAST design procedure presented below includes both of the above. More importantly, however, it also includes a slight alteration to the typical DES-like round function which renders it intrinsically immune (as opposed to computationally immune) to differential and linear cryptanalysis as described in [8, 33]. Such an alteration is generally applicable to all DES-like ciphers and may, in some ciphers, be added with little degradation in encryption / decryption speed. 3. Detailed Design This section covers the four main aspects of a CAST cipher (s-boxes, framework, key schedule, and round function) in more detail than the previous section and provides a number of assertions, theorems, and remarks regarding the cryptographic properties relevant to each aspect.
6Assuming independent round keys (a reasonable assumption (i.e., a good approximation) for most known ciphers).
number of operations required for the attack, which may or may not be directly related to the number of chosen plaintexts required.
7The
3.1. Detailed S-Box Design For the design of mn (m < n) s-boxes8, let n be an integer multiple of m (where 2n is the blocksize of the cipher); in particular, let n=rm where r is an integer greater than 1 (note that then m log2C(n,n/2) = log2(n choose n/2)). Such s-boxes can be constructed as follows. Choose n distinct binary bent (see, for example, [42, 46, 3]) vectors fi of length 2m such that linear combinations of these vectors sum (modulo 2) to highly nonlinear, nearSAC-fulfilling vectors (Nyberg's work [43] shows that these linear combinations cannot all be bent since m<2n; however, it is important that they be highly nonlinear and close to SAC-fulfilling so as to satisfy the Output Bit Independence Criterion and aid in resistance to linear cryptanalysis). Furthermore, choose half the fi to be of weight (2m-1 + 2(m/2)-1) and the other half to be of weight (2m-1 2(m/2)-1); these are the two weights possible for binary bent vectors of length 2m. Set the n vectors fi to be the columns of the matrix M representing the s-box. Note that each new s-box should be generated from an independent pool of bent vectors to ensure that columns in different s-boxes are distinct and not linearly related. Check that M has 2m distinct rows and that the Hamming weight of each row and the Hamming distance between pairs of rows is close to n/2 (i.e., that the set of weights and the set of distances each have a mean of n/2 and some suitably small but nonzero variance)9. If these conditions are not satisfied, continue choosing suitable bent vectors (i.e., candidate fi) and checking the resulting matrix until the conditions are satisfied. Note that it is possible to construct 832 s-boxes which meet these conditions within a few weeks of running time on common computing platforms. The following assertions and theorems apply to substitution boxes constructed according to the above procedure. Assertion 1: S-boxes constructed as described above have good confusion, diffusion, and avalanche.
8An mn s-box is represented as a 2mn binary matrix M where each of the n columns is a 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 2m, is therefore the n-bit output vector which results from the ith input vector. 9Note
that this is impossible if m n but is quite feasible if n = rm, since then 2m C(n,n/2).
Discussion: It is not difficult to see that the given requirements on the s-box rows and columns lead to good s-box confusion and diffusion properties (as described by Shannon [51]) and also ensure good avalanche (as discussed in [18, 19] and echoed in [26]). Theorem 1: Using bent binary vectors as the columns of the 2mn matrix which describes an s-box ensures that the s-box will respond ideally in the sense of highest-order strict avalanche criterion [2, 4]10 to arbitrary changes in the input vector. Proof: Highest-order SAC is guaranteed for each output bit this is a property of bent Boolean functions which was proven in [34]. By definition [54], an s-box satisfies the highest-order SAC if and only if each of its output bits satisfies the highest-order SAC. o Assertion 2: If the columns in the s-box matrix are bent vectors whose linear combinations are highly nonlinearly related and near SAC-fulfilling, then the s-box will show close proximity to highest-order (output) bit independence criterion. That is, small changes in the m input bits will cause each of the n output bits to change virtually independently of all other output bits. Furthermore, such s-boxes aid in immunity to linear cryptanalysis [33]. Discussion: It can be shown that if columns fj and fk sum modulo 2 to a linear vector, then s-box output bits j and k will either always change together or never change together when any input bit i is inverted (i.e., they will have a correlation coefficient of 1). At the other extreme, if fj and fk sum to a bent vector, then j and k will change independently for any input change. Because it is impossible for all column sums to be bent (since m<2n), the CAST design procedure uses s-boxes in which the column sums are highly nonlinear and near SAC-fulfilling but not necessarily bent. Proximity to BIC is defined in terms of proximity to SAC: if columns fj and fk sum to a vector which comes close to satisfying the SAC (i.e., over all single-bit input changes, the output changes with probability g, where (0.5-w) g (0.5+w) and w is small), then output bits j and k will act virtually independently (i.e., will have a correlation coefficient which is nonzero, but small, as determined by w), for all single-bit input changes. In highest-order BIC the sums of all column subsets are considered (not just pairs). Requiring that these sums are near-SACfulfilling means (by definition) that the s-box will have close proximity to highest-order BIC11. Such s-boxes aid in immunity to linear cryptanalysis because there is no linear
10This 11Note
that highest-order BIC itself (i.e., total independence of output bits over the full set of input changes) cannot be achieved except in Nyberg's "perfect nonlinear" 2nn s-boxes [43], where all column sums are bent.
combination of component functions which has a small Hamming distance to an affine Boolean function (see the discussion in Section 8.1 of [50]). Lemma 1: mn s-boxes designed according to the above procedure can be made to have a largest value, L, in the difference distribution table such that 2 L 2m/2. Proof: Let a CAST s-box be constructed by beginning with Nyberg's perfect nonlinear mm/2 s-box and adding binary bent vectors as matrix columns until the full 2mn matrix M is complete (adhering to the design constraints given above). Without loss of generality, assume that the first m/2 columns of M correspond to a perfect nonlinear s-box (i.e., these columns are bent and all nonzero linear combinations of these columns (modulo 2) are also bent). Consider the 2m-1n matrix M' of avalanche vectors12 corresponding to a given change in the s-box input (see [4, 54] for details). In this matrix all columns are of Hamming weight 2m-2 (since the columns of M are bent) and all nonzero linear combinations of the first m/2 columns are also of Hamming weight 2m-2. It is not difficult to see that within the first m/2 columns of M', therefore, each m/2-bit row will occur exactly T = 2m-1/2m/2 times, so that regardless of the remaining columns of M', each full nbit row can occur a maximum of T times. Thus, the largest value in the difference distribution table for this s-box is L 2T = 2m/2. Clearly, each additional column in M' (beyond the m/2 initial columns) has the ability to reduce T; in the limit (when n is sufficiently large compared with m), every row of M' is unique, so that T=1. Therefore L2. o Remark 1: Although starting with a perfect s-box provides a guaranteed upper bound on L, in practice the same result can be achieved without the perfect s-box if n is sufficiently large. For example, it is not difficult to construct 832 s-boxes with L=2 which do not have four component columns which form a perfect s-box. This is why the use of a perfect s-box has not been made a stipulation of the s-box design procedure given above. 3.2. Detailed Framework Design As was stated previously, the primary parameter options in framework design are blocksize and number of rounds. Aside from the constraint that the blocksize be large
c = c1c2...cm be a fixed m-bit vector of nonzero Hamming weight and let f(x) = f(x1x2...xm) be a Boolean function of m input variables. Divide the 2m possible inputs of f into 2m-1 pairs x and (xc) and sort the pairs into increasing values of x. Label the ith pair [x, (xc)]i. Then the 2m-1-bit vector v is called the avalanche vector of f with respect to c if the ith bit of v = g([x, (xc)]i) = f(x) f(xc) for i = 0...2m-1-1.
12Let
10
enough to preclude birthday-attack-derived analysis of the plaintext data, the only real blocksize consideration is ease of implementation. On current machines and for many typical environments, 64 bits (the blocksize of DES) is an attractive choice because left and right data halves and other variables fit nicely into 32-bit registers. However, in the future a larger choice may be warranted for environments wherein significantly more than 232 data blocks (i.e., 233 or more) may be encrypted using a single key. The number of rounds in the framework appears to be a much more important and delicate decision. There need to be enough rounds to provide the desired level of security, but not so many that the cipher is unacceptably slow for its intended applications. In an SPN of the Feistel type it is clear that the left half of the input data is modified by the output of the round function in rounds 1, 3, 5, 7, and so on, and the right half is modified in rounds 2, 4, 6, 8, and so on. Thus, it is clear that for equal treatment of both halves the number of rounds must be even. However, it is less obvious how many rounds is enough. Differential and linear cryptanalysis, the two most powerful attacks currently known for DES-like ciphers, have helped to quantify this design parameter. It has long been known, for example, that DES with 5 or 6 rounds can be broken, but not until 1990, with the introduction of differential cryptanalysis [8], was it clear why 16 rounds were actually used in its design fewer rounds could not withstand a differential attack [13]. With subsequent improvements to the differential attack [8] and with the introduction of linear cryptanalysis, it now appears that 18-20 rounds would be necessary for DES to be theoretically as strong as its keysize. A prudent design guideline, therefore, is to select a number of rounds which has an acceptably high work factor for both differential and linear cryptanalysis and then either add a few more rounds or modify the round function to make these attacks even more difficult (in order to add a safety margin). As will be seen in Section 3.4, the CAST design procedure chooses the second approach for both security and performance reasons.
Theorem 2:
With respect to differential cryptanalysis, N-round ciphers designed according to the CAST procedure can be constructed with N-2 round characteristics which have probability significantly smaller than the inverse of the size of the keyspace.
11
Proof: Recall from Lemma 1 that the largest value in the difference distribution table of CAST-designed mn s-boxes is L, where 2 L 2m/2. Select for the round function only s-boxes for which L=2. Therefore the highest probability in each table is P = L/2m 21-m. Consider now the f function of this SPN. If a multi-bit change is made to the vector V which is input to f (so that a change is made to the input of each of x of the component sboxes used for f), then the characteristic [30] of f (that is, the most successful differential cryptanalytic attack for that single round) has probability at most Pf = 2x(1-m)+y (because the s-box outputs are combined (e.g., using XOR) rather than simply concatenated (as in DES)). Note that the y in the exponent accounts for the possibility that there may be as many as 2y sets of the r component s-box output XORs which combine to produce a desired output XOR of f; randomness arguments suggest that y is expected to be less than 4. Given Pf, the strategy for differential cryptanalysis in this cipher must be to change the inputs of the smallest number of s-boxes possible in f in each round. Let DV be an input XOR for f for which the corresponding output XOR is zero. To ensure that such a DV must involve 3 or more s-boxes, the following condition is stipulated: for all pairs of s-boxes in the round function, ensure that Si(a) Sj(b) Si(c) Sj(d) except when a=c and b=d (in which case, of course, they must be equal). The probability of the characteristic for a single round could therefore be as high as Pf = 23(1-m)+y. Hence, assuming an N-2 round characteristic (for an N-round cipher), the probability of the characteristic could be as high as Pf(N-2)/2 = 2(3(1-m)+y)(N-2)/2, since DV is only used on every other round and an input XOR of zero is used otherwise13. For parameters m=8, and N=12, and with a conservative estimate of y=5, the characteristic probability is 2-80. This value can be decreased dramatically, if desired, by doing extra checking during the s-box construction / selection process to ensure that y < 5, or that DV o must involve all 4 s-boxes. Remark 2: It has been shown [30, 44] that immunity against differential attacks can only be proven through the use of differentials, not characteristics. However, since the probability of an r-round differential with input difference A and output difference B is the sum of the probabilities of all r-round characteristics with input difference A and output difference B [44], it would be necessary that there exist significantly more than 216 such maximum-probability characteristics in order for a differential to exist which would
it is recognized that multiplying the Pf values in an iterated cipher with additive keys (with respect to differential attacks where the difference is addition) is only strictly correct if the round keys are independent and uniformly random, this product appears to be a good approximation of the characteristic probability for most known ciphers.
13Although
12
threaten a cipher with a 64-bit blocksize. We therefore conjecture immunity to differential cryptanalysis for CAST-designed ciphers with this blocksize. Theorem 3: With respect to linear cryptanalysis, N-round ciphers designed according to the CAST procedure can be constructed with linear relations requiring a number of known plaintexts approximately equal to the total number of possible plaintexts. Proof: The relationship in a CAST cipher between the minimum nonlinearity of the mn substitution boxes in the round function (Nmin), the number of rounds in the overall cipher (N), and the number of known plaintexts required for the recovery of a single key bit with 97.7% confidence (NL) has been given by Heys and Tavares [24]: NL 22 4 N 2m 1 N min 2m
4N
1 = 4 m 1 1 N min 2
4N
This relationship was derived by substituting a (the number of s-box linear approximations involved in the overall linear approximation) into the piling-up lemma of [33] to get 1 1 2 1 pL 2 1 p NL = pL and noting that for 97.7% confidence in the 2 2 2 suggested key. The value a was estimated at 2N, assuming 4 s-boxes per CAST round function (thus 4 s-boxes involved in the best 2-round approximation), and N/2 iterations of 1 the best 2-round approximation. Finally, p depends on the nonlinearity of the 2 1 2 m 1 Nmin component s-boxes: p = . 2m 2 Substituting Nmin = 74 and N = 12 results in NL being lower-bounded14 by approximately 262 (which appears to be adequate security for a 64-bit blocksize since there are only 264 possible plaintexts and since it is not currently known how tight this lower bound is for CAST-designed ciphers). As another example, for a cipher with a 96-bit blocksize, a may be estimated at 3N (that is, the cipher may be constructed with 6 s-boxes per round); thus, 6N 1 296.6 . o for the same Nmin and N, NL 4 Nmin 2m 1 1 It should be noted that 832 s-boxes with minimum nonlinearity Nmin = 74 have been constructed using the CAST procedure; more rounds, higher nonlinearity s-boxes, or
14Like differential cryptanalysis, formal results in this area require round keys which are independent and uniformly random. However, most equations derived using this assumption appear to be good approximations for most known ciphers.
13
additional operations in the round function (see Section 3.4) should all permit CAST ciphers with longer keys to be used with sufficient resistance to linear cryptanalysis. Remark 3: Like the situation in differential cryptanalysis with characteristics and differentials, immunity to linear cryptanalysis can only be proved using total linear relations, not linear relations (as used in the theorem above). However, a number of factors suggest that CAST ciphers are immune to this attack. Firstly, the lower bound for linear relations appears to be acceptably high and is not known to be tight. Secondly, the structure of the CAST round function (e.g., the XOR sum of a number of s-boxes) is such that any subset of output bits must involve data bits and key bits from each component sbox (thus, finding useful multi-round linear relations appears to be more difficult for CAST than for DES). Finally, the goal of linear cryptanalysis is to derive, with reasonable probability, the XOR sum of a subset of subkey bits. In DES and some other ciphers, these subkey bits correspond directly to bits of the primary key and so exhaustive search on primary key bits not deduced by the attack recovers the entire key. In CAST, however, the subkey bits do not correspond directly to primary key bits (see Section 3.3 below or the example key schedule in Appendix A) and so it is not clear that knowing a subset of these bits will aid in any significant way in recovering the primary key. 3.3. Detailed Key Schedule Design As indicated in Section 2.3 above, the key schedule used in the CAST design procedure has three main components: a relatively simple bit-selection algorithm mapping primary key bits to partial key bits; one or more key transformation steps; and a set of key schedule s-boxes which are used to create subkeys from partial keys in each round. A simple key schedule for an 8-round algorithm employing a 64-bit key is as follows (this schedule is for illustrative purposes, using a relatively small number of rounds and little complexity in order to show how an absence of inverseSR keys can be proven; in practice, a more involved schedule (with more entropy per subkey [47]) would be used see Appendix A, which provides a schedule for a 16-round algorithm with a 128-bit key). Let KEY = k1k2k3k4k5k6k7k8, where ki is the ith byte of the primary key. The partial keys K'i are selected from the primary key according to the following bit-selection algorithm: K'1=k1k2, K'2=k3k4, K'3=k5k6, K'4=k7k8, K'5=k4'k3', K'6=k2'k1', K'7=k8'k7', K'8=k6'k5', where KEY is transformed to KEY' = k1'k2'k3'k4'k5'k6'k7'k8' between round 4 and round 5. The key transformation step is defined by:
14
k1'k2'k3'k4' = k1k2k3k4 S1[k5] S2[k7]; k5'k6'k7'k8' = k5k6k7k8 S1[k2'] S2[k4']. The bytes of KEY' are used to construct the final four partial keys, as shown above. The set of partial keys is used to construct the subkeys Ki using key schedule s-boxes S1 and S2: Ki = S1(K'i,1) S2(K'i,2) where K'i,j denotes the jth byte of K'i. Although a similar schedule can be constructed for a more involved 12- or 16-round system or for different block or key sizes, for simplicity of notation and concreteness of explanation, the theorem and remarks below apply to the specific example given here. 3.3.1. Definitions Related to Key Scheduling In a block cipher, an inverse key I for a given encryption key K is defined to be a key such that ENCI(p) = ENCK-1(p) = DECK(p) for any plaintext vector p. Furthermore, a fixed point of a key K is a plaintext vector x such that ENCK(x) = x and an anti-fixed point of a key K is a plaintext vector x such that ENCK(x) is the complement of x. From work done on cycling properties and key scheduling in DES [12, 14, 25, 40], the following definitions have been introduced. A key is weak if it is its own inverse (such keys generate a palindromic set of subkeys15 and have 232 fixed points in DES). A key is semi-weak if it is not weak but its inverse is easily found there are two subclasses: a key is semi-weak, anti-palindromic if its complement is its inverse (such keys generate an antipalindromic set of subkeys16 and have 232 anti-fixed points in DES); a key is semi-weak, non-anti-palindromic if its inverse is also semi-weak, non-anti-palindromic (such keys generate a set of subkeys with the property that Ki KN+1-i = V, where N is the number of rounds and V = 00001111 or 11110000 in DES). DES has 4 weak keys, 4 semiweak anti-palindromic keys, and 8 semi-weak non-anti-palindromic keys. Let H and K be keys which generate sets of subkeys Hi and Ki, i = 1, ..., N, respectively, for an N-round DES-like (Feistel-type SPN) cipher. We define H to be a subkey reflection inverse key of K (denoted inverseSR) if Ki = HN+1-i, i = 1, ..., N. It is clear that a subkey
palindromic set of subkeys is one with the property that Ki KN+1-i = 0, where N is the number of rounds in the cipher and 0 is the all-zero vector.
15A 16An
anti-palindromic set of subkeys is one with the property that Ki KN+1-i = 1, where N is the number of rounds in the cipher and 1 is the all-one vector.
15
reflection inverse key of K is an inverse key of K; whether the converse always holds true for DES-like ciphers is an open question. Thus, for a given key K, {H} {I}. In DES the semi-weak key pairs are subkey reflection inverses of each other and the weak keys are subkey reflection inverses of themselves. 3.3.2. Key Schedule Theorem and Remarks Theorem 4: Ciphers using the key schedule proposed in Section 3.3 can be shown to have no inverseSR key H{0,1}64 for any key K{0,1}64. Proof: There are two steps to this proof. Let S1[k2'] S2[k4'] be equal to the 4-byte vector a1a2a3a4 and let S1[k5] S2[k7] be equal to the 4-byte vector b1b2b3b4. In the first (general) step, we prove that for the transformation given in the key schedule of Section 3.3, if inverseSR keys exist for the cipher then a1=a2, a3=a4, b1=b2, and b3=b4 all simultaneously hold. The second step, which is specific to each implementation of the CAST design, is to examine the specific s-boxes chosen in the implementation to verify that the equalities do not hold simultaneously (note that s-boxes satisfying this condition do exist). Step 1: Theorem: For the transformation given in the key schedule of Section 3.3, if inverseSR keys exist for the cipher then the subkeys Ki = HN+1-i (by definition) and the partial keys K'i = H'N+1-i (by construction of the key schedule s-boxes; see Section 3.1). Therefore, a1=a2, a3=a4, b1=b2, and b3=b4 all simultaneously hold, where ai and bi are defined as above. Proof: Let H and K be cipher keys whose respective key schedules are given by Section 3.3. If H is the inverseSR of K then h1=k6', h2=k5', h3=k8', h4=k7', h5=k2', h6=k1', h7=k4', h8=k3', and h1'=k6, h2'=k5, h3'=k8, h4'=k7, h5'=k2, h6'=k1, h7'=k4, h8'=k3. Substituting these equalities into the key schedule transformation step gives: h1'h2'h3'h4' = h1h2h3h4 S1[h5] S2[h7] or k6k5k8k7 = k6'k5'k8'k7' S1[k2'] S2[k4'] = k6'k5'k8'k7' k5k6k7k8 k5'k6'k7'k8' h5'h6'h7'h8' = h5h6h7h8 S1[h2'] S2[h4'] or k2k1k4k3 = k2'k1'k4'k3' S1[k5] S2[k7] = k2'k1'k4'k3' k1k2k3k4 k1'k2'k3'k4'
16
Therefore, k6 = k6' k5 k5' = k6' a1, whence a1=a2. Similarly, the remaining substitutions yield a3=a4, b1=b2, and b3=b4. Note that these must hold simultaneously o since the equalities given for the hi and ki necessarily hold simultaneously. Step 2: For any specific implementation of the CAST design, the key schedule s-boxes (S 1 and S2) can be examined to determine whether a1=a2, a3=a4, b1=b2, and b3=b4 hold simultaneously. If these do not hold simultaneously then the cipher has been shown to have no inverseSR key H for any given key K (otherwise a new S1 and S2 can be chosen and Step 2 can be repeated). o
Although the proof above applies to an 8-round implementation of a CAST cipher, the result can be extended to higher numbers of rounds. This may be done by modifying the proof itself (using essentially the same format and procedure, but with notation based on the new key schedule), or simply by using the eight subkeys above as the first four and last four subkeys in an N-round cipher (N > 8). This latter approach works because if the cipher has inverseSR keys, then certain equalities must hold between the first four and last four subkeys. Verifying that the equalities do not hold for these eight subkeys, then, ensures that the N-round cipher has no inverseSR keys. Assertion 3: Ciphers using the key schedule proposed in this paper are immune to relatedkey cryptanalysis as described in [9]. Discussion: There are no related keys [27, 9] in the key schedule described in Section 3.3 (i.e., the derivation algorithm of a subkey from previous subkeys is not the same in all rounds because of the construction procedure and the transformation step), and so ciphers using this key schedule are not vulnerable to the chosen-key-chosen-plaintext, chosenkey-known-plaintext, or chosen-plaintext-unknown-related-keys attacks as described in [9]. Remark 4: From Theorem 4 above, this key schedule avoids all inverseSR keys. It is therefore guaranteed to avoid the fixed points associated with weak and semi-weak keys in DES (since using this key schedule in DES would guarantee the non-existence of weak and semi-weak keys). From all evidence available thus far in the open literature, fixed points have only been easily17 found in DES-like ciphers for weak and semi-weak keys; we
17Requiring
a level of effort for an n-bit block cipher of roughly 2n/2 operations rather than 2n operations.
17
therefore conjecture that ciphers using the key schedule proposed in Section 3.3 have no easily-found fixed points for any key. Remark 5: The CAST procedure has no known complementation properties (unlike DES, for example) and so CAST-designed ciphers appear not to be vulnerable to reduced key searches based on this type of weakness. Theorem 4 and the above remarks regarding the key schedule are due to the fact that sboxes are employed in the schedule itself (i.e., in the generation of the subkeys), rather than simply in the use of the subkeys. To the author's knowledge, this is a novel proposal in key scheduling which appears to have some interesting properties. 3.4. Detailed Round Function Design The round function given in Section 2.4 for a CAST cipher with a 64-bit blocksize and 832 s-boxes can be illustrated as follows. A 32-bit data half is input to the function along with a subkey Ki. These two quantities are combined using operation a and the 32-bit result is split into four 8-bit pieces. Each piece is input to a different 832 s-box (S1, ..., S4). S-boxes S1 and S2 are combined using operation b; the result is combined with S3 using operation c; this second result is combined with S4 using operation d. The final 32-bit result is the output of the round function.
18
Ki
S-box 1
S-box 2
b
32
S-box 3
c
32
S-box 4
d
32
A simple way to complete the definition of the CAST round function is to specify that all operations (a, b, c, and d) are XOR additions of 32-bit quantities, although other more complex operations may be used instead (for example, see the discussion in the following subsection regarding the first operation a). Assertion 4: The CAST round function exhibits good confusion, diffusion, and avalanche. Discussion: It is not difficult to see that the round function possesses these properties due to the fact that the component s-boxes possess these properties (Assertion 1). Remark 6: Although confusion, diffusion, and avalanche are somewhat vague terms and cannot be proven formally, they can be argued on an intuitive level for the CAST s-boxes and round function. Note that a round function which achieves all three properties simultaneously should lead to a faster buildup of complexity and data / key interdependency in a Feistel network than a round function which does not. This appears to be the case for CAST ciphers, which show very good statistical properties after only 2-3 rounds whereas DES, for example, requires 5-6 rounds to display similar properties 18.
that in the DES round function a single bit change in the input can change a maximum of 8 of the 32 output bits. It therefore does not satisfy the avalanche property.
18Note
19
Theorem 5: For appropriate design choices, the CAST round function is guaranteed to exhibit highest-order SAC for both plaintext and key changes. Proof: Given that each s-box satisfies the avalanche property and guarantees highest-order SAC19 (see Section 3.1), any change to the input of s-box Si causes approximately half its output bits to change. If operations b, c, and d in the round function f are XOR addition (see above), then approximately half the bits in the modified message half will be inverted. Let V be the vector of changes to the output of Si when its input is changed. Then V = (v1, v2, ..., vn), where vi is a random binary variable with Prob(vi=0) = Prob(vi=1) = 1/2. Similarly, let W = (w1, w2, ..., wn) be the vector of changes to s-box Sj when its input is changed. Clearly, if Z = V W, then Prob(zi=0) = Prob(vi=wi) = 1/2 if vi and wi are independent (that is, have a correlation coefficient of zero over all possible inputs). This is guaranteed for Si and Sj if columns fi and fj in the corresponding s-box matrices sum (modulo 2) to a bent vector. This means that if changes are made to both Si and Sj, it is still the case that the outputs of f will change with probability 1/2. This argument generalizes to any number of the s-boxes (once the corresponding output bits are independent), which proves that any change to the input of f changes each bit in the output of f with probability 1/2 over all inputs. The limit to the number of mn s-boxes with independent corresponding output bits is a direct result of Nyberg's perfect s-box theorem: it is m/2. Therefore, if t m/2 (where t is the number of s-boxes used for the data half in f), the simplest way to achieve the independence is to choose the corresponding columns in the sbox matrices such that they are the columns of an mm/2 perfect s-box. Note that key/ciphertext highest-order SAC imposes no requirement beyond that needed for o plaintext/ciphertext highest-order SAC because of the definition of f. In practice, close proximity to highest-order SAC appears to be readily achieved for the CAST round function without the requirement that operations b, c, and d be XOR addition and even without the requirement that perfect s-boxes be used as the columns for corresponding output bits. Assertion 5: For appropriate design choices, the CAST round function exhibits close proximity to highest-order BIC for both plaintext and key changes. Discussion: A similar argument to the one above can be used to show that close proximity to highest-order BIC can be achieved for both plaintext and key changes when operations b, c, and d are XOR addition. Again, however, in practice it appears that this property is Remark 7:
that the avalanche property relates to any specific input change; the SAC, on the other hand, is an average calculated over the full input space.
19Note
20
readily achieved for the CAST round function whether or not XOR addition is used as the binary operation. Remark 8: Although this seems to be difficult to prove theoretically, the above properties of the round function (confusion, diffusion, avalanche, highest-order SAC, and highestorder BIC) lend evidence to the conjecture that an N-round CAST cipher employing such a round function will behave as a random permutation for arbitrary input bit changes. 3.4.1. Operation a and Intrinsic Immunity to Attacks As discussed previously, the number of rounds and the properties of the round function s-boxes can be chosen to provide computational immunity to differential and linear cryptanalysis. We now discuss the proposal that extra work in the round function specifically, some care in the choice of operation a can conceivably give intrinsic immunity to these attacks (in that the attacks as described in [8, 33] can no longer be mounted); see also Section 4.2. 3.4.1.1. Differential and Linear Cryptanalysis Differential and linear cryptanalysis (chosen- and known-plaintext attacks, respectively) are similar in flavour in that both rely on s-box properties to formulate an attack on a single s-box. Each then generalizes this to attack the round function and extends the round function attack to create a number of characteristics for the overall cipher. The most successful characteristic (that is, the one with highest probability) theoretically breaks the cipher if its work factor is less than the work factor for exhaustive search of the key space (even if the attack requires an impractical amount of chosen or known plaintext). In terms of notation, for the DES round function let R be the data input, K be the subkey, E() be the expansion step, S() be the s-box step, P() be the permutation step, and R' be the function output. Furthermore, let X = E(R) K and Y = S(X), so that R' = P(Y). Finally, let L be the left half of the data which is not input to the round function. In differential cryptanalysis the s-box property which is exploited is its input XOR to output XOR mapping, where a specific DX leads to a specific DY with high probability. Due to the linearity in the E() and P() operations with respect to XOR, DX = X1 X2 = E(R1) K E(R2) K = E(R1) E(R2) = E(DR) during two encryptions with the same key, and DR' = P(Y1) P(Y2) = P(DY). Thus DR pairs can be found which result in useful DR' pairs, where a DR' pair is useful in this context if it can act as a desired DR
21
pair in the following round, so that round function attacks can be iterated and concatenated into characteristics with high overall probability. In linear cryptanalysis the s-box property which is exploited is linearity. Let S() be the XOR sum of a specific subset of the bits in the argument and let Sp() be the XOR sum of the permuted indices of the subset of bits used in S() with respect to the permutation P(). Then S(Y) = S(X) with high probability. Again due to linearity, S(Y) = S(E(R) K) = S(E(R)) S(K), and so S(K) = S(E(R)) S(Y). Since knowing R immediately yields S(E(R)) and knowing R' immediately yields Sp(R') = Sp(P(Y)) = S(Y), various R can be found which result in useful R', where an R' is useful in this context if it can be XORed with a desired S(L) from the previous round to yield a desired S(R) for the following round, so that round function attacks can be iterated and concatenated into characteristics with high overall probability. 3.4.1.2. Modification of Operation a The goal behind modifying the round function is to eliminate the possibility of both differential and linear cryptanalytic attacks (as described in [8, 33]) against the cipher. This is done by inserting a nonlinear, key-dependent operation before the s-box lookup to effectively mask the inputs to the set of s-boxes. If these inputs are well hidden, then sbox properties (such as the input XOR to output XOR mapping, or linearity) cannot be exploited in a general round function attack because the actual inputs to the s-boxes will not be known. More specifically, the following modification to the round function f is proposed: f(R, K) = f(R, K1, K2) = S(a(R K1, K2)) where a(, ) is an operation with properties as defined below. For DES, the expansion operation can be placed either around R or around (R K1) that is, f(R, K) = S(a(E(R) K1, K2)) or f(R, K) = S(a(E(R K1), K2)) depending on whether K1 is 32 or 48 bits in length. As well, the permutation operation can be placed around S() as is done in the current round definition. Several properties are required of the function a(, ). These will be discussed below, but they are enumerated here for reference. (1) The subset sum operation must not be distributive over a(, ). (2) a(, ) must represent a nonlinear mapping from its input to its output, so that any linear change in either input leads to a nonlinear change in the output vector.
22
(3) a(, ) must effectively hide its R (or E(R)) input if K1 and K2 are unknown (in the sense that there must be no way to cancel the effect of the keys in the round function using an operation on a single R value or a pair of R values). (4) a(, ) must be relatively simple to implement in software (in terms of code size and complexity). (5) a(, ) must execute efficiently (no more slowly than the remainder of the round function, for example). A function which appears to encompass all the properties listed above is modular multiplication, for an appropriate choice of modulus. If R, K1, and K2 are 32 bits in length, two candidate moduli20 are (232 - 1) and (232 + 1). Meijer [35] describes a simple algorithm to carry out multiplication modulo (232 - 1) in a high-level language using only 32-bit registers, and has shown that multiplication with this modulus is a complete operation (in that every input bit has the potential to modify every output bit [26]), so that this modulus appears to satisfy nonlinearity, simplicity, and data hiding. However, this modulus does not satisfy the third property ideally, since zero always maps to zero, and (232 - 1) always maps to either (232 - 1) or zero (depending on the implementation), regardless of the key in use. (Note, however, that in a practical implementation it is a simple matter to ensure that the computed subkey K2 is never equal to 0 or to (232 - 1), and masking R with K1 ensures that it is not easy for the cryptanalyst to choose R such that (R K1) is equal to 0 or to (232 - 1).) The modulus (232 + 1) may be a better choice with respect to property three than (232 1) if either of two simple manipulations are performed. Firstly, each input can be incremented by one, so that the computation is actually done with (R+1) and (K+1). Thus the arguments belong to the set [1, 232] rather than [0, 232 - 1], avoiding both the zero and the (232 + 1) fixed point inputs. Alternatively, the inputs can be left as is (so that the computation is done with R and K), with the zero input mapped to the value 232 (and the 232 output mapped back to zero). Implementation of multiplication using this modulus is thus only slightly more difficult using a high-level language with 32-bit registers than for the modulus (232 - 1), and on platforms where the assembly language instructions give access to the full 64-bit result of a 32-bit multiply operation, the modular reduction can be accomplished quite simply and efficiently. Furthermore, as for (232 - 1), multiplication with this modulus represents a nonlinear mapping from input to output.
that multiplication modulo 232-1 was first used in a cryptographic setting by Donald Davies in MAA [15] and that multiplication modulo 216+1 was first used in IDEA [29].
20Note
23
In order to ensure that the modular multiplication does not perform badly with respect to property three, it is necessary that the subkey K2 be relatively prime to the modulus. Thus, when the subkeys are being generated, the K2 used in each round must not have 3, 5, 17, 257, or 65537 as factors if the modulus n = (232 - 1), and must not have 641 or 6700417 as factors if n = (232 + 1). Finally, it appears that either modulus can be used to satisfy property one, since the subset sum operation is not distributive over modular multiplication. 3.4.1.3. Making the Round Function Intrinsically Immune to Differential Cryptanalysis Property three listed above prevents a differential attack as described by Biham and Shamir, and property two prevents a simple modification to their description. Recall the equation given in Section 3.4.1.1: DX = X1 X2 = E(R1) K E(R2) K = E(R1) E(R2) = E(DR) during two encryptions with the same key. This is the critical component of the differential attack because it shows that the XOR sum of two data inputs (R1 and R2) completely determines the input XOR for the round s-boxes. This is why this attack would ideally be mounted using chosen plaintext (so that the cryptanalyst can select the input XORs which will construct the highest-probability characteristic). Property three prevents such an attack with the requirement that no operation on a pair of R values can cancel the effect of the key. Modular multiplication appears to achieve property three in the modified equation DX = X1 X2 = a(R1 K1, K2) a(R2 K1, K2) = (((R1 K1) * K2) mod n) (((R2 K1) * K2) mod n) since knowledge of R1 and R2 does not seem to reveal DX if K1 and K2 are not known. Thus, the input XOR to output XOR mapping of the round s-boxes cannot be exploited through knowledge/choice of R1 and R2. Modular multiplication also appears to satisfy property two because it is not obvious that any simple modification to the differential attack will cause knowledge of R1 and R2 to reveal information about DX if K1 and K2 are not known. This is not true of arbitrary operations which may be proposed for a(, ). For example, if a(, ) is real addition (modulo n), then re-defining DX to be subtraction (modulo n) yields DX = (X1 - X2) mod n
24
= (a(R1 K1, K2) - a(R2 K1, K2)) mod n = ( (((R1 K1) + K2) mod n) - (((R2 K1) + K2) mod n) ) mod n = ( (R1 K1) - (R2 K1) ) mod n In such a situation the difference between R1 and R2 (XOR or real subtraction) reveals a significant amount of information about DX which may be used in subsequent rounds to construct a characteristic. 3.4.1.4. Making the Round Function Intrinsically Immune to Linear Cryptanalysis Property one given above prevents a linear attack as described by Matsui. Recall the equation given in Section 3.4.1.1: S(Y) = S(X) = S(E(R) K) = S(E(R)) S(K) Therefore, S(K) = S(E(R)) S(Y) This is the critical component of the linear attack because the distributive nature of the subset sum operation S() over the XOR operation may allow the equivalent of one key bit to be computed21 using only knowledge of S(E(R)) and S(Y). This is why this attack would typically be mounted using known plaintext (so that the cryptanalyst can use knowledge of S(plaintext) and S(ciphertext) to work through intermediate rounds to solve for various key bits). Property one prevents such an attack by the requirement that S() not be distributive over a(, ). Modular multiplication appears to achieve this requirement22, as seen in the modified equation S(Y) = S(X) = S( ((R K1) * K2) mod n ) since it appears that this equation cannot be rearranged in any way to solve for subset sums of K1 and K2 given only subset sums of R and Y. (Note that either E(R) or E(R K1) may be substituted in the above equation, if required.)
that if two linear approximations exist involving the same bits and with the same bias, but with opposite sign, no information can be found on the single key bit. The reason this attack works on DES is that one approximation has a higher probability than the others in the DES round function. This situation may or may not exist in other round functions, including the one proposed for CAST ciphers.
22Note that Harpes, et al, have found that ciphers using modular addition or multiplication (with large moduli) to insert the key into the round function tend to be immune not only to Matsuis linear cryptanalysis, but also to their generalization of linear cryptanalysis using I/O sums [21].
21Note
25
3.4.1.5. Implementing Operation a in a CAST Cipher A CAST cipher implemented with a blocksize and keysize of 64 bits, four 832 s-boxes S1...S4 in the round function, and 32-bit subkeys in each round, appears to require more chosen/known plaintexts for differential and linear attacks than exist for that blocksize if 12 or more rounds are used. If operations a, b, c, and d are all XOR addition, the round function f may be computed simply as: f(R, K) = S1(B(1)) ... S4(B(4)) where B = R K and B(j) is the jth byte of B. Application of the technique described in this section yields the modified computation of operation a, where f remains identical but B is now computed as B = ((R K1) * K2) mod n. Examination of the assembly language instructions required for the modular multiplication step alone (using either (232 - 1) or (232 + 1) as the modulus) shows that multiplication takes approximately the same amount of time as the remainder of the round on a Pentium-class PC, so that there is a performance impact of about a factor of two, compared with a version of CAST where operation a is simple XOR addition. 4. Alternative Operations and Design Choices A number of options are available both for the round function operations and for the framework design which do not appear to compromise security and do not degrade encryption / decryption performance of the resulting cipher. In fact, for some choices it appears that security or performance may be enhanced, thus motivating the use of these alternatives in practice and encouraging further research into a proof of security for each alternative. If such proofs become available, the corresponding options will be formally incorporated into the CAST design procedure. Note that all alternatives have been included in the example cipher given in Section 5, primarily to stimulate analysis of these options in the context of a real cipher, but also because the author believes these to be good design choices. 4.1. Binary Operations in the Round Function Throughout this paper the operations b, c, and d in the round function (as well as at least part of operation a) have been specified as the XOR of two binary quantities. It
26
should be clear, however, that other binary operations may be used instead. Particularly attractive are addition and subtraction modulo 232, since these operations take no more time than XOR and so will not degrade encryption / decryption performance in any way. Experimental evidence suggests that using such alternative operations may significantly increase security against linear cryptanalysis [56], but this is yet to be proven formally. 4.2. Extension to Operation a Discussed in Section 3.4.1 was the proposal to add extra computation (using extra key bits) to the operation a in the round function. The specific computation suggested was multiplication with another 32-bit subkey using a modulus of either (232 - 1) or (232 + 1). However, it was noted that this suggestion can degrade performance by as much as a factor of two. An alternative operation which appears to be quite attractive is rotation (i.e., circular shifting) by a given number of bits. This operation is similar to the central operation of the cipher RC5 [48], except that here we suggest a key-dependent rotation (controlled by a 5-bit subkey) rather than a data-dependent rotation, since data-dependent rotation appears to be less appropriate for a Feistel-type structure. The extended a operation for a CAST cipher with a 64-bit blocksize is then a(R, K) = a(R, K1, K2) = ((R K1) <<< K2), where is any binary operation (such as XOR or addition modulo 232), <<< is the circular left shift operator, K1 is a 32-bit subkey, and K2 is a 5-bit subkey. The primary advantage of the rotation operation over modular multiplication is speed: on typical computing platforms the n-bit rotation (0 n 31) specified by K2 can be accomplished in a small number of clock cycles, thus causing very minor performance degradation in the overall cipher. Rotation satisfies property (1) from Section 3.4.1.2 because it prevents a linear attack as described by Matsui for all cases except the extreme case where the input subset considered consists of the full set of input bits. It is highly unlikely that this extreme case applied in every round of an N-round cipher will describe a successful linear characteristic for the cipher. 4.3. Non-Uniformity within the Round Function The discussion thus far implies that the binary operation in b, c, and d (and at least part of a) must be the same in all four instances (e.g., XOR). However, there is no reason that this needs to be the case. For example, it would be perfectly acceptable for b and d to use
27
addition modulo 232 while c uses XOR (this is precisely the combination used in the Blowfish cipher [49]). Certainly many variations are possible, and while it is not clear that any one variation is significantly better than any other, it does appear to be the case that the use of different operations within a, b, c, and d can add to the security of the overall cipher (note that the IDEA cipher has long advanced the conviction that operations over different groups contribute to cipher security [29, 30]). 4.4. Non-Uniformity From Round to Round Another design option is to vary the definition of the round function itself from round to round. Thus, in an N-round cipher there may be as many as N distinct rounds, or there may be a smaller number of distinct rounds with each type of round being used a certain number of times. The variations in the round definitions may be due to the kinds of options mentioned in the previous subsection or may be more complex in nature. Whether the idea of a number of distinct rounds [55] in a cipher adds in any significant way to its cryptographic security is an open question. However, there is no evidence thus far that variations resulting from mixed operations (as suggested in Section 4.3) can in any way weaken the cipher and lead to its cryptanalysis. 5. An Example CAST Cipher In order to facilitate detailed analysis of the CAST design procedure, and as an aid to understanding the procedure itself, an example CAST cipher (an output of the design procedure described in this paper) is provided in this section (with further details given in Appendices A, B, and C). This 16-round cipher has a blocksize of 64 bits and a keysize of 128 bits; it uses rotation in operation a to provide intrinsic immunity to linear and differential attacks; it uses a mixture of XOR, addition and subtraction (modulo 232) in the operations a, b, c, and d in the round function; and it uses three variations of the round function itself throughout the cipher. Finally, the 832 s-boxes used in the round function each have a minimum nonlinearity of 74 and a maximum entry of 2 in the difference distribution table. This example cipher appears to have cryptographic strength in accordance with its keysize (128 bits) and has very good encryption / decryption performance: 3.3 MBytes/sec on a 150 MHz Pentium processor.
28
In order to simplify future reference (i.e., to disambiguate this example from any other CAST-designed cipher discussed elsewhere), this example cipher will be referred to as CAST-128. 5.1. Pairs of Round Keys CAST-128 uses a pair of subkeys per round; a 32-bit quantity Km is used as a masking key and a 5-bit quantity Kr is used as a rotation key. 5.2. Non-Identical Rounds Three different round functions are used in CAST-128. The rounds are as follows (where D is the data input to the f function and Ia Id are the most significant byte through least significant byte of I, respectively). Note that + and - are addition and subtraction modulo 232, ^ is bitwise XOR, and <<< is the circular left-shift operation.
Type 1: I = ((Kmi + D) <<< Kri) f = ((S1[Ia] ^ S2[Ib]) - S3[Ic]) + S4[Id] I = ((Kmi ^ D) <<< Kri) f = ((S1[Ia] - S2[Ib]) + S3[Ic]) ^ S4[Id] I = ((Kmi - D) <<< Kri) f = ((S1[Ia] + S2[Ib]) ^ S3[Ic]) - S4[Id]
Type 2:
Type 3:
Rounds 1, 4, 7, 10, 13, and 16 use f function Type 1. Rounds 2, 5, 8, 11, and 14 use f function Type 2. Rounds 3, 6, 9, 12, and 15 use f function Type 3. 5.3. Key Schedule Let the 128-bit key be x0x1x2x3x4x5x6x7x8x9xAxBxCxDxExF, where x0 represents the most significant byte and xF represents the least significant byte. See Appendix A for a detailed description of how to generate Kmi and Kri from this key. 5.4. Substitution Boxes CAST-128 uses eight substitution boxes: s-boxes S1, S2, S3, and S4 are round function s-boxes; S5, S6, S7, and S8 are key schedule s-boxes. Although 8 s-boxes require a total of
29
8 KBytes of storage, note that only 4 KBytes are required during actual encryption/decryption since subkey generation is typically done prior to any data input. See Appendix B for the contents of s-boxes S1 - S8. 6. Conclusions The CAST design procedure can be used to produce a family of encryption algorithms which appear to have good resistance to differential cryptanalysis, linear cryptanalysis, and related-key cryptanalysis, as described in the literature. CAST ciphers also possess a number of other desirable cryptographic properties and have good encryption / decryption speed on common computing platforms. Analysis of the procedure described in this paper by members of the cryptologic community is strongly encouraged so as to increase confidence in the various aspects of the design presented.
7. References
[1] [2] C. M. Adams, A Formal and Practical Design Procedure for Substitution-Permutation Network Cryptosystems, Ph.D. Thesis, Department of Electrical Engineering, Queen's University, 1990. C. M. Adams and S. E. Tavares, The Use of Bent Sequences to Achieve Higher-Order Strict Avalanche Criterion in S-Box Design, Technical Report TR 90-013, Dept. of Elec. Eng., Queen's University, Kingston, Ontario, Canada, Jan., 1990. C. M. Adams and S. E. Tavares, Generating and Counting Binary Bent Sequences, IEEE Transactions on Information Theory, vol. IT-36, 1990, pp.1170-1173. C. M. Adams, On Immunity against Biham and Shamir's Differential Cryptanalysis, Information Processing Letters, vol.41, Feb.14, 1992, pp.77-80. C. M. Adams and S. E. Tavares, Designing S-Boxes for Ciphers Resistant to Differential Cryptanalysis, Proceedings of the 3rd Symposium on the State and Progress of Research in Cryptography, Rome, Italy, Feb., 1993, pp.181-190. C. M. Adams, Simple and Effective Key Scheduling for Symmetric Ciphers, in Workshop Record of the Workshop on Selected Areas in Cryptography (SAC 94), May 5-6, 1994, pp.129-133. C. M. Adams, Designing DES-Like Ciphers with Guaranteed Resistance to Differential and Linear Attacks, in the Workshop Record of the Workshop on Selected Areas in Cryptography (SAC 95), May 18-19, 1995, pp.133-144. E. Biham and A. Shamir, Differential Cryptanalysis of the Data Encryption Standard, SpringerVerlag, 1993. E. Biham, New Types of Cryptanalytic Attacks Using Related Keys, in Advances in Cryptology: Proc. of Eurocrypt '93, Springer-Verlag, 1994, pp.398-409. L. Brown, J. Pieprzyk, and J. Seberry, LOKI A Cryptographic Primitive for Authentication and Secrecy Applications, Advances in Cryptology: Proc. of Auscrypt 90, 1990, pp.229-236. L. Brown, M. Kwan, J. Pieprzyk, and J. Seberry, Improving Resistance to Differential Cryptanalysis and the Redesign of LOKI, Advances in Cryptology: Proc. of Asiacrypt 91.
[6] [7]
30
[32]
[33]
D. Coppersmith, The Real Reason for Rivest's Phenomenon, in Adv. in Cryptology: Proc. of Crypto '85, Springer-Verlag, New York, 1986, pp.535-536. D. Coppersmith, The Data Encryption Standard (DES) and its Strength Against Attacks, IBM Journal of Research and Development, vol.38, #3, May 1994, pp.243-250. D. Davies, Some Regular Properties of the Data Encryption Standard Algorithm, in Advances in Cryptology: Proc. of Crypto '82, Springer-Verlag, New York, 1983, pp.89-96. D. Davies, A Message Authenticator Algorithm Suitable for A Mainframe Computer, in Advances in Cryptology: Proc. of Crypto '84, Springer-Verlag, New York, 1985, pp.394-400. M. Dawson and S. E. Tavares, An Expanded Set of S-Box Design Criteria Based on Information Theory and its Relation to Differential-Like Attacks, in Advances in Cryptology: Proc. of Eurocrypt '91, Springer-Verlag, 1992, pp.352-367. W. Diffie and M. E. Hellman, Privacy and Authentication: An Introduction to Cryptography, in Proceedings of the IEEE, vol.67, 1979, pp.397-427. H. Feistel, Cryptography and Computer Privacy, Scientific American, vol.228, 1973, pp.15-23. H. Feistel, W. Notz, and J. L. Smith, Some Cryptographic Techniques for Machine-to-Machine Data Communications, Proceedings of the IEEE, vol.63, 1975, pp.1545-1554. E. Grossman and B. Tuckerman, Analysis of a Feistel-Like Cipher Weakened by Having No Rotating Key, Technical Report RC 6375, IBM, 1977. C. Harpes, G. Kramer, and J. Massey, A Generalization of Linear Cryptanalysis and the Applicability of Matsuis Piling-up Lemma, Proc. of Eurocrypt 95, Springer-Verlag, 1995, pp.2438. H. M. Heys and S. E. Tavares, Cryptanalysis of tree-structured substitution-permutation networks, IEE Electronics Letters, vol.29, #1, 1993, pp.40-1. H. M. Heys, The Design of Substitution-Permutation Network Ciphers Resistant to Cryptanalysis, Ph.D. Thesis, Department of Electrical and Computer Engineering, Queen's University, 1994. H. M. Heys and S. E. Tavares, On the security of the CAST encryption algorithm, in Canadian Conference on Electrical and Computer Engineering, Halifax, Nova Scotia, Canada, Sept., 1994, pp.332-335. B. S. Kaliski Jr., R. L. Rivest, and A. T. Sherman, Is the Data Encryption Standard a Group? (Results of Cycling Experiments on DES), Journal of Cryptology, vol.1-1, 1988, pp.3-36. J. B. Kam and G. I. Davida, Structured Design of Substitution-Permutation Encryption Networks, IEEE Trans. on Computers, vol. C-28, 1979, pp.747-753. L. R. Knudsen, Cryptanalysis of LOKI91, in Advances in Cryptology: Proc. of Auscrypt '92, Springer-Verlag, 1993, pp.196-208. L. R. Knudsen, Iterative Characteristics of DES and s2-DES, in Advances in Cryptology: Proc. of Crypto '92, Springer-Verlag, 1993, pp.497-511. X. Lai and J. L. Massey, A Proposal for a New Block Encryption Standard, Adv. in Cryptology: Proc. of Eurocrypt 90, Springer-Verlag, 1991, pp.389-404. X. Lai, J. L. Massey, and S. Murphy, Markov Ciphers and Differential Cryptanalysis, in Advances in Cryptology: Proc. of Eurocrypt '91, Springer-Verlag, 1991, pp.17-38. J. Lee, H. M. Heys, and S. E. Tavares, On the Resistance of the CAST Encryption Algorithm to Differential Cryptanalysis, in the Workshop Record of the Workshop on Selected Areas in Cryptography (SAC 95), May 18-19, 1995, pp.107-120. J. Massey, SAFER K-64: A Byte-Oriented Block-Ciphering Algorithm, Proceedings of the Cambridge Security Workshop on Fast Software Encryption, Cambridge, U.K., Dec. 9-11, 1993, Springer-Verlag, pp.1-17. [See also: SAFER K-64: One Year Later, in Proceedings of the Second International Workshop on Fast Software Encryption, Springer-Verlag, 1995, pp.212-241; and Strengthened Key Schedule for the Cipher SAFER, posted to the USENET newsgroup sci.crypt, September 9, 1995] M. Matsui, Linear Cryptanalysis Method for DES Cipher, in Advances in Cryptology: Proc. of Eurocrypt '93, Springer-Verlag, 1994, pp.386-397, 1994.
31
[34] [35] [36] [37] [38] [39] [40] [41] [42] [43] [44] [45]
[46]
[51] [52]
W. Meier and O. Staffelbach, Nonlinearity Criteria for Cryptographic Functions, in Adv. in Cryptology: Proc. of Eurocrypt '89, Springer-Verlag, 1990, pp.549-562. H. Meijer, Multiplication-Permutation Encryption Networks, Technical Report #85-171, Queen's University, Dept. of Computing and Information Science, 1985. R. Merkle, A Fast Software One-Way Hash Function, Journal of Cryptology, vol.3, #1, 1990, pp.4358. R. Merkle, Fast Software Encryption Functions, in Advances in Cryptology: Proc. of Crypto '90, Springer-Verlag, New York, 1991, pp.477-501. S. Miyaguchi, A. Shiraishi, and A. Shimizu, Fast Data Encryption Algorithm Feal-8, Review of Electrical Communications Laboratories, vol.36, #4, 1988. S. Miyaguchi, The FEAL Cipher Family, in Advances in Cryptology: Proc. of Crypto '90, SpringerVerlag, New York, 1991, pp.627-638. J. H. Moore and G. J. Simmons, Cycle Structure of the DES with Weak and Semi-Weak Keys, in Advances in Cryptology: Proc. of Crypto '86, Springer-Verlag, New York, 1987, pp.9-32. National Bureau of Standards (U.S.), Data Encryption Standard (DES), Federal Information Processing Standards Publication 46, Jan. 15, 1977. K. Nyberg, Constructions of bent functions and difference sets, in Advances in Cryptology: Proc. of Eurocrypt '90, Springer-Verlag, 1991, pp.151-160. K. Nyberg, Perfect nonlinear S-boxes, in Advances in Cryptology: Proc. of Eurocrypt '91, SpringerVerlag, 1991, pp.378-386. K. Nyberg and L. Knudsen, Provable Security Against Differential Cryptanalysis, in Advances in Cryptology: Proc. of Crypto 92, Springer-Verlag, 1993, pp.566-574. L. OConnor, An average case analysis of a differential attack on a class of SP-networks, in the Workshop Record of the Workshop on Selected Areas in Cryptography (SAC 95), May 18-19, 1995, pp.121-130. B. Preneel, W. Van Leekwijck, L. Van Linden, R. Govaerts, and J. Vandewalle, Propagation characteristics of boolean functions, in Advances in Cryptology: Proc. of Eurocrypt '90, SpringerVerlag, Berlin, 1991, pp.161-173. V. Rijmen, B. Preneel, On Weaknesses of Non-surjective Round Functions, in Workshop Record of the Workshop on Selected Areas in Cryptography (SAC 95), May 18-19, 1995, pp.100-106. R. Rivest, The RC5 Encryption Algorithm, Proceedings of the Second International Workshop on Fast Software Encryption, Springer-Verlag, 1995, pp.86-96. B. Schneier, The Blowfish Encryption Algorithm, Proceedings of the Cambridge Security Workshop on Fast Software Encryption, Cambridge, U.K., Dec. 9-11, 1993, Springer-Verlag, pp.191-204. J. Seberry, X.-M. Zhang, and Y. Zheng, Systematic Generation of Cryptographically Robust SBoxes (Extended Abstract), in Proceedings of the 1st ACM Conference on Computer and Communications Security, Fairfax, Virginia, USA, Nov. 3-5, 1993, pp.171-182. C. E. Shannon, Communication Theory of Secrecy Systems, Bell Systems Technical Journal, vol. 28, 1949, pp.656-715. M. Sivabalan, S. E. Tavares, and L. E. Peppard, On the Design of SP Networks from an Information Theoretic Point of View, in Advances in Cryptology: Proc. of Crypto '92, Springer-Verlag, 1993, pp.260-279. A. F. Webster, Plaintext/Ciphertext Bit Dependencies in Cryptographic Systems, M.Sc. Thesis, Department of Electrical Engineering, Queens University, Kingston, Ont., 1985. A. F. Webster and S. E. Tavares, On the Design of S-Boxes, in Adv. in Cryptology: Proc. of Crypto '85, Springer-Verlag, New York, 1986, pp.523-534. M. Wiener (personal communication). A. Youssef (personal communication).
32
Appendix A. This appendix provides full details of the CAST-128 key schedule (see Section 5). A.1. Key Schedule Let the 128-bit key be x0x1x2x3x4x5x6x7x8x9xAxBxCxDxExF, where x0 represents the most significant byte and xF represents the least significant byte. Let Km1, ..., Km16 be sixteen 32-bit masking subkeys (one per round). , Kr16 be sixteen 32-bit rotate subkeys (one per round); only the least Let Kr1, significant 5 bits are used in each round. Let z0..zF be intermediate (temporary) bytes. Let Si[] represent s-box i and let ^ represent XOR addition. The subkeys are formed from the key x0x1x2x3x4x5x6x7x8x9xAxBxCxDxExF as follows.
z0z1z2z3 = x0x1x2x3 ^ z4z5z6z7 = x8x9xAxB ^ z8z9zAzB = xCxDxExF ^ zCzDzEzF = x4x5x6x7 ^ K1 = S5[z8] ^ S6[z9] K2 = S5[zA] ^ S6[zB] K3 = S5[zC] ^ S6[zD] K4 = S5[zE] ^ S6[zF] x0x1x2x3 = z8z9zAzB ^ x4x5x6x7 = z0z1z2z3 ^ x8x9xAxB = z4z5z6z7 ^ xCxDxExF = zCzDzEzF ^ K5 = S5[x3] ^ S6[x2] K6 = S5[x1] ^ S6[x0] K7 = S5[x7] ^ S6[x6] K8 = S5[x5] ^ S6[x4] z0z1z2z3 = x0x1x2x3 ^ z4z5z6z7 = x8x9xAxB ^ z8z9zAzB = xCxDxExF ^ zCzDzEzF = x4x5x6x7 ^ K9 = S5[z3] ^ S6[z2] K10 = S5[z1] ^ S6[z0] K11 = S5[z7] ^ S6[z6] K12 = S5[z5] ^ S6[z4] x0x1x2x3 = z8z9zAzB ^ x4x5x6x7 = z0z1z2z3 ^ x8x9xAxB = z4z5z6z7 ^ xCxDxExF = zCzDzEzF ^ K13 = S5[x8] ^ S6[x9] K14 = S5[xA] ^ S6[xB] K15 = S5[xC] ^ S6[xD] K16 = S5[xE] ^ S6[xF] S5[xD] ^ S5[z0] ^ S5[z7] ^ S5[zA] ^ ^ S7[z7] ^ S7[z5] ^ S7[z3] ^ S7[z1] S5[z5] ^ S5[x0] ^ S5[x7] ^ S5[xA] ^ ^ S7[xC] ^ S7[xE] ^ S7[x8] ^ S7[xA] S5[xD] ^ S5[z0] ^ S5[z7] ^ S5[zA] ^ ^ S7[zC] ^ S7[zE] ^ S7[z8] ^ S7[zA] S5[z5] ^ S5[x0] ^ S5[x7] ^ S5[xA] ^ ^ S7[x7] ^ S7[x5] ^ S7[x3] ^ S7[x1] S6[xF] ^ S6[z2] ^ S6[z6] ^ S6[z9] ^ ^ S8[z6] ^ S8[z4] ^ S8[z2] ^ S8[z0] S6[z7] ^ S6[x2] ^ S6[x6] ^ S6[x9] ^ ^ S8[xD] ^ S8[xF] ^ S8[x9] ^ S8[xB] S6[xF] ^ S6[z2] ^ S6[z6] ^ S6[z9] ^ ^ S8[zD] ^ S8[zF] ^ S8[z9] ^ S8[zB] S6[z7] ^ S6[x2] ^ S6[x6] ^ S6[x9] ^ ^ S8[x6] ^ S8[x4] ^ S8[x2] ^ S8[x0] S7[xC] ^ S7[z1] ^ S7[z5] ^ S7[zB] ^ ^ S5[z2] ^ S6[z6] ^ S7[z9] ^ S8[zC] S7[z4] ^ S7[x1] ^ S7[x5] ^ S7[xB] ^ ^ S5[x8] ^ S6[xD] ^ S7[x3] ^ S8[x7] S7[xC] ^ S7[z1] ^ S7[z5] ^ S7[zB] ^ ^ S5[z9] ^ S6[zC] ^ S7[z2] ^ S8[z6] S7[z4] ^ S7[x1] ^ S7[x5] ^ S7[xB] ^ ^ S5[x3] ^ S6[x7] ^ S7[x8] ^ S8[xD] S8[xE] S8[z3] S8[z4] S8[z8] ^ ^ ^ ^ S7[x8] S8[xA] S5[x9] S6[xB]
^ ^ ^ ^
^ ^ ^ ^
^ ^ ^ ^
[The remaining half is identical to what is given above, carrying on from the last created x0..xF to generate keys K17 - K32.]
z0z1z2z3 = x0x1x2x3 ^ z4z5z6z7 = x8x9xAxB ^ z8z9zAzB = xCxDxExF ^ zCzDzEzF = x4x5x6x7 ^ K17 = S5[z8] ^ S6[z9] K18 = S5[zA] ^ S6[zB] K19 = S5[zC] ^ S6[zD] K20 = S5[zE] ^ S6[zF] S5[xD] ^ S5[z0] ^ S5[z7] ^ S5[zA] ^ ^ S7[z7] ^ S7[z5] ^ S7[z3] ^ S7[z1] S6[xF] ^ S6[z2] ^ S6[z6] ^ S6[z9] ^ ^ S8[z6] ^ S8[z4] ^ S8[z2] ^ S8[z0] S7[xC] ^ S7[z1] ^ S7[z5] ^ S7[zB] ^ ^ S5[z2] ^ S6[z6] ^ S7[z9] ^ S8[zC] S8[xE] S8[z3] S8[z4] S8[z8] ^ ^ ^ ^ S7[x8] S8[xA] S5[x9] S6[xB]
33
x0x1x2x3 = z8z9zAzB ^ x4x5x6x7 = z0z1z2z3 ^ x8x9xAxB = z4z5z6z7 ^ xCxDxExF = zCzDzEzF ^ K21 = S5[x3] ^ S6[x2] K22 = S5[x1] ^ S6[x0] K23 = S5[x7] ^ S6[x6] K24 = S5[x5] ^ S6[x4] z0z1z2z3 = x0x1x2x3 ^ z4z5z6z7 = x8x9xAxB ^ z8z9zAzB = xCxDxExF ^ zCzDzEzF = x4x5x6x7 ^ K25 = S5[z3] ^ S6[z2] K26 = S5[z1] ^ S6[z0] K27 = S5[z7] ^ S6[z6] K28 = S5[z5] ^ S6[z4] x0x1x2x3 = z8z9zAzB ^ x4x5x6x7 = z0z1z2z3 ^ x8x9xAxB = z4z5z6z7 ^ xCxDxExF = zCzDzEzF ^ K29 = S5[x8] ^ S6[x9] K30 = S5[xA] ^ S6[xB] K31 = S5[xC] ^ S6[xD] K32 = S5[xE] ^ S6[xF]
S5[z5] ^ S5[x0] ^ S5[x7] ^ S5[xA] ^ ^ S7[xC] ^ S7[xE] ^ S7[x8] ^ S7[xA] S5[xD] ^ S5[z0] ^ S5[z7] ^ S5[zA] ^ ^ S7[zC] ^ S7[zE] ^ S7[z8] ^ S7[zA] S5[z5] ^ S5[x0] ^ S5[x7] ^ S5[xA] ^ ^ S7[x7] ^ S7[x5] ^ S7[x3] ^ S7[x1]
S6[z7] ^ S6[x2] ^ S6[x6] ^ S6[x9] ^ ^ S8[xD] ^ S8[xF] ^ S8[x9] ^ S8[xB] S6[xF] ^ S6[z2] ^ S6[z6] ^ S6[z9] ^ ^ S8[zD] ^ S8[zF] ^ S8[z9] ^ S8[zB] S6[z7] ^ S6[x2] ^ S6[x6] ^ S6[x9] ^ ^ S8[x6] ^ S8[x4] ^ S8[x2] ^ S8[x0]
S7[z4] ^ S7[x1] ^ S7[x5] ^ S7[xB] ^ ^ S5[x8] ^ S6[xD] ^ S7[x3] ^ S8[x7] S7[xC] ^ S7[z1] ^ S7[z5] ^ S7[zB] ^ ^ S5[z9] ^ S6[zC] ^ S7[z2] ^ S8[z6] S7[z4] ^ S7[x1] ^ S7[x5] ^ S7[xB] ^ ^ S5[x3] ^ S6[x7] ^ S7[x8] ^ S8[xD]
^ ^ ^ ^
^ ^ ^ ^
^ ^ ^ ^
A.2. Masking Subkeys And Rotate Subkeys Let Km1, ..., Km16 be 32-bit masking subkeys (one per round). , Kr16 be 32-bit rotate subkeys (one per round); only the least significant 5 Let Kr1, bits are used in each round.
for (i=1; i<=16; i++) { K mi = K i; Kri = K16+i; }
Appendix B. This appendix provides the contents of the CAST-128 s-boxes (see Section 5).
S-Box S1 30fb40d4 88bbbdb5 ff2379c8 22540f2f 97943fac 90ecf52e b48ee411 c19b0c50 b1b6ab8a 6276a0b5 84c7cb8c 187184c9 04ee002e 380782d5 aa573b04 915a0bf5 cfa4bd3f adbe4528 1b069505 d4df39de e11f0abc 1cacd68d dd24cb9e a5bb15e6 98a52666 d4234870 d1231959 20c8c571 427b169c 9fa0ff0b e2034090 775f50e2 2abe32e1 4a97c1d8 22b0c054 4bff345d 882240f2 c71358dd 19a6fcdf 2ad75a0f 6c00b32d 89fe78e6 c7fa5cf6 4a805d8d 6b54bfab 2deaa3e2 d8710f69 41ece491 e01063da bfc5fe4a 2ad37c96 7e1c54bd 580304f0 5648f725 a7870bf3 381b7298 962bda1c 5ac9f049 6beccd2f 98d09675 43c340d3 aa54166b 527644b7 bc8e5935 fd45c240 0c6e4f38 6385c545 7a42206a 874a1427 73e2bb14 3fab0950 8ac31511 548300d0 2b0b1426 9e204d02 aa51c90f b4c332e6 4736f464 a70aec10 0175cb9d f01144f9 ca042cf1 ff5e569d 2d3b4d79 f5d2f4db e1e696ff dd8f0f00 3f258c7a 6e63a0e0 df2f8656 22568e3a b5f437a7 4b6d2f7f ad31973f a4e4bfd7 110f935d 29f9d4d5 a2d1936b a0bebc3c 325ff6c2 35e79e13 00322a3c ab4cc9d7 c8bd25ac aa786bf6 032268d4 5ad328d8 ac39570a c69dff09 d2240eb1 011a37ea 0ced63d0 42e04198 ab838653 b141ab08 5c8165bf 1e213f2f 15c361d2 887ca41a a2d341d0 b82cbaef 50bb64a2 c4f6d02e 4f5ba272 57538ad5 f61b1891 2ad286af 54623779 81383f05 47da91d0 bf64cddf 449ccd82 eadf55b3 22513f1e c9600acc b347cc96 3f04442f c75b65f0 9675b3fd 8dbfaadb 7c63b2cf 0cd0ede7 6e2f1e23 7cca89b9 9c004dd3 c2e7661d a2d2bd2d 66db40c8 d751d159 d2664910 55fc8165 564c1d2f 6a390493 bb72275e aa56d291 64459eab 6963c5c8 f40f9086 ba57a68e f7fbf265 d5bd9e98 aa51a79b ce387e6d 75bb0fc3 6188b153 d9db40d8 a3ac3755 35ba3e4a 700b45e1 26470db8 83719c9e 1a69e783 6003e540 22d4ff8e a1c9e0d6 a784392f 6ff7f0ed bee5812d d5b1caad c59c5319 e63d37e0 aa508167 d7894360 3f328b82 76cb5ad6 a7e2419e 75c6372b ab85c5f3 e31231b2 2ad344cc bf6bb16c 98511bfb e0397a2e ec0e7779 d47c27af 3526ffa0 d5ea50f1 f881814c bd91e046 02cc4843 cf9fc949 28683b6f 346c4819 004dff2f 5a097a1f b7332290 a1ac2dae b949e354 2a54f6b3 38901091 425c750d 7718cf82 d49974c9 31366241 50afd341 1b55db94 2ad5ad6c 7b5a41f0 6a70fb78 4ffbcc35 5727cb79 4744ead4 51c85f4d c37b4d09 85a92872 474d6ad7 9a56456e a2f7c579 bfd4af27 c07fd059 61b76d87 2db9d2de 827b68d0 e93b159f a2d4b76d b04669fe 3a787d5f c6b505eb 93b39e26 59a2cea6 ca180dcf 051ef495 a7c13275 aad4e324 954329de d37cfbad 0d03d9c9 b58bcf6a 9ceb418f b11c3274 56907596 bc306ed9 af1fbda7 7c0c5e5c dc39200c 429ef47d
34
S-Box S2 1f201094 4e1d7235 ee15b094 a5e6cf7b 98de8b7f 0d554b63 361e3084 ba6cf38c fc884f69 844e8212 77840b4d dadc4755 33b4a34c b96726d1 a4b09f6b 9f63293c 73f98417 cb3f4861 31eef84d 30f66f43 99319ad5 bec0c560 273be979 8f1c9ba4 2d6a77ab 2667a8cc dcb1c647 4fb089bd 7160a539 S-Box S3 8defc240 eefbcaea b2e3e4d4 125e3fbc 3373f7bf 1fb78dfc c5884a28 5afb9a04 8c96fdad a672597d 60270df2 e29d840e 224d1e20 3cf8209d 127dadaa 64380e51 4b39fffa d11e42d1 35c0eaa5 f9ff2889 494a488c 7c34671c a2e53f55 7b00a6b0 6ea22fde b1e583d1 8ab41738 2b6d8da0 dfef4636 S-Box S4 9db30420 e60fb663 c9430040 2d195ffe d2b8ee5f 547eebe6 72500e03 ffc304a5 a5bf6d8e 8bd78a70 df871b62 2f91a340 99afc8b0 d0ec3b25 041afa32 56e55a79
ef0ba75b d55a63ce e9ffd909 01420ddb 77e83f4e 5d681121 e4eb573b 10843094 3e4de8df 128d8098 a1b6a801 b5625dbf 397bc8d6 8049a7e8 1ca815cf ee41e729 a1269859 c26bd765 7e0824e4 b3faec54 c242fa0f 61a3c9e8 b0ffeaa6 dc8637a0 3527ed4b 85196048 ac4c56ea 649da589 73bfbe70 25fa5d9f e8cf1950 3d4f285e 21fffcee 8c9f8188 8e6bd2c1 ccc36f71 a747d2d0 5d2c2aae ada840d8 0276e4b6 842f7d83 8437aa88 6094d1e3 438a074e 68cc7bfb ba39aee9 cead04f4 e805d231 694bcc11 b9b6a80c 02717ef6 b9e6d4bc 947b0001 5f08ae2b b7dc3e62 20e1be24 642b1e31 a133c501 1fb6e9de 095f35a1 0cc32220 1a05645f 06df4261 446d4ca0 f80eb2bb 4d351805 1143c44f 7477e4c1 211c40b7 557be8de 56c8c391 b7801ab7 1d16625a 026a4ceb
69e3cf7e de0436ba dc440086 e4e7ef5b 79929269 c866c359 602f64a4 2537a95e ef0e0088 fed33fb4 84db26a9 68561be6 5ee22b95 22b7da7b a20c3005 6e1d2d7c ec645c44 64a3f6ab 2ccb49eb 157fd7fa a7e3ebb0 bca8f54d 61d9b8c6 16a7d3b1 821fd216 8c4bacea 3ebd81b3 a345415e 83877605 eb903dbf 51df07ae b9afa820 825b1bfd a6fc4ee8 437be59b b843c213 1651192e 8ee99a49 45f54504 94fd6574 340ce5c8 7d29dc96 cd9ca341 1f97c090 d90f2788 a4ffd30b 127ea392 428929fb 236a5cae 5c8f82bc 4feb5536 a2048016 570075d2 af7a616d 7f10bdce af96da0f 9c305a00 e9d3531c a7be7bef 79ebf120 fdd30b30 0c13fefe bb9e9b8a 6cf3d6f5 abe0502e 7f3d5ce3 43958302 b506e07c a51a9ef9 00eae4a7 6b65811c 8d6d3b24 6701902c 52437eff
393f4380 99c430ef ef944459 25a1ff41 24fa9f7b 3d63cf73 d63acd9c f46f6ffe 3559648d ce280ae1 e0b56714 83ca6b94 5f0e5304 5e552d25 8871df63 50045286 52c877a9 80342676 846a3bae ef8579cc c68e4906 c72feffa 00b24869 9fc393b7 095c6e2e 833860d4 230eabb0 5c038323 4523ecf1 e810c907 920e8806 fade82e0 9255c5ed c982b5a5 99b03dbf 6c0743f1 af70bf3e 50da88b8 fa5d7403 927985b2 96bbb682 2756d3dc 5c76460e 081bdb8a 12490181 faf7933b 10428db7 b4fcdf82 12deca4d 89d36b45 a2d02fff 97573833 f9bb88f8 e5c98767 f90a5c38 68458425 52bce688 ee353783 d273a298 fd059d43 c0a5374f 081b08ca 7293ea25 2649abdf ec8d77de a6c866c6 d0214eeb f32d0a25 0014377b 0ce5c2ec 5e146119 20c763ef 9b757a54 2f8f76b4
fe61cf7a 5f0c0794 ba83ccb3 e180f806 e113c85b cee234c0 1bbc4635 a1ff3b1f 8a45388c 27e19ba5 21f043b7 2d6ed23b 81ed6f61 5272d237 b9de2fcb 1e6685f3 cdff33a6 25a75e7b 8ff77888 d152de58 b8da230c 22822e99 b7ffce3f a7136eeb db92f2fb 0d23e0f9 6438bc87 3e5d3bb9
eec5207a 18dcdb7d e0c3cdfb 1fc41080 acc40083 d4d87e87 9e81032d 208cfb6a 1d804366 d5a6c252 e5d05860 eccf01db 20e74364 79d2951c 0cc6c9e9 f33401c6 a02b1741 e4e6d1fc ee5d60f6 db2ffd5e 80823028 82c570b4 08dc283b c6bcc63e 5eea29cb 6c387e8a f0b5b1fa 43d79572
55889c94 a1d6eff3 d1da4181 179bee7a d7503525 5c672b21 2701f50c 8f458c74 721d9bfd e49754bd 54f03084 a6d3d0ba b45e1378 c60d894c 0beeff53 30a22c95 7cbad9a2 20c710e6 7af75673 8f32ce19 dcdef3c8 d8d94e89 43daf65a 1a513742 145892f5 0ae6d249 8f5ea2b3 7e6dd07c
72fc0651 a0b52f7b 3b092ab1 d37ac6a9 f7ea615f 071f6181 99847ab4 d9e0a227 a58684bb c5d655dd 066ff472 b6803d5c de18639b 488cb402 e3214517 31a70850 2180036f cdf0b680 2fdd5cdb 306af97a d35fb171 8b1c34bc f7e19798 ef6828bc 91584f7f b284600c fc184642 06dfdf1e
ada7ef79 59e83605 f997f1c1 fe5830a4 62143154 39f7627f a0e3df79 4ec73a34 e8256333 eb667064 a31aa153 af77a709 881ca122 1ba4fe5b b4542835 60930f13 50d99c08 17844d3b a11631c1 02f03ef8 088a1bc8 301e16e6 7619b72f 520365d6 5483697b d835731d 0a036b7a 6c6cc4ef
47607fff f0ad0548 a067268b 1257a240 a8c01db7 b5dbc64b 8309893c 58c31380 8427f4a0 e83ec305 8276dbcb 93b4b148 8b907cee 00ea983b 93a07ebe 5de5ffd4 6d498623 8272a972 4fb66a53 2c3f8cc5 3a609437 d2bf60c4 d7207d67 8942019e cf1febd2 0ff0443d 99833be5 1b03588a
369fe44b e13c8d83 8272792e 4e1a8302 579fc264 638dc0e6 0feddd5f 5f98302e 1eac5790 4f91751a 02778176 ef303cab b51fd240 d4d67881 b938ca15 dd7ef86a 193cbcfa 9270c4a8 0e7dc15b d2d02dfe ec00c9a9 d43f03c0 de0f8f3d 4264a5ff 61efc8c2 606e6dc6 600d457d f7baefd5
8c1fc644 927010d5 553fb2c0 bae07fff 67094f31 55819d99 2f7fe850 727cc3c4 796fb449 925669c2 f8af918d 984faf28 e7c07ce3 fd47572c 97b03cff 76a2e214 27627545 127de50b 1f081fab f8ef5896 44715253 50b4ef6d 72f87b33 856302e0 f1ac2571 60543a49 282f9350 4142ed9c
aececa90 11107d9f 489ae22b 528246e7 f2bd3f5f a197c81c d7c07f7e 0a0fb402 8252dc15 23efe941 4e48f79e 779faf9b e566b4a1 f76cedd9 3dc2c0f8 b9a40368 825cf47a 285ba1c8 108618ae e4cf52da 0a874b49 07478cd1 abcc4f33 72dbd92b cc8239c2 5727c148 8334b362 a4315c11
beb1f9bf 07647db9 d4ef9794 8e57140e 40fff7c1 4a012d6e 02507fbf 0f7fef82 efbd7d9b a903f12e 8f616ddf 92dc560d c3e9615e bda8229c 8d1ab2ec 925d958f 61bd8ba0 3c62f44f fcfd086d 95155b67 d773bc40 006e1888 7688c55d ee971b69 67214cb8 2be98a1d d91d1120 83323ec5
4a4f7bdb 6497b7b1 1d2d00d9 05170121 ce84ffdf aea0c7f5 57971e81 5d5bcca9 022083b8 79098b02 041e8ac8 4db4bba6 6e85cb75 c366a5fc 31d477f7 0df980a5
64ad8c57 f3641f63 24147b15 80530100 f5718801 36338cc1 e14f6746 daec6fea 3fb6180c e4eabb81 09114003 e756bdff be07c002 9c382880 9126b031 8674cde3
85510443 241e4adf ee4d111a e83e5efe 3dd64b04 503f7e93 c9335400 9f926f91 18f8931e 28123b23 bd59e4d2 dd3369ac c2325577 0ace3205 36cc6fdb edda04eb
fa020ed1 28147f5f 0fca5167 ac9af4f8 a26f263b d3772061 6920318f 9f46222f 281658e6 69dead38 e3d156d5 ec17b035 893ff4ec aac9548a c70b8b46 17a9be04
7e287aff 4fa2b8cd 71ff904c 7fe72701 7ed48400 11b638e1 081dbb99 3991467d 26486e3e 1574ca16 4fe876d5 06572327 5bbfc92d eca1d7c7 d9e66a48 2c18f4df
35
b7747f9d 6552daf9 49bafefd 6c728aff b1c52fca 9711aac5 af9eb3db 015f1919 d8eeb6d2 1fda8538 df7e052f ccd6fd43 13ecf0b0 S-Box S5 7ec90c04 e7f511cc c4494816 41d0efe2 c106ecd7 8709e6b0 2261be02 3d959981 ef55a1ff 17af8975 e53a7426 04a5c284 c7fb7dc9 c1bacb7f 68cb3e47 b0d70eba 580a249f c0f1648a 28421c9a aa90b472 f3e4f94e 6e5dd2f3 1ad2fff3 58ebb16e 3d38f5f7 20758184 6bac307f f19f06be 5e76ffa8 S-Box S6 f6fa8f9d dfa1e2ed f506c6da eaa01866 d0d51932 4c7f4448 2c0e636a 1ae2eac8 80226dae 53c0843a e967fd78 da5a26c0 4f628daa a8dc8af0 e9a9d848 592af950 89dff0bb c39a3373 b353fd00 6062e397 c10908f0 0c5ec241 bc60b42a 361400bc b17f5505 54268d49 97c55b96 a0e1d855 48392905
ab2af7b4 d2c231f8 187908d9 71eae2a1 b4be31cd 001d7b95 29c9ed2a 77079103 e523be77 1987832f db25701c 41823979 d3ffb372 2c6e74b9 d2051b00 ccf5c180 4e40b48d 97a5980a d7e07156 d642a0c9 5c1ff900 e59ca2c2 32c7911c 01b3d82b 636737b6 3063fcdf e5ff550f 086c010f 0ab378d5 94f74bc0 697ed5af 44489406 3ca5d717 176d486f 20936079 8c25404e 44094f85 0ca81f36 d0cefa65 376829d2 f9e0659a b1534546 2cac6ce1 83f0579d e4625e7e a084db2d cf0fec14 dab5d440 ba7dd9cd 284caf89 c340a4a3 fe893655 0ba93563 e81f994f 57f55ec5 7345c106 f3160289 36f73523 5fe2be78 42410005 cbb0e358 47cf8e7a 513021a5 8809286c 953498da e8816f4a 59357cbe 51a477ea eaec991b d36b4cf1 a65b1db8
efc34d20 25130f69 8d0dbd86 1f9af36e d8782806 82e5e7d2 5ce2a465 dea03af6 c2154529 ca007367 1b5e51ee 932bcdf6 3f85c5c1 9b0e66df 735aba00 38851640 248eb6fb c539b9aa 4e29fea7 df13a280 fe38d399 a6b62d27 89f89468 1a9e7449 50f5b616 b6f589de b6083049 a21de820 d951fb0c e327888e 49e92ff6 736e4cb8 7d161bba 097c13ea 459b80a5 324ed72f 3f481d87 52af4a8a 88f7be58 85360fa9 eeb9491d 6d47de08 4ca34867 63ed86b9 a308ea99 09a8486f f7ca07d2 6dba0ec3 ea6f7388 aa928223 df7e9c09 25bfe68a 8e342bc1 9528cd89 e2220abe f41e232f 3a62ef1d 4cfb6e87 448f4f33 6a091751 830f220a b6c85283 6c5b68b7 f592d891 fba1ae12 3814f200 edbd15c8 5017d55b 29935913 f544edeb 851c97bd
2e096b7c d8167fa2 311170a7 cfcbd12f 12a3a4e2 109873f6 a730f32c 78a8565e 2f69efdf a99144f8 f65324e6 b657c34d 0aef7ed2 a6337911 2ab722d8 15b0a848 8dba1cfe 4d79fe6a 6366e52d 74b55bd2 0c4eff0b e66a4263 0d01e980 64ee2d7e f24766e3 ec2941da 5bb5d0e8 d18b69de ded7da56 9f7b5561 309e374f c1092910 9cad9010 631da5c7 be60e2db 4067b7fd fcfeae7b 66d5e7c0 4a046826 17e3fe2a 34010718 efe9e7d4 e2337f7c 1ab6a6b8 4e23e33c a888614a d0a82072 083919a7 e70bc762 9334be53 a694a807 b4628abc e8a11be9 fd339fed d2916ebf 35162386 a787e238 7da4cec0 754613c9 0ef3c8a6 1f8fb214 3cc2acfb 822f8aa0 08a930f6 2d4bd736 a3f94043 7f97c5ab d7d25d88 01fdb7f1 b0e93524 d675cf2f
1741a254 0418f2c8 3e9b640c c1de8417 6f7de532 00613096 d0aa3fe8 dee356df afe67afb 296b299e 6afce36c 4edfd282
e5b6a035 001a96a6 cc3e10d7 ac07be6b 58fd7eb6 c32d9521 8a5cc091 21f05cbe f470c4b2 492fc295 0316cc04 7ae5290c
213d42f6 0d1526ab d5cad3b6 cb44a1d8 d01ee900 ada121ff d49e2ce7 8b75e387 f3e0eb5b 9266beab 8644213e 3cb9536b
2c1c7c26 63315c21 0caec388 8b9b0f56 24adffc2 29908415 0ce454a9 b3c50651 d6cc9876 b5676e69 b7dc59d0 851e20fe
61c2f50f 5e0a72ec f73001e1 013988c3 f4990fc5 7fbb977f d60acd86 b8a5c3ef 39e4460c 9bd3ddda 7965291f 9833557e
b86a7fff 386381cb e68b18cb 41a99b02 f2f3f763 02d1c000 682199c0 062407ea df65001f 524755f4 cddbb1da 8eca36c1 26e46695 87d72e5a f3f65777 4124bbe4 c3dc0280 2cb6356a 8bc95fc6 af462ba2 445f7382 a9c23101 0523138e 77b5ff76 df3b0874 0ff6f8f3 24b79767 bb30cab8
1dd358f5 acf6243a 4caadeff 1a550a04 68af8040 c4ac8e05 d421e5ec aa2f4fb1 0ec50966 03b63cc9 01c94910 136e05db b7566419 ab6a6ee1 fa02c3f6 94ca0b56 05687715 85808573 7d869cf4 9fe459d2 175683f4 eba5315c 5ca3bc78 8c2302bf 95055110 a09c7f70 f5a96b20 e822fe15
44dd9d44 69befd7a 5f480a01 ba8f65cb ed0c9e56 9377f571 53fb3ce8 4fb96976 dfdd55bc 0cc844b2 b868bf80 fef18391 f654efc5 223a66ce 407edac3 0f5755d1 646c6bd7 4991f840 134f616f 45d34559 cdc66a97 224e42f2 dc0fd66e aaf47556 1b5ad7a8 5346aba0 d6cd2595 88570983
1731167f e6a2e77f 0412b2aa 7251f4e7 11b4958b 0c05372a c8adedb3 90c79505 29de0655 bcf3f0aa 0d26f3fd fb887a37 d08d58b7 c62bf3cd cbb3d550 e0e1e56e 44904db3 76f0ae02 2e77118d d9f2da13 70be0288 1c5c1572 75922283 5f46b02a f61ed5ad 5ce96c28 68ff1ebf 750e6249
08fbf1fa f0c720cd 259814fc 95a51725 e1eb5a88 578535f2 28a87fc9 b0a8a774 911e739a 87ac36e9 9342ede7 d6e7f7d4 48925401 9e0885f9 1793084d 6184b5be 66b4f0a3 083be84d b31b2be1 dbc65487 b3cdcf72 f6721b2c 784d6b17 2b092801 6cf6e479 e176eda3 7555442c da627e55
95db08e7 de5ebe39 79cbd7cc 2900af98 fd41197e 9fbaeed9 35f29adb 3b3a21bf 5b7c5ecc cf222ebf 4980740d b87834bf 4ec75b95 e6ea8926 f3a5f676 6c152daa 2b05d08d 890072d6 d372cf08 3fc06976 3007cd3e 957ef305 0f25faab 9c7a54c2 ba5ac7b5 44136c76 088e8dfa bebb8fbd
016843b4 f38ff732 48a14367 01665991 9305a6b0 49dbcfb0 5c4cdd8d 16434be3 221db3a6 25ac6f48 c8087dfc 5f04456d 24f2c3c0 3333b094 74364853 cb0396a8 48b9d585 28207682 cc3c4a13 4e8f0252 74719eef b7fbffbd a4f3fceb bc704f57 b6f6deaf 0404a8c8 9ab6f6f5 a2d762cf
eced5cbc 8989b138 a3149619 e1992863 e86be3da 4e670c53 f0d48d8c 9aea3906 9a69a02f a9a99387 8de4bf99 22258698 42d15d99 157ec6f2 20951063 c50dfe5d dc049441 a9a9f7be 8cf63166 64d8314d dc872681 c266e96f e2969123 da41e7f9 3a479c3a b8e5a121 3b4cbf9f 49c92f54
325553ac 33f14961 fec94bd5 c8f30c60 74bed3cd 5c3d9c01 b88153e2 efe8c36e 68818a54 53bddb65 a11101a0 c9c4c83b cd0d7fa0 372b74af 4576698d fcd707ab c8098f9b bf32679d 061c87be da3870e3 073340d4 6fe4ac98 257f0c3d c25ad33a 5302da25 b81a928a 4a5de3ab 38b5f331
bf9f0960 c01937bd a114174a 2e78ef3c 372da53c 64bdb941 08a19866 f890cdd9 ceb2296f e76ffbe7 7fd37975 2dc156be 7b6e27ff 692573e4 b6fad407 0921c42f 7dede786 d45b5b75 88c98f88 1e665459 7e432fd9 b173ecc0 9348af49 54f4a084 653d7e6a 60ed5869 e6051d35 7128a454
S-Box S7 85e04019 332bf567 662dbfff cfc65693 2a8d7f6f ab9bc912 de6008a1 2028da1f 0227bce7 4d642916 18fac300 50f18b82 2cb2cb11 b232e75c 4b3695f2 b28707de a05fbcf6 cd4181e9 e150210c e24ef1bd b168c381 fde4e789 5c79b0d8 1e8bfd43 4d495001 38be4341 913cee1d
36
92a79c3f c3b3ad66 eb12ff82 d0d854c0 42d2d816 c06eba30 468f508b aba68ced b3a1f25d 98f8f35a d45230c7 be8b9d2d 5dda0033 2711fd60 c2610aca dd1e16c3 40055a2c b87242d1 58d4f2ae e4f2dfa6 4b269301 d3b5ab34 30bcc33d 2d57539d b6e318d2 f2a279c7 S-Box S8 e216300d e5952f11 be197029 669ded42 b301d40a ce949ad4 57e8726e 70108c0c 522fffb1 27eb35e6 d4de495a 46a52564 7f229b1e e2506d3d 7cd16efc 151682eb b6f2cf3b 57e85b7a c5068778 223613bd 9052815e db485694 e0779695 1a00726e a0e736a0 87451c0f 36997b07 0c768347 50b2ad80
089766be 28136086 e3486911 cb3a6c88 0a961288 07211b24 7829435f 9ac96f78 f7debb85 1626a49f 2bd1408b 7979fb06 f28ebfb0 438050e3 3d49a9cf 15e0d7f9 93d29a22 19de7eae 9ea294fb 693ed285 c79f022f f72bf9b7 38a0c07d 569a58cf 3ffa50bc 94e01be8 bbddfffc ece7990a 84a00940 c7ece831 02e7d1ca b84769ad 647a78fc bbd35049 d24708cc c9aff67b 64c6d006 f8d7e54e 31842e7b 4f9b12ea 1436876c a842eedf 9f326442 d53f5af6 e580b3e6 dd06caa2 5e410fab 38d7e5b2 f9c17a8f 11403092 5564a6b9 e0f6a27a 0e84093d 589e8d82 eaee6801
baeeadf4 0bd8dfa8 d34d7516 47bc2829 e1a5c06e 45c28829 f124183b 06a5b79a 61fe033c eed82b29 60c03eb7 e7225308 f5b9c310 069908a8 bae3b9df 50b1b887 e32dbf9a 053e561a 52cf564c 74904698 3c997e7e 1b0434c0 fd1606f2 e84e63ad 3d40f021 90716f4b a7ebdabd 9386d174 bb243a0f 3f8f95e7 53571dae 965bd862 99865d44 2998df04 1c7e27cd 36baf5b8 bcc0c62c 3e378160 24259fd7 f215f225 f1544107 fdba60b4 cb15a4cc 20cf4d8c 4e68b8f4 37df932b b48a2465 57720101 7a5b2121 00da6d77 10853209 3ada4819 4aa93e61 0d2059d1 8db2a283
1286becf 356d1cf2 4e7b3aff 4725ba37 13749e67 c95e317f 821dba9f b2856e6e 16746233 1d382fe3 b9068d78 8b75cf77 a0eac280 3d7fedc4 b65f8de6 2b9f4fd5 058745b9 15ad6f8c 9883fe66 4c2b0edd 5e4f9504 4e72b567 c363519b 462e1b78 c3c0bdae 954b8aa3 35648095 2a42931c b4d137cf 72df191b 7a3182a2 82f3d055 608bd593 980cf42a a4eb215b 09c467cd 3dd00db3 7895cda5 f8bef472 a223736f bedeee14 f1907b75 b01a4504 cea4d428 c5c8b37e c4248289 2eda7fa4 730edebc d187b896 4a0cdd61 c7eb8f37 4cf1764f 8360d87b a466bb1e ea8bf59e
b6eacb19 107789be 5f43671b a66ad22b 72fc081a bc8ec511 aff60ff4 1aec3ca9 3c034c28 0c4fb99a a33754f4 11ef8da4 08b9767a 826d2bef 92aeaf64 625aba82 3453dc1e 66626c1c 2ec40581 4f757656 3ffafbbd 5592a33d 589dd390 6580f87e 4958c24c
2660c200 b3b2e9ce 9cf6e037 7ad61f1e b1d139f7 38bc46e9 ea2c4e6d be838688 da6d0c74 bb325778 f430c87d e083c858 a3d9d2b0 4eeb8476 3ac7d5e6 6a017962 d699296e 7154c24c 763953c3 5d393378 76f7ad0e b5229301 5479f8e6 f3817914 518f36b2
7565bde4 0502aa8f 4981ac83 0c5cbafa f9583745 c6e6fa14 16e39264 0e0804e9 79aac56c 3ec6d97b c8a71302 8d6b786f 79d34217 488dcf25 9ea80509 2ec01b9c 496cff6f ea082b2a 01d6692e a132234f 296693f4 cfd2a87f 1cb8d647 91da55f4 84b1d370
64241f7a 0bc0351e 334266ce 4437f107 cf19df58 bae8584a 92544a8b 55f1be56 3ce4e1ad 6e77a6a9 b96d8c32 5a6317a6 021a718d 36c9d566 f22b017d 15488aa9 1c9f4986 93eb2939 d3a0c108 3d321c5d 3d1fce6f 60aeb767 97fd61a9 40a230f3 0fedce83
8248dca9 166bf52a 8c9341b7 b6e79962 bec3f756 ad4ebc46 009b4fc3 e7e5363b 51f0c802 cb658b5c ebd4e7be fa5cf7a0 9ac6336a 28e74e41 a4173f70 d716e740 dfe2ed07 17dcb0f0 a1e7160e c3f5e194 c61e45be 1814386b ea7759f4 d1988f35 878ddada
7789f8b7 76e38111 b44e79f0 7580330d 12a8ddec 66fb9767 6c200e03 9b6df491 3cf1d2e2 c18910b1 708f8f34 859c15a5 835ffcb8 9fb4c428 56e9af27 20e3030f f1e47d8d 79d130a4 0d809ea2 acf3ebc3 e87b40e4 5b643113 29263a4d ad1f4603 2de705ca 0d771c2b 1fa98b0c f8da0a82
e6c1121b b12def3a 049eedfd 94074251 fdaa335d 15b80b4e 39dc5ff6 9e7edd53 19b47a38 e11dbf7b 77d51b42 e6459788 6df4c1f2 25d04979 a04aa441 24d8c29e 844a1be5 3486ebfb 398feb7c 5715f6b7 e98ea084 94917e4f ba510cdf 605bdfb0 8951570f 67cdb156 1149382c 04f19130
0e241600 37ddddfc 0b15a15d 5c7dcdfa 176f43e8 1d5b47a0 5d0b00a3 06918548 424f7618 06cd1af8 264f620f c37bc75f 96f5b195 34c713f8 3cf7c899 e139673b bae7dfdc 33d3cddc 132a4f94 ef3478dd 5889e9e1 503c2fba 81f47c9f 9eedc364 df09822b 350d8384 e97625a5 ba6e4ec0
052ce8b5 de9adeb1 480d3168 abbe6d63 71fb46d4 4cfde06f ae63aff2 58cb7e07 35856039 7170c608 24b8d2bf db07ba0c fd0af0fc c4618187 92ecbae6 efa63fb8 42cbda70 77853b53 43b7950e f267616f efd390fc 646f1282 ad1163ed 22ebe6a8 bd691a6c 5938fa0f 0614d1b7 99265164
11a9cfb0 0a0cc32c 8bbbde5a aa402164 38129022 c28ec4b8 7e8bd632 3b74ef2e 9d17dee7 2d5e3354 15c1b79e 0676a3ab b0fe134c ea7a6e98 dd67016d 71873054 cd7dae0a 37effcb5 2fee7d1c c148cbe4 dd07d35b 7523d24a ea7b5965 cee7d28a aa12e4f2 42399ef3 0e25244b 1ee7230d
Appendix C. This appendix provides test vectors for the CAST-128 cipher described in Section 5 and in Appendices A and B.
37
C.2. Full Maintenance Test A maintenance test for CAST-128 has been defined to verify the correctness of implementations. It is defined in pseudo-code as follows, where a and b are 128-bit vectors, aL and aR are the leftmost and rightmost halves of a, bL and bR are the leftmost and rightmost halves of b, and encrypt(d,k) is the encryption in ECB mode of block d under key k.
Initial a = 01 23 45 67 12 34 56 78 23 45 67 89 34 56 78 9A (hex) Initial b = 01 23 45 67 12 34 56 78 23 45 67 89 34 56 78 9A (hex) do 1,000,000 times { aL = encrypt(aL,b) aR = encrypt(aR,b) bL = encrypt(bL,a) bR = encrypt(bR,a) } Verify a == EE A9 D0 A2 49 FD 3B A6 B3 43 6F B8 9D 6D CA 92 (hex) Verify b == B2 C9 5E B0 0C 31 AD 71 80 AC 05 B8 E8 3D 69 6E (hex)
38