4 * Copyright (C) 2004, 2009 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. Furthermore if you modify this software you must label
20 * your software as modified software and not distribute it in such a
21 * fashion that it might be confused with the original M.I.T. software.
22 * M.I.T. makes no representations about the suitability of
23 * this software for any purpose. It is provided "as is" without express
24 * or implied warranty.
26 * This file contains tests for theKRB-FX-CF2 code in Kerberos, based
27 *on the PRF regression tests. It reads an input file, and writes an
28 *output file. It is assumed that the output file will be diffed
29 *against expected output to see whether regression tests pass. The
30 *input file is a very primitive format.
32 *second line: key to pass to string2key; also used as salt
33 *Third line: second key to pass to string2key
36 *scanf is used to read the file, so interior spaces are not permitted. The program outputs the hex bytes of the key.
45 char pepper1[1024], pepper2[1024];
46 krb5_keyblock *k1 = NULL, *k2 = NULL, *out = NULL;
53 if (scanf( "%d", &enctype) == EOF)
55 if (scanf("%1024s", &s[0]) == EOF)
57 assert (krb5_init_keyblock(0, enctype, 0, &k1) == 0);
59 s2k.length = strlen(s);
60 assert(krb5_c_string_to_key (0, enctype, &s2k, &s2k, k1) == 0);
61 if (scanf("%1024s", &s[0]) == EOF)
63 assert (krb5_init_keyblock(0, enctype, 0, &k2) == 0);
65 s2k.length = strlen(s);
66 assert(krb5_c_string_to_key (0, enctype, &s2k, &s2k, k2) == 0);
67 if (scanf("%1024s %1024s", pepper1, pepper2) == EOF)
69 assert(krb5_c_fx_cf2_simple(0, k1, pepper1,
70 k2, pepper2, &out) ==0);
74 (unsigned int) ((unsigned char) out->contents[out->length-i]));
78 krb5_free_keyblock(0,out);
81 krb5_free_keyblock(0, k1);
83 krb5_free_keyblock(0, k2);