3 * $Id: storin-tests.c,v 1.1 2000/05/21 11:28:30 mdw Exp $
5 * Generate test vectors for Storin
7 * (c) 2000 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * Copyright (c) 2000 Mark Wooding
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
22 * 2, Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
26 * 3. The name of the authors may not be used to endorse or promote
27 * products derived from this software without specific prior written
30 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
33 * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
34 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
38 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
42 * Instead of accepting the above terms, you may redistribute and/or modify
43 * this software under the terms of either the GNU General Public License,
44 * or the GNU Library General Public License, published by the Free
45 * Software Foundation; either version 2 of the License, or (at your
46 * option) any later version.
49 /*----- Revision history --------------------------------------------------*
51 * $Log: storin-tests.c,v $
52 * Revision 1.1 2000/05/21 11:28:30 mdw
57 /*----- Header files ------------------------------------------------------*/
66 /*----- Main code ---------------------------------------------------------*/
70 uint24 k[8], p[4], c[4], pp[4];
75 fibrand_lcseed(&r, 0);
78 # Test vectors for Storin [generated]\n\
80 # In each entry, the key comes first, followed by the plaintext and\n\
86 for (i = 1; i < 8; i++) {
88 /* --- Initial plaintext value --- */
90 for (j = 0; j < i; j++)
92 for (j = 0; j < 4; j++)
94 storin_init24(&s, k, i);
95 storin_eblk24(&s, p, c);
96 storin_dblk24(&s, c, pp);
97 fputs("\n ", stdout); for (j = 0; j < i; j++) printf("%06x", k[j]);
98 fputs("\n ", stdout); for (j = 0; j < 4; j++) printf("%06x", p[j]);
99 fputc(' ', stdout); for (j = 0; j < 4; j++) printf("%06x", c[j]);
100 fputs(";\n", stdout);
101 for (j = 0; j < 4; j++) {
103 fputs("*** decryption failure\n", stderr);
108 /* --- Random tests --- */
110 for (ii = 1; ii < 16; ii++) {
111 for (j = 0; j < i; j++)
112 k[j] = U24(fibrand_step(&r));
113 for (j = 0; j < 4; j++)
114 p[j] = U24(fibrand_step(&r));
115 storin_init24(&s, k, i);
116 storin_eblk24(&s, p, c);
117 fputs("\n ", stdout); for (j = 0; j < i; j++) printf("%06x", k[j]);
118 fputs("\n ", stdout); for (j = 0; j < 4; j++) printf("%06x", p[j]);
119 fputc(' ', stdout); for (j = 0; j < 4; j++) printf("%06x", c[j]);
120 fputs(";\n", stdout);
124 fputs("}\n", stdout);
128 /*----- That's all, folks -------------------------------------------------*/