Patent ID: 7236593

Claim:
An apparatus for performing a byte substitution operation (SubBytes) and an inverse byte substitution operation (InvSubBytes) selectively on an input data code so as to output a required output data code, capable of use in encryption and decryption of advanced encryption standard (AES), the apparatus comprising: an inverse matrix operation module for receiving the input data code so as to perform an inverse matrix operation on the input data code and output the result of the inverse matrix operation; a first multiplexer having a first input terminal and a second input terminal, the first input terminal being coupled to the inverse matrix operation module so as to receive the result of the inverse matrix operation and the second input terminal receiving the input data code, wherein the first multiplexer selects one of the input data code and the result of the inverse matrix operation as the first multiplexer's output data code, according to a selection signal; a multiplicative inverse operation module coupled to the first multiplexer for outputting a table-lookup data code based on the output data code from the first multiplexer after table-look up; a matrix operation module for receiving the table-lookup data code, performing a matrix operation, and outputting the result of the matrix operation; and a second multiplexer having a first terminal and a second terminal, the second terminal of the second multiplexer being coupled to the matrix operation module so as to receive the result of the matrix operation and the first terminal of the second multiplexer being coupled to the multiplicative inverse operation module so as to receive the table-lookup data code, wherein the second multiplexer selects one of the table-lookup data code and the result of the matrix operation as the second multiplexer's output data code, according to the selection signal, and wherein the output data code from the second multiplexer is the required output data code for the apparatus.