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>
14 #include <hcrypto/des.h>
15 #include <afs/com_err.h>
23 main(int argc, char *argv[])
25 struct ktc_principal client;
26 struct ktc_encryptionKey sessionkey;
30 char ticket[MAXKTCTICKETLEN];
33 char bob[KA_TIMESTR_LEN];
36 initialize_RXK_error_table();
37 initialize_KA_error_table();
40 printf("Usage is %s key ticket\n", whoami);
43 if (ka_ReadBytes(argv[1], key, sizeof(key)) != 8)
44 printf("Key must be 8 bytes long\n");
45 if (!DES_check_key_parity(charptr_to_cblock(key)) || DES_is_weak_key(charptr_to_cblock(key))) {
46 afs_com_err(whoami, KABADKEY, "server's key for decoding ticket is bad");
49 ticketLen = ka_ReadBytes(argv[2], ticket, sizeof(ticket));
50 printf("Ticket length is %d\n", ticketLen);
53 tkt_DecodeTicket(ticket, ticketLen, key, client.name, client.instance,
54 client.cell, &sessionkey, &host, &start, &end);
56 afs_com_err(whoami, code, "decoding ticket");
57 if (code = tkt_CheckTimes(start, end, time(0)) <= 0)
58 afs_com_err(whoami, 0, "because of start or end times");
62 if (!des_check_key_parity(&sessionkey) || des_is_weak_key(&sessionkey)) {
63 afs_com_err(whoami, KABADKEY, "checking ticket's session key");
67 ka_PrintUserID("Client is ", client.name, client.instance, 0);
68 if (strlen(client.cell))
69 printf("@%s", client.cell);
70 printf("\nSession key is ");
71 ka_PrintBytes(&sessionkey, 8);
72 ka_timestr(start, bob, KA_TIMESTR_LEN);
73 printf("\nGood from %s", bob);
74 ka_timestr(end, bob, KA_TIMESTR_LEN);
75 printf(" till %s\n", bob);