[2854] in cryptography@c2.net mail archive
KEA key formation
daemon@ATHENA.MIT.EDU (Colin Plumb)
Thu Jun 25 14:35:39 1998
Date: Thu, 25 Jun 1998 08:00:39 -0600 (MDT)
From: Colin Plumb <colin@nyx.net>
To: cryptography@c2.net
I was looking for some more Skipjack test vectors when I noticed that
the last stage of the KEA does Skipjack encryptions.
So I coded up a quick implementation of the key formation algorithm
that is described and plugged in the data from sections III.B and III.C
of the test vector annex.
The result? Bleah. No joy. It doesn't work.
I'm getting:
v1 = 95 b8 c6 e7 76 e0 ca e7 34 f0
v2 = 99 cc fe 2b 90 fd 55 0b 44 71
pad = 72 f1 a8 7e 92 82 41 98 ab 0b
v1 XOR pad = e7 49 6e 99 e4 62 8b 7f 9f fb
key = 24 c9 0c b0 5d 66 8b 27 24 d6
v1 = 97 3b 5c a2 55 8c 14 69 76 9b
v2 = b7 1c b0 d0 09 af 27 65 9f 7c
pad = 72 f1 a8 7e 92 82 41 98 ab 0b
v1 XOR pad = e5 ca f4 dc c7 0e 55 f1 dd 90
key = fe e7 78 a8 38 a6 01 cd fb 88
This is not making me very happy. Does anyone else have different results?
static void
keyform(uint8 const v[20], uint8 out[10])
{
static uint8 const pad[10] = {
0x72, 0xf1, 0xa8, 0x7e, 0x92, 0x82, 0x41, 0x98, 0xab, 0x0b };
uint8 tkey[10];
int i;
for (i = 0; i < 10; i++) {
tkey[i] = v[i] ^ pad[i];
printf(" %02x", tkey[i]);
}
putchar('\n');
memcpy(out, v+10, 10);
encrypt(out, tkey);
out[8] ^= out[0];
out[9] ^= out[1];
encrypt(out, tkey);
memset(tkey, 0, sizeof(tkey));
}
#include <time.h>
int
main(void)
{
static uint8 const key[10] =
{ 0x00, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11 };
static uint8 const plain[8] =
{ 0x33, 0x22, 0x11, 0x00, 0xdd, 0xcc, 0xbb, 0xaa };
static uint8 const va[20] = {
0x95, 0xb8, 0xc6, 0xe7, 0x76, 0xe0, 0xca, 0xe7, 0x34, 0xf0,
0x99, 0xcc, 0xfe, 0x2b, 0x90, 0xfd, 0x55, 0x0b, 0x44, 0x71 };
static uint8 const vb[20] = {
0x97, 0x3b, 0x5c, 0xa2, 0x55, 0x8c, 0x14, 0x69, 0x76, 0x9b,
0xb7, 0x1c, 0xb0, 0xd0, 0x09, 0xaf, 0x27, 0x65, 0x9f, 0x7c };
uint8 cipher[10];
int i;
clock_t t0, t1;
keyform(va, cipher);
for (i = 0; i < 10; i++)
printf(" %02x", cipher[i]);
putchar('\n');
keyform(vb, cipher);
for (i = 0; i < 10; i++)
printf(" %02x", cipher[i]);
putchar('\n');
memcpy(cipher, plain, 8);
for (i = 0; i < 8; i++)
printf(" %02x", cipher[i]);
putchar('\n');
t0 = clock();
// for (i =0; i < 1<<17; i++)
encrypt(cipher, key);
t1 = clock();
printf("encrypt time: %lu ticks\n", t1 - t0);
for (i = 0; i < 8; i++)
printf(" %02x", cipher[i]);
putchar('\n');
t0 = clock();
// for (i =0; i < 1<<17; i++)
decrypt(cipher, key);
t1 = clock();
printf("decrypt time: %lu ticks\n", t1 - t0);
for (i = 0; i < 8; i++)
printf(" %02x", cipher[i]);
putchar('\n');
return 0;
}