Cryptography Reference
In-Depth Information
4.4.2.5 The Known Answer Tests
Next, in order to test the AES implementation, we introduce the “Known Answer
Tests” of [12] and we begin with the variable text test which consists of encrypting
a sequence of plaintexts using a fixed key. Since the plaintext and the key are pre-
determined, the input of this test is simply the key length (in order to choose among
three possible keys of different lengths) but, as the output is too long to be printed
here, we introduce an additional input parameter len that allows specification of the
number of ciphertext blocks to be printed. The function that implements this test is
the following:
> VarTxtTest := proc(keylength::{128, 192, 256}, len := keylength)
local i, t;
for i to len do
t := ListTools:-Reverse(convert([0$(128-i), 1$i], base, 2, 256));
printf("%s|%s\n", bytestohexstring(t),
bytestohexstring(AES([0$(iquo(keylength,8))],t)))
end do;
printf("\n")
end proc:
Example 4.3 We print the first eight ciphertext blocks obtained with a 256-bit key.
The output can be compared to that appearing in [12]:
> VarTxtTest(256, 8);
80000000000000000000000000000000|ddc6bf790c15760d8d9aeb6f9a75fd4e
c0000000000000000000000000000000|0a6bdc6d4c1e6280301fd8e97ddbe601
e0000000000000000000000000000000|9b80eefb7ebe2d2b16247aa0efc72f5d
f0000000000000000000000000000000|7f2c5ece07a98d8bee13c51177395ff7
f8000000000000000000000000000000|7818d800dcf6f4be1e0e94f403d1e4c2
fc000000000000000000000000000000|e74cd1c92f0919c35a0324123d6177d3
fe000000000000000000000000000000|8092a4dcf2da7e77e93bdd371dfed82e
ff000000000000000000000000000000|49af6b372135acef10132e548f217b17
Next, we introduce the variable key test, which is very similar to the preceding
one, except that now the plaintext is fixed and the key varies.
> VarKeyTest := proc(keylength::{128, 192, 256}, len := keylength)
local i, k;
for i to len do
k := ListTools:-Reverse(convert([0$(keylength-i), 1$i], base, 2, 256));
printf("%s|%s\n", bytestohexstring(k), bytestohexstring(AES(k, [0$16])))
end do;
printf("\n")
end proc:
Example 4.4 The output corresponding to the first 8 keys in the 192-bit
VarKeyTest is the following (compare with [12]):
> VarKeyTest(192, 8);
800000000000000000000000000000000000000000000000|de885dc87f5a92594082d02cc1e1b42c
c00000000000000000000000000000000000000000000000|132b074e80f2a597bf5febd8ea5da55e
e00000000000000000000000000000000000000000000000|6eccedf8de592c22fb81347b79f2db1f
f00000000000000000000000000000000000000000000000|180b09f267c45145db2f826c2582d35c
f80000000000000000000000000000000000000000000000|edd807ef7652d7eb0e13c8b5e15b3bc0
fc0000000000000000000000000000000000000000000000|9978bcf8dd8fd72241223ad24b31b8a4
fe0000000000000000000000000000000000000000000000|5310f654343e8f27e12c83a48d24ff81
ff0000000000000000000000000000000000000000000000|833f71258d53036b02952c76c744f5a1
 
Search WWH ::




Custom Search