1 /* rijndael.c --- Shishi AES crypto self tests.
2 * Copyright (C) 2002, 2003, 2004 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 #define KEY "chicken teriyaki"
27 #define IN "I would like the General Gau's Chicken, please, and wonton soup."
28 #define ZERO "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
46 "\xc6\x35\x35\x68\xf2\xbf\x8c\xb4\xd8\xa5\x80\x36\x2d\xa7\xff\x7f\x97",
47 17, "\xc6\x35\x35\x68\xf2\xbf\x8c\xb4\xd8\xa5\x80\x36\x2d\xa7\xff\x7f"},
52 "\xfc\x00\x78\x3e\x0e\xfd\xb2\xc1\xd4\x45\xd4\xc8\xef\xf7\xed\x22"
53 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5", 31,
54 "\xfc\x00\x78\x3e\x0e\xfd\xb2\xc1\xd4\x45\xd4\xc8\xef\xf7\xed\x22"},
59 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
60 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84",
61 32, "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"},
66 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
67 "\xb3\xff\xfd\x94\x0c\x16\xa1\x8c\x1b\x55\x49\xd2\xf8\x38\x02\x9e"
68 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5", 47,
69 "\xb3\xff\xfd\x94\x0c\x16\xa1\x8c\x1b\x55\x49\xd2\xf8\x38\x02\x9e"},
74 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
75 "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8"
76 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8",
77 48, "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8"},
82 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
83 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
84 "\x48\x07\xef\xe8\x36\xee\x89\xa5\x26\x73\x0d\xbc\x2f\x7b\xc8\x40"
85 "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8",
86 64, "\x48\x07\xef\xe8\x36\xee\x89\xa5\x26\x73\x0d\xbc\x2f\x7b\xc8\x40"}
90 test (Shishi
* handle
)
97 shishi_cfg (handle
, strdup ("verbose-crypto"));
99 for (i
= 0; i
< sizeof (tv
) / sizeof (tv
[0]); i
++)
101 err
= shishi_aes_cts (handle
, 0,
102 tv
[i
].key
, tv
[i
].keylen
,
103 tv
[i
].iv
, &ivout
, tv
[i
].in
, tv
[i
].inlen
, &out
);
108 hexprint (tv
[i
].in
, tv
[i
].inlen
);
109 printf ("output:\n");
110 hexprint (out
, tv
[i
].inlen
);
111 if (memcmp (out
, tv
[i
].out
, tv
[i
].outlen
) != 0)
113 printf ("expected output:\n");
114 hexprint (tv
[i
].out
, tv
[i
].outlen
);
116 printf ("iv out:\n");
117 hexprint (ivout
, IVLEN
);
118 if (memcmp (ivout
, tv
[i
].nextiv
, IVLEN
) != 0)
120 printf ("expected iv out:\n");
121 hexprint (tv
[i
].nextiv
, IVLEN
);
126 fail ("shishi_aes_cts(%d) failed: %d\n", i
, err
);
129 if (memcmp (out
, tv
[i
].out
, tv
[i
].outlen
) == 0)
130 success ("shishi_aes_cts(%d) OK\n", i
);
132 fail ("shishi_aes_cts(%d) failure\n", i
);
134 if (memcmp (ivout
, tv
[i
].nextiv
, IVLEN
) == 0)
135 success ("shishi_aes_cts(%d) IV OK\n", i
);
137 fail ("shishi_aes_cts(%d) failure IV\n", i
);