Cryptography Reference
In-Depth Information
m1[ r ][ 0 ] * m2[ 0 ][ c ] +
m1[ r ][ 1 ] * m2[ 1 ][ c ] +
m1[ r ][ 2 ] * m2[ 2 ][ c ] +
m1[ r ][ 3 ] * m2[ 3 ][ c ];
}
}
}
As you can see, each element of the target matrix becomes the sum of the
rows of the fi rst matrix multiplied by the columns of the second. As long as
the fi rst matrix has as many rows as the second has columns, two matrices can
be multiplied this way. This code can be made even more general to deal with
arbitrarily sized matrices, but C's multidimensional array syntax makes that
tricky, and you won't need it for AES.
If you multiply something, there ought to be a way to unmultiply (t hat is,
divide) it. And certainly if you're using this in an encryption operation you need
a well-defi ned way to undo it. Matrix division is not as clear-cut as matrix mul-
tiplication, however. To undo a matrix multiplication, you must fi nd a matrix's
inverse . This is another matrix which, when multiplied, as defi ned above, will
yield the identity matrix :
01 00 00 00
00 01 00 00
00 00 01 00
00 00 00 01
If you look back at the way matrix multiplication was defi ned, you can see
why it's called the identity matrix. If you multiply this with any other (four-row)
matrix, you get back the same matrix. This is analogous to the case of multiply-
ing a number by 1 — when you multiply any number by the number 1 you get
back the same number.
The problem with the standard matrix operations, as they pertain to encryp-
tion, is that the inversion of the matrix above is:
0.1143
0.0857
0.3143
0.4857
02 03 01 01
01 02 03 01
01 01 02 03
03 01 01 02
0.4857
0.1143
0.0857
0.3143
0.3143
0.4857
0.1143
0.0857
0.0857
0.3143
0.4857
0.1143
As you can imagine, multiplying by this inverted matrix to decrypt would
be terribly slow, and the inclusion of fl oating point operations would introduce
round-off errors as well. To speed things up, and still allow for invertible matrices,
Search WWH ::




Custom Search