2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 #include <hcrypto/des.h>
17 #include <afs/com_err.h>
26 main(int argc, char *argv[])
28 struct ktc_principal client;
29 struct ktc_encryptionKey sessionkey;
33 char ticket[MAXKTCTICKETLEN];
36 char bob[KA_TIMESTR_LEN];
39 initialize_RXK_error_table();
40 initialize_KA_error_table();
43 printf("Usage is %s key ticket\n", whoami);
46 if (ka_ReadBytes(argv[1], key, sizeof(key)) != 8)
47 printf("Key must be 8 bytes long\n");
48 if (!DES_check_key_parity(charptr_to_cblock(key)) || DES_is_weak_key(charptr_to_cblock(key))) {
49 afs_com_err(whoami, KABADKEY, "server's key for decoding ticket is bad");
52 ticketLen = ka_ReadBytes(argv[2], ticket, sizeof(ticket));
53 printf("Ticket length is %d\n", ticketLen);
56 tkt_DecodeTicket(ticket, ticketLen, key, client.name, client.instance,
57 client.cell, &sessionkey, &host, &start, &end);
59 afs_com_err(whoami, code, "decoding ticket");
60 if (code = tkt_CheckTimes(start, end, time(0)) <= 0)
61 afs_com_err(whoami, 0, "because of start or end times");
65 if (!des_check_key_parity(&sessionkey) || des_is_weak_key(&sessionkey)) {
66 afs_com_err(whoami, KABADKEY, "checking ticket's session key");
70 ka_PrintUserID("Client is ", client.name, client.instance, 0);
71 if (strlen(client.cell))
72 printf("@%s", client.cell);
73 printf("\nSession key is ");
74 ka_PrintBytes(&sessionkey, 8);
75 ka_timestr(start, bob, KA_TIMESTR_LEN);
76 printf("\nGood from %s", bob);
77 ka_timestr(end, bob, KA_TIMESTR_LEN);
78 printf(" till %s\n", bob);