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>
17 #include <afs/com_err.h>
25 main(int argc, char *argv[])
27 struct ktc_principal client;
28 struct ktc_encryptionKey sessionkey;
32 char ticket[MAXKTCTICKETLEN];
35 char bob[KA_TIMESTR_LEN];
38 initialize_RXK_error_table();
39 initialize_KA_error_table();
42 printf("Usage is %s key ticket\n", whoami);
45 if (ka_ReadBytes(argv[1], key, sizeof(key)) != 8)
46 printf("Key must be 8 bytes long\n");
47 if (!des_check_key_parity(key) || des_is_weak_key(key)) {
48 afs_com_err(whoami, KABADKEY, "server's key for decoding ticket is bad");
51 ticketLen = ka_ReadBytes(argv[2], ticket, sizeof(ticket));
52 printf("Ticket length is %d\n", ticketLen);
55 tkt_DecodeTicket(ticket, ticketLen, key, client.name, client.instance,
56 client.cell, &sessionkey, &host, &start, &end);
58 afs_com_err(whoami, code, "decoding ticket");
59 if (code = tkt_CheckTimes(start, end, time(0)) <= 0)
60 afs_com_err(whoami, 0, "because of start or end times");
64 if (!des_check_key_parity(&sessionkey) || des_is_weak_key(&sessionkey)) {
65 afs_com_err(whoami, KABADKEY, "checking ticket's session key");
69 ka_PrintUserID("Client is ", client.name, client.instance, 0);
70 if (strlen(client.cell))
71 printf("@%s", client.cell);
72 printf("\nSession key is ");
73 ka_PrintBytes(&sessionkey, 8);
74 ka_timestr(start, bob, KA_TIMESTR_LEN);
75 printf("\nGood from %s", bob);
76 ka_timestr(end, bob, KA_TIMESTR_LEN);
77 printf(" till %s\n", bob);