This application is based upon and claims the benefit of priority of the prior Japanese Patent Application No. 2008-279028, filed on Oct. 30, 2008, the entire contents of which are incorporated by reference herein.
The present application relates to a swap circuit for a common key block cipher and an encryption/decryption circuit including the swap circuit.
In the information society of today, encryption and decryption of information according to certain rules are practiced in various fields for protection against leakage, tampering, and/or unauthorized copying of important information. Encryption and decryption of information is also effected in the field of small portable information storage media, such as smart cards. Such cards and the like include an encryption/decryption circuit for realization of encryption and decryption.
One method of encryption is common key cryptography. Similar encryption circuits adopt Data Encryption Standard (DES) or Advanced Encryption Standard (AES) methods, which are representative standards of the United States. The DES and AES methods involve block encryption. Data to be encrypted, called plaintext, are encrypted into ciphertext in units of blocks and ciphertext is similarly decrypted into plaintext in units of blocks. The unit block for encryption and decryption is 64-bit long in DES and 128-bit long in AES. Also, both of the encryption methods define a number of modes of operation, and certain processes for encryption and decryption are performed in accordance with those modes. In such modes of operation, four modes are defined in DES, including Electronic Codebook (ECB), Cipher Block Chaining (CBC), Cipher Feedback (CFB), and Output Feedback (OFB) modes, and AES further defines a Counter (CTR) mode in addition to the four modes of DES.
Behaviors of the modes of operation defined in DES will be illustrated below using
In decryption, input ciphertext Ci is decrypted by the decryption processing unit Dec and output as plaintext Pi.
Expressions representing processing in ECB mode are illustrated below: Encryption: Ci=Enc(Pi) (i=1, 2, 3, . . . ) Decryption: Pi=Dec(Ci) (i=1, 2, 3, . . . ).
In decryption, the initial value of initialization vector Vi is set in the register IV and used as initialization vector V1 for decryption of ciphertext C1. Ciphertext C1 is the first block of ciphertext divided into 64-bit long blocks. Next, ciphertext C1 is subjected to decryption processing in the decryption processing unit Dec and output as intermediate data D1. Then, an exclusive OR operation of intermediate data D1 and initialization vector V1 is performed, and plaintext P1 is output. Then, for decryption of ciphertext C2, i.e., the next block, ciphertext C1 is set in the register IV and used as initialization vector V2. Subsequently, the value in the register IV is updated and ciphertext Ci is decrypted in units of blocks in a similar way.
Expressions representing processing in CBC mode are illustrated below, where “XOR” indicates exclusive OR. Encryption:
Decryption:
In encryption, the initial value of initialization vector Vi is set in the register IV and used as initialization vector V1 for encryption of plaintext P1, the first block of plaintext divided into 8-bit long blocks. Next, the initialization vector V1 is subjected to encryption processing by the encryption processing unit Enc and output as intermediate data D1. Next, the high-order 8 bits of intermediate data D1 is taken, an exclusive OR operation of the 8 bits and plaintext P1 divided into 8-bit long blocks is performed, and 8-bit long ciphertext C1 is output. Then, a value that is concatenation of the low-order 56 bits of the 64-bit long initialization vector V1 mentioned above and the ciphertext C1 is set in the register IV and used as initialization vector V2 for encryption of the next plaintext, P2. Subsequently, the register IV is updated and plaintext Pi is encrypted in blocks in a similar way.
In decryption, the initial value of initialization vector Vi is set in register IV and used as initialization vector V1 for decryption of ciphertext C1, the first block of ciphertext divided into 8-bit long blocks. Next, initialization vector V1 is subjected to encryption processing by the encryption processing unit Enc and output as intermediate data D1. Next, the high-order 8 bits of intermediate data D1 is taken and an exclusive OR operation of the 8 bits and ciphertext C1 divided into 8-bit long blocks is performed, and 8-bit long plaintext P1 is output. Next, a value which is concatenation of the low-order 56 bits of the 64-bit long initialization vector V1 described above and the ciphertext C1 is set in the register IV and used as initialization vector V2 for decryption of the next ciphertext, C2. Subsequently, the register IV is updated and ciphertext Ci is decrypted in units of blocks in a similar way.
Expressions representing processing in CFB mode are illustrated below:
Encryption:
Decryption:
In decryption, the initial value of initialization vector Vi is set in the register IV and used as initialization vector V1 for decryption of ciphertext C1, the first block of ciphertext divided into blocks. Next, initialization vector V1 is subjected to encryption processing by the encryption processing unit Enc and output as intermediate data D1. Next, an exclusive OR operation of intermediate data D1 and ciphertext C1 is performed and P1 is output. Then, for decryption of ciphertext C2, i.e., the next block, the aforementioned intermediate data D1 is set in the register IV and used as initialization vector V2. Subsequently, the register IV is updated and ciphertext Ci is decrypted in units of blocks in a similar manner.
Expressions representing processing in OFB mode are illustrated below:
Encryption:
Decryption:
As described above, the DES method has the four modes of operation for performing encryption and decryption with different behaviors. And encryption/decryption circuits for use in small portable information storage media, such as smart cards, may be required to support all of these modes of operation, and moreover, to be small in size.
Japanese Patent Laid-Open No. 2000-75785 discusses an encryption circuit that is capable of implementing both the CBC and CFB modes of the DES method with a special circuit configuration.
Japanese Patent Laid-Open No. 2004-126323 discusses that processing by a host computer, including access processing, is reduced by isolating and separating encryption processing from the host computer.
Japanese Patent Laid-Open No. 2006-330126 discusses that overwriting of plaintext data which is caused by special processing on a break of encryption chain is eliminated by providing a buffer that can read in multiple blocks of plaintext data divided into blocks at a time and loading blocks less than can be read into the buffer.
However, because encryption/decryption processing and exclusive OR operation that are performed on plaintext and an initialization vector are different in order and combination depending on an operation mode in conventional techniques as mentioned above, an encryption/decryption circuit cannot be made small in size, due to the inclusion of circuits for all of the different modes of operation.
According to an aspect of the embodiment, an encryption/decryption circuit includes a swap circuit for outputting each of text data and initialization vector data which are input from an input terminal to either a first or second output terminal in accordance with one of modes of operation, an encryption/decryption processing unit to which one of the text data and the initialization vector data are input from the first output terminal and which performs encryption processing and decryption processing on the data, and an exclusive OR processing unit to which another one of the initialization vector data and the text data are input from the second output terminal and which performs an exclusive OR operation on the data.
The object and advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the claims.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory and are not restrictive of the invention, as claimed.
The above-described embodiments of the present invention are intended as examples, and all embodiments of the present invention are not limited to including the features described above.
Reference may now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like reference numerals refer to like elements throughout.
Hereinafter, embodiments will be described with respect to drawings. However, the technical scope is not limited to those embodiments and is intended to encompass matters set forth in CLAIMS and equivalents thereof.
While an encryption/decryption circuit for DES is illustrated in relation to the embodiments, similar embodiments may be also possible for the AES method.
As mentioned above, in the DES method, encryption/decryption processing and exclusive OR operation are performed on plaintext and an initialization vector, and their order and combination vary in different modes of operation. For that reason, an encryption/decryption circuit capable of supporting all the modes of operation includes an encryption/decryption processing unit and an exclusive OR processing unit. Plaintext and an initialization vector are input to the encryption/decryption processing unit and the exclusive OR processing unit in accordance with requirements of each of the modes of operation. Hereinafter, plaintext divided into blocks for encryption or ciphertext divided into blocks for decryption which are input to the encryption/decryption circuit of the embodiments will be called TEXT data, and an initialization vector will be called IV data. Also, data that are output being encrypted or decrypted will be referred to as encrypted data and decrypted data, respectively.
To start with, which input data, namely TEXT data or IV data, are directly subjected to encryption or decryption processing will be described with reference to the description of the modes of operation provided above. In ECB mode, IV data are not used and TEXT data undergo encryption or decryption processing. In CBC mode, no input data are directly subjected to encryption processing, but TEXT data are subjected to decryption processing in decryption. In CFB and OFB modes, IV data are subjected to encryption or decryption processing.
For realization of such operations, the encryption/decryption circuit according to the embodiments includes a swap circuit for switching data in accordance with an operation mode. Hereby, TEXT data are input to the encryption/decryption processing unit in ECB and CBC modes, and IV data are input to the encryption/decryption processing unit in CFB and OFB modes.
Now, operations of the encryption/decryption system of
In
For the first encryption or decryption of TEXT data, the initial value of IV data are input as input data I_DT from the memory 104 and set in the register reg41 (step T1). Then, TEXT data are input from the memory 104 as input data I_DT and set in the register reg42 (step T2).
In the encryption/decryption macro 100, the data set in the registers at steps T1 and T2 is each input to a corresponding one of the processing units 1 and 2 in accordance with requirements of the operation mode of interest with function of the swap circuit 90a to be encrypted or decrypted (step T3).
Then, encrypted or decrypted data are output as output data O_DT and stored in the memory 104 by way of the bus 105 (step T4).
Then, for the next encryption/decryption of TEXT data, the IV updating unit 50 updates IV data in accordance with requirements of the operation mode of interest. The updated IV data are set in the register reg41, i.e., the similar register as the one in which IV data was set at step T1 (step T5).
Then, when there is subsequent TEXT data to be encrypted or decrypted, processing is moved to step T2, and when there is no subsequent TEXT data, processing is terminated (step T6).
While encryption and decryption are performed as described in the embodiments, actual configuration and flow of processing are not limited thereto.
An overview of the first embodiment will be described first. The swap circuit 90 has the TEXT register 3 and the IV register 4 as dedicated registers in which TEXT data and IV data, which are input data I_DT, are set. The swap circuit 90 swaps data set in the registers using the selectors SEL11 and SEL12 in accordance with requirements of an operation mode so that the data are input to either the encryption/decryption processing unit 1 or the exclusive OR processing unit 2. In other words, in the swap circuit 90, a register for setting TEXT data and one for IV data are fixed and destination of data set in the registers is changed in accordance with an operation mode.
Now, operations of the components of the swap circuit 90 will be described. The TEXT register 3 and IV register 4 are dedicated registers in which TEXT data and IV data as input data I_DT are set, respectively. Individual pieces of input data I_DT are input from the similar path. Then, into the TEXT register 3, TEXT data are set via the path w1 in response to assertion of TEXT-data write enable signal, TEXT_WR. Likewise, into the IV register 4, IV data are set via the path w2 in response to assertion of IV-data write enable signal, IV_WR.
The selectors SEL11 and SEL12 have the similar bit length as the registers 3 and 4, and select either TEXT data set in the TEXT register 3 or IV data set in the IV register 4 and output the selected data to their respective processing unit. The selector SEL11 also performs OR operation of CFB mode signal, cfb, and OFB mode signal, ofb, with the two signals as control input. Hereinafter, an operational expression “|” represents OR. When an operation value (cfb|ofb) is 0, the selector SEL11 selects the TEXT register 3, causing TEXT data to be input to the encryption/decryption processing unit 1 via paths w3 and w7. When the operation value (cfb|ofb) is 1, the selector SEL11 selects the IV register 4, causing IV data to be input to the encryption/decryption processing unit 1 via paths w6 and w7. That is to say, when either one of operation signals cfb and ofb is “1”, which means being effective, IV data in the IV register 4 is input to the encryption/decryption processing unit 1. Likewise, when the operation value (cfb|ofb)=0, the selector SEL12 selects the IV register 4, causing IV data to be input to the exclusive OR processing unit 2 via paths w4 and w8. When the operation value (cfb|ofb)=1, the selector SEL12 selects the TEXT register 3, causing TEXT data to be input to the exclusive OR processing unit 2 via paths w5 and w8.
The encryption/decryption processing unit 1 performs encryption or decryption processing on input data w7, and the exclusive OR processing unit 2 performs exclusive OR processing on input data w8.
Next, certain operations of the swap circuit 90 in different modes of operation will be described. First, in response to assertion of IV-data write enable signal IV_WR to the IV register 4, IV data are set into the IV register 4 via path w2 as input data I_DT. And in response to assertion of TEXT-data write enable signal TEXT_WR to the TEXT register 3, TEXT data are set in the TEXT register 3 via path w1 as input data I_DT.
Then, in CBC mode, the operation value (cfb|ofb) is 0, so that the selector SEL11 selects the TEXT register 3 and the selector SEL12 selects the IV register 4. Accordingly, the TEXT data are input to the encryption/decryption processing unit 1 via paths w3 and w7, and the IV data are input to the exclusive OR processing unit 2 via paths w4 and w8.
In CFB or OFB mode, the operation value (cfb|ofb) is 1, so that the selector SEL11 selects the IV register 4 and the selector SEL12 selects the TEXT register 3. Accordingly, the IV data are input to the encryption/decryption processing unit 1 via paths w6 and w7 and the TEXT data are input to the exclusive OR processing unit 2 via paths w5 and w8.
Next, a configuration of an encryption circuit that uses the swap circuit 90 and is capable of supporting all the modes of operation of DES will be described.
Data input to the encryption/decryption unit 1 or the exclusive OR processing unit 2 described above is passed between the units via paths w50 and w60 in accordance with requirements of each operation mode, is encrypted or decrypted, and output as data O_DT.
The IV updating unit 50 updates IV data in accordance with requirements of each operation mode and sets the updated IV data in the IV register 4 via path w70. That is to say, when IV data are updated with a result of operation or the like of the last encryption or decryption during the second and subsequent encryption or decryption of TEXT data in CBC, CFB, and OFB modes, the IV updating unit 50 performs this updating of IV data in the encryption circuit of the present embodiment. The IV updating unit 50 includes a CFB feedback section CFB_FB, an OFB feedback section OFB_FB, and a CBC feedback section CBC_FB which perform IV updating in accordance with each operation mode with data w10 to w15 as input.
Data input paths to the IV register 4 are path w2 and path w70. That is to say, IV data for use in the first encryption is set in the IV register 4 via path w2, and IV data for use in the second and subsequent encryption is updated by the IV updating unit 50 and set in the IV register 4 via path w70 as mentioned above. In encryption in CBC mode, for example, ciphertext Ci that has been subjected to encryption processing in the encryption processing unit Enc is set in the register IV as illustrated in the block diagram of
A selector SEL39 outputs input data w2 as data w80 when busy=0 and outputs input data w70a as data w80 when busy=1, with busy signal as control input. Thus, IV data are set in the IV register 4 via path w2 in the first encryption by making busy=0, and after an encryption operation is started, is set in the IV register 4 via path w70a by making busy=1 at all times.
Operations in the different modes of operation will be described using
ECB Mode
In encryption, TEXT data are set into the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal, TEXT_WR. In ECB encryption mode, the operation value (cfb|ofb) for operation mode signals is 0 and the selector SEL11 selects path w3. Accordingly, TEXT data are input to the encryption/decryption unit 1 via paths w3 and w7, encrypted, and output as encrypted data O_DT. Subsequently, TEXT data are set in the TEXT register 3, encrypted by the encryption/decryption processing unit 1, and output as encrypted data O_DT in a similar manner.
Meanwhile, in decryption, TEXT data, which is ciphertext, is set into the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR. In ECB decryption mode, the operation value for operation mode signals (cfb|ofb) is 0, so that the selector SEL11 selects path w3. Accordingly, TEXT data are input to the encryption/decryption processing unit 1 via paths w3 and w7, decrypted, and output as decrypted data O_DT. Subsequently, TEXT data are set in the TEXT register 3, decrypted by the encryption/decryption processing unit 1, and output as decrypted data O_DT in a similar way.
The operations illustrated above correspond with the behavior of ECB mode described in
CBC Mode
In encryption, for the first encryption of TEXT data, the initial value of IV data are set into the IV register 4 via path w2 in response to assertion of IV-data write enable signal IV_WR. Next, TEXT data are set into the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR. In CBC encryption mode, the operation value for operation mode signals (cfb|ofb) is 0, so that the selector SEL11 selects path w3 and the selector SEL12 selects path w4.
Then, the TEXT data are input via paths w3, w7 and w9 and the IV data are input via paths w4 and w8 to the exclusive OR processing unit 2, and an exclusive OR operation of the two is performed therein. Then, resulting data w60, which corresponds to intermediate data Di of
Then, for the next encryption of TEXT data, the encrypted data O_DT mentioned above is input to the CBC feedback section CBC_FB of the IV updating unit 50 via paths w50 and w14, and set into the IV register 4 via path w70 in response to assertion of IV-data write enable signal IV_WR. Next, into the TEXT register 3, TEXT data are set via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR. Subsequently, encryption is repeated in a similar way.
In decryption, for the first decryption of TEXT data, the initial value of IV data are set into the IV register 4 via path w2 in response to assertion of IV-data write enable signal IV_WR. Next, TEXT data, which is ciphertext, is set into the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR. In CBC decryption mode, the operation value for operation mode signals (cfb|ofb) is 0, so that the selector SEL11 selects path w3 and the selector SEL12 selects path w4.
Then, the TEXT data are input to the encryption/decryption processing unit 1 via paths w3 and w7 to be subjected to decryption processing therein, and data w50 corresponding to the intermediate data Di of
Then, for the next decryption of TEXT data, the TEXT data in the TEXT register 3 is input to the CBC feedback section CBC_FB of the IV updating unit 50 via paths w3, w7, w9 and w15, and set into the IV register 4 via path w70 in response to assertion of IV-data write enable signal IV_WR. Next, into the TEXT register 3, TEXT data are set via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR. Subsequently, decryption is repeated in a similar manner.
Here, the CBC feedback section CBC_FB, which is common in
The operations illustrated above correspond with the behavior of CBC mode described in
CFB Mode
In encryption, for the first encryption of TEXT data, the initial value of 64-bit long IV data are set into the IV register 4 via path w2 in response to assertion of IV-data write enable signal IV_WR. Next, k-bit long TEXT data are set into the high-order k bits of the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR and 0 values are set in the remaining low-order bits. In CFB encryption mode, the operation value for operation mode signals (cfb|ofb) is 1, so that the selector SEL11 selects path w6 and the selector SEL12 selects path w5.
The IV data are then input to the encryption/decryption processing unit 1 via paths w6 and w7 to be subjected to encryption processing therein, and data w50 which corresponds to the intermediate data Di of
Then, for the next encryption of TEXT data, the IV data in the IV register 4 is input via paths w6, w7, w9 and w10, and the encrypted data mentioned above is input via paths w60 and w11 to the CFB feedback section CFB_FB of the IV updating unit 50, are subjected to bit processing, and set into the IV register 4 via path w70 in response to assertion of IV-data write enable signal IV_WR. Bit processing in the CFB feedback section CFB_FB is discussed later. Next, the following k-bit TEXT data are set into the high-order k bits of the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR and 0 values are set in the remaining low-order bits. Subsequently, encryption is repeated in a similar way.
In decryption, for the first decryption of TEXT data, the initial value of 64-bit long IV data are set into the IV register 4 via path w2 in response to assertion of IV-data write enable signal IV_WR. Then, into the high-order k bits of the TEXT register 3, k-bit long TEXT data, which is ciphertext, is set via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR and 0 values are set in the remaining low-order bits. Also, in CFB decryption mode, the operation value for operation mode signals (cfb|ofb) is 1, so that the selector SEL11 selects path w6 and the selector SEL12 selects path w5.
Then, the IV data are input to the encryption/decryption processing unit 1 via paths w6 and w7 to be subjected to encryption processing therein, and data w50 corresponding to the intermediate data Di of
Then, for the next decryption of TEXT data, the IV data in the IV register 4 is input via paths w6, w7, w9 and w10, and the TEXT data in the TEXT register 3 is input via paths w5, w8 and w12 to the CFB feedback section CFB_FB of the IV updating unit 50, subjected to bit processing, and set into the IV register 4 via path w70 in response to assertion of IV-data write enable signal IV_WR. Next, into the high-order k bits of the TEXT register 3, the following k-bit TEXT data are set via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR and 0 values are set in the remaining low-order bits. Subsequently, decryption is repeated in a similar way.
Here, the CFB feedback section CFB_FB, which is common in
The operations illustrated above correspond with the behavior of CFB mode described in
OFB Mode
In encryption, for the first encryption of TEXT data, the initial value of IV data are set into the IV register 4 via path w2 in response to assertion of IV-data write enable signal IV_WR. Next, TEXT data are set into the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR. In OFB encryption mode, the operation value for operation mode signals (cfb|ofb) is 1, so that the selector SEL11 selects path w6 and the selector SEL12 selects path w5.
Then, the IV data are input to the encryption/decryption processing unit 1 via paths w6 and w7 to be subjected to encryption processing therein, and data w50 which corresponds to the intermediate data Di of
Then, for the next encryption of TEXT data, the aforementioned intermediate data Di is input to the OFB feedback section OFB_FB of the IV updating unit 50 via paths w50 and w13, and set into the IV register 4 via path w70 in response to assertion of IV-data write enable signal IV_WR. The OFB feedback section OFB_FB is merely a feedback path as illustrated in
Meanwhile, in decryption, the initial value of IV data are set in the IV register 4 via path w2 in response to assertion of IV-data write enable signal IV_WR for the first decryption of TEXT data. Then, TEXT data, which is ciphertext, is set into the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR. In OFB decryption mode, the operation value for operation mode signals (cfb|ofb) is 1, so that the selector SEL11 selects path w6 and the selector SEL12 selects path w5.
Then, the IV data are input to the encryption/decryption processing unit 1 via paths w6 and w7 to be subjected to encryption processing therein, and data w50 which corresponds to the intermediate data Di of
Then, for the next decryption of TEXT data, the aforementioned intermediate data Di is input to the OFB feedback section OFB_FB of the IV updating unit 50 via paths w50 and w13, and set in the IV register 4 via path w70 in response to assertion of IV-data write enable signal IV_WR. Next, TEXT data are set into the TEXT register 3 via path w1 in response to assertion of TEXT-data write enable signal TEXT_WR. Subsequently, decryption is repeated in a similar manner. The operations illustrated above correspond with the behavior of OFB mode described in
The swap circuit 90 of the first embodiment may require selectors SEL11 and SEL12 that have the similar bit length as the register length in order to switch between the TEXT register and the IV register. On the other hand, the swap circuit 95 of the second embodiment employs 1-bit long selectors SEL21 and SEL22 in order to assert write enable signals reg1_wr and reg2_wr appropriate for an operation mode to the registers reg31 and reg32, and selects either one of the write enable signals. That is to say, to support the different modes of operation of the DES method, for example, the swap circuit 90 of the first embodiment may require two 64-bit long selectors, whereas the swap circuit 95 of the second embodiment may use two one-bit long selectors. According to the second embodiment, it may be thereby possible to reduce bit-length of selectors and wires, which may make circuits smaller and consume less electric power.
By using the selector of the second embodiment, divided input of data may be realized with a simple configuration. For example, when 32-bit data are input twice to a 64-bit long register for DES method, similar input processing to that described above may be performed using a one-bit selector for each 32-bit register. In other words, when data are to be input being divided into blocks, the data may be handled with several-bit selectors corresponding to the number of blocks.
The operations of components of the swap circuit 95 will be now described. The registers reg31 and reg32 are common registers in which either TEXT data or IV data, which are input data I_DT, is set, and the individual pieces of input data I_DT is input from the similar path.
The selector SEL21 outputs write enable signal reg1_wr to the register reg31 with operation mode signals cfb and ofb as control inputs and with TEXT-data write enable signal TEXT_WR and IV-data write enable signal IV_WR as inputs. In other words, the selector SEL21 selects either TEXT-data write enable signal TEXT_WR or IV-data write enable signal IV_WR in accordance with operation mode signals cfb and ofb, and outputs the selected signal as write enable signal reg1_wr to the register reg31.
In ECB and CBC modes, the operation value (cfb|ofb) is 0 and TEXT_WR is asserted to the register reg31 as write enable signal reg1_wr. In CFB and OFB modes, the operation value (cfb|ofb) is 1 and IV_WR is asserted to the register reg31 as write enable signal reg1_wr. When write enables signal reg1_wr is TEXT_WR, TEXT data are set in the register reg31, and when write enables signal reg1_wr is IV_WR, IV data are set in the register reg31.
The selector SEL22 performs similar operations, but an enable signal it selects for operation mode signals cfb and ofb is the reverse of the one selected by the selector SEL21. That is to say, in ECB and CBC modes, the operation value (cfb|ofb) is 0, so that IV_WR is asserted to the register reg32 as write enable signal reg2_wr. In CFB and OFB modes, the operation value (cfb|ofb) is 1, so that TEXT_WR is asserted to the register reg32 as write enable signal reg2_wr.
Data set in the register reg31 is input to the encryption/decryption unit 1 via path w7 and subjected to encryption or decryption processing therein. The data set in the register reg32 is input to the exclusive OR processing unit 2 via path w8 and is subjected to exclusive OR processing therein.
In ECB or CBC modes, output from OR gate p1 is (cfb|ofb)=0. Then, to set IV data first, TEXT-data write enable signal TEXT_WR becomes 0 and IV-data write enable signal IV_WR becomes 1. Accordingly, the selector circuit illustrated in
Meanwhile, in CFB and OFB modes, output from OR gate p1 is (cfb|ofb)=1. To set IV data first, TEXT-data write enable signal TEXT_WR becomes 0 and IV-data write enable signal IV_WR becomes 1. Accordingly, the selector circuit illustrated in
As described above, the selector circuit illustrated in
Certain operations of the swap circuit 95 in the different modes of operation will be now described. According to the example, operation mode signal has been determined when IV data are to be set in a register. For example, in CBC mode, operation mode signals cfb and ofb are not asserted to the selectors SEL21 and SEL22, and the operation value (cfb|ofb) is 0. Therefore, in response to assertion of IV_WR which is selected as write enable signal reg2_wr, IV data as input data I_DT is set into the register reg32 via path w2. Also, in response to assertion of TEXT_WR selected as write enable signal reg1_wr, TEXT data as input data I_DT is set into the register reg31 via path w1. Consequently, the TEXT data set in the register reg31 is input to the encryption/decryption processing unit 1 via path w7 and the IV data set in the register reg32 is input to the exclusive OR processing unit 2 via path w8.
In CFB mode, since CFB mode signal cfb is asserted to the selectors SEL21 and SEL22 (i.e., cfb=1), the operation value (cfb|ofb) is 1. Therefore, in response to assertion of IV_WR selected as write enable signal reg1_wr, IV data as input data I_DT is set into the register reg31 via path w1. Also, in response to assertion of TEXT_WR selected as write enable signal reg2_wr, TEXT data as input data I_DT is set into the register reg32 via path w2. Consequently, the IV data set in the register reg31 is input to the encryption/decryption processing unit 1 via path w7 and the TEXT data set in the register reg32 is input to the exclusive OR processing unit 2 via path w8.
In OFB mode, since OFB mode signal ofb is asserted to the selectors SEL21 and SEL22 (i.e., ofb=1), the operation value (cfb|ofb) is 1 and data input processing similar to that in CFB mode is performed.
Now, a configuration of an encryption circuit using the swap circuit 95 that is capable of supporting all the modes of operation of the DES method is described.
The IV updating unit 50 updates IV data in accordance with requirements of each operation mode and sets updated IV data into register reg31 or the register reg32 via path w75 or path w76.
Data input paths to the register reg31 are path w1 and path w75. In CFB and OFB modes, IV data to be used in the first encryption is set into the register reg31 via path w1 as mentioned above. IV data for use in the second and subsequent encryption is updated by the IV updating unit 50 and set into the register reg31 via path w75. Similarly, data input paths to the register reg32 are path w2 and path w76. In CBC mode, IV data to be used in the first encryption is set into the register reg32 via path w2. IV data for use in the second and subsequent encryption is updated by the IV updating unit 50 and set into the register reg32 via path w76.
The selector SEL35 outputs either data w71 or w72 as data w70b in accordance with operation mode signal cfb and ofb. The selector SEL33 outputs input data w1 as data w81 when busy=0 and outputs input data w70b as data w81 when busy=1. The selector SEL36 outputs input data w2 as data w82 when busy=0 and outputs input data w73 as data w82 when busy=1.
In CBC mode, for example, busy is 0 when TEXT data and IV data are input in the first encryption, so that IV data are set in the register reg32 via path w2 and TEXT data are set in the register reg31 via path w1. Then, busy becomes 1 and an encryption operation is performed. After the first encryption, updated IV data are set into the register reg32 via paths w73 and w82 because busy=1. Then, busy becomes 0 and TEXT data are input from path w1 and path w2. At the time of the input, write enable signal reg1_wr for the register reg31 is 1 because of setting to CBC mode and TEXT data are set in the register reg31 as mentioned above. Meanwhile, write enable signal reg2_wr for the register reg32 is 0 and the register reg32 keeps the updated IV data. Then, busy becomes 1 and operation will be performed in a similar manner.
Hereinafter, operation in the different modes of operation will be described using
ECB Mode
In ECB encryption mode, the operation value for operation mode signals (cfb|ofb) is 0 and TEXT data are set into the register reg31 via path w1 in response to assertion of TEXT_WR which is selected as write enable signal reg1_wr. Consequently, TEXT data are input to the encryption/decryption processing unit 1 via path w7, encrypted, and output. Subsequently, TEXT data are set into the register reg31 via path w1, encrypted by the encryption/decryption processing unit 1, and output as encrypted data O_DT in a similar way.
Meanwhile, in ECB decryption mode, the operation value for operation mode signals (cfb|ofb) is 0 and TEXT data, which is ciphertext, is set into the register reg31 via path w1 in response to assertion of TEXT_WR selected as write enable signal reg1_wr. Consequently, TEXT data are input to the encryption/decryption processing unit 1 via path w7, decrypted, and output. Subsequently, TEXT data are set into the register reg31 via path w1, decrypted by the encryption/decryption processing unit 1, and output as decrypted data O_DT in a similar way.
The operations illustrated above correspond with the behavior of ECB mode described in
CBC Mode
In CBC encryption mode, when the operation value for operation mode signals (cfb|ofb) is 0, the initial value of IV data are set into the register reg32 in response to assertion of IV_WR selected as write enable signal reg2_wr. Here, in the case of the selector of
Then, the TEXT data are input via paths w7 and w9 and the IV data are input via path w8 to the exclusive OR processing unit 2, in which an exclusive OR operation of the two is performed. Then, resulting data w60 which corresponds to the intermediate data Di of
Then, for the next encryption of TEXT data, the encrypted data O_DT mentioned above is input to the CBC feedback section CBC_FB of the IV updating unit 50 via paths w50 and w14, and set into the register reg32 via path w76 in response to assertion of IV-data write enable signal IV_WR. Next, to the register reg31, TEXT data are set via path w1 in response to assertion of TEXT_WR which is selected as write enable signal reg1_wr. Subsequently, encryption is repeated in a similar way.
In CBC decryption mode, when the operation value for operation mode signals (cfb|ofb) is 0, the initial value of IV data are set into the register reg32 in response to assertion of IV_WR which is selected as write enable signal reg2_wr. Similarly, TEXT data are set into the register reg31 in response to assertion of TEXT_WR which is selected as write enable signal reg1_wr.
Then, the TEXT data are input to the encryption/decryption processing unit 1 via path w7 to be subjected to decryption processing therein, and data w50 corresponding to the intermediate data Di of
Then, for the next decryption of TEXT data, the TEXT data in the register reg31 is input to the CBC feedback section CBC_FB of the IV updating unit 50 via paths w7, w9 and w15, and set into the register reg32 via path 76 in response to assertion of IV_WR selected as write enable signal reg2_wr. Next, TEXT data are set into the register reg31 via path w1 in response to assertion of TEXT_WR which is selected as write enable signal reg1_wr. Subsequently, decryption is repeated in a similar way.
The operations above correspond with the behavior of CBC mode described in
CFB Mode
In CFB encryption mode, when the operation value for operation mode signals (cfb|ofb) is 1, the initial value of 64-bit long IV data are set into the register reg31 in response to assertion of IV_WR which is selected as write enable signal reg1_wr. Similarly, k-bit long TEXT data are set into the high-order k bits of the register reg32 in response to assertion of TEXT_WR which is selected as write enable signal reg2_wr and 0 values are set in the remaining low-order bits.
Then, the IV data are input to the encryption/decryption processing unit 1 via path w7 to be subjected to encryption processing therein, and data w50 corresponding to the intermediate data Di of
Then, for the next encryption of TEXT data, the IV data in the register reg31 is input via paths w7, w9 and w10, and the encrypted data mentioned above is input via paths w60 and w11 to the CFB feedback section CFB_FB of the IV updating unit 50, are subjected to the aforementioned bit processing, and set in the register reg31 via path w75 in response to assertion of IV_WR which is selected as write enable signal reg1_wr. Next, the following k-bit TEXT data are set into the high-order k bits of the register reg32 via path w2 in response to assertion of TEXT_WR which is selected as write enable signal reg2_wr and 0 values are set in the remaining low-order bits. Subsequently, encryption is repeated in a similar way.
In CFB decryption mode, when the operation value for operation mode signals (cfb|ofb) is 1, the initial value of 64-bit long IV data are set into the register reg31 in response to assertion of IV_WR which is selected as write enable signal reg1_wr. Similarly, k-bit long TEXT data are set into the high-order k bits of the register reg32 in response to assertion of TEXT_WR which is selected as write enable signal reg2_wr and 0 values are set in the remaining low-order bits.
Then, the IV data are input to the encryption/decryption processing unit 1 via path w7 to be subjected to encryption processing therein, and data w50 corresponding to the intermediate data Di of
Then, for the next decryption of TEXT data, the IV data in the register reg31 is input via paths w7, w9 and w10, and the TEXT data in the register reg32 is input via paths w8 and w12 to the CFB feedback section CFB_FB of the IV updating unit 50, are subjected to the bit processing described above, and set in the register reg31 via path w75 in response to assertion of IV_WR which is selected as write enable signal reg1_w. Next, into the high-order k bits of the register reg32, the following k-bit TEXT data are set via path w2 in response to assertion of TEXT_WR which is selected as write enable signal reg2_wr, and 0 values are set in the remaining low-order k bits. Subsequently, decryption is repeated in a similar way.
The operations above correspond with the behavior of CFB mode described in
OFB Mode
In OFB encryption mode, when the operation value for operation mode signals (cfb|ofb) is 1, the initial value of IV data are set into the register reg31 in response to assertion of IV_WR which is selected as write enable signal reg1_wr. Similarly, TEXT data are set in the register reg32 in response to assertion of TEXT_WR which is selected as write enable signal reg2_wr.
Then, the IV data are input to the encryption/decryption processing unit 1 via path w7 to be subjected to encryption processing therein, and data w50 corresponding to the intermediate data Di of
Then, for the next encryption of TEXT data, the aforementioned intermediate data Di is input to the OFB feedback section OFB_FB of the IV updating unit 50 via paths w50 and w13, and set into the register reg31 via path w75 in response to assertion of IV_WR which is selected as write enable signal reg1_wr. Next, TEXT data are set into the register reg32 via path w2 in response to assertion of TEXT_WR which is selected as write enable signal reg2_wr. Subsequently, encryption is repeated in a similar way.
Meanwhile, in OFB decryption mode, when the operation value for operation mode signals (cfb|ofb) is 1, the initial value of IV data are set into the register reg31 in response to assertion of IV_WR which is selected as write enable signal reg1_wr. Similarly, TEXT data are set in the register reg32 in response to assertion of TEXT_WR which is selected as write enable signal reg2_wr.
Then, the IV data are input to the encryption/decryption processing unit 1 via path w7 to be subjected to encryption processing therein, and data w50 corresponding to the intermediate data Di of
Then, for the next decryption of TEXT data, the aforementioned intermediate data Di is input to the OFB feedback section OFB_FB of the IV updating unit 50 via paths w50 and w13, and set into the register reg31 via path 75 in response to assertion of IV_WR which is selected as write enable signal reg1_wr. Next, TEXT data are set into the register reg32 via path w2 in response to assertion of TEXT_WR which is selected as write enable signal reg2_wr. Subsequently, decryption is repeated in a similar way.
The operations illustrated above correspond with the behavior of OFB mode described in
According to the above-described embodiments, a small encryption/decryption circuit may be provided that may support the different modes of operation defined for the DES and/or AES method. The above-described embodiments may be applied to a swap circuit for swapping TEXT data and IV data in common key block cipher and an encryption/decryption circuit including the swap circuit.
All examples and conditional language recited herein are intended for pedagogical purposes to aid the reader in understanding the invention and the concepts contributed by the inventor to furthering the art, and are to be construed as being without limitation to such specifically recited examples and conditions, nor does the organization of such examples in the specification relate to a showing of the superiority and inferiority of the invention. Although the embodiments have been described in detail, it should be understood that the various changes, substitutions, and alterations could be made hereto without departing from the spirit and scope of the invention.
Although a few preferred embodiments of the present invention have been shown and described, it would be appreciated by those skilled in the art that changes may be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
2008-279028 | Oct 2008 | JP | national |