Version 2.1.
[krb5dissect.git] / ccache.h
blob67065e1976df15e228949015aee83d7204a3b6f9
1 /* ccache.h --- Read/write MIT style Kerberos Credential Cache file.
2 * Copyright (C) 2006, 2007 Simon Josefsson
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This file is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this file; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA
21 #ifndef CCACHE_H
22 #define CCACHE_H 1
24 #include <stdint.h>
25 #include <string.h>
27 #define CCACHE_MAX_COMPONENTS 5
28 #define CCACHE_MAX_KEYLEN 32
30 struct ccache_header
32 uint16_t tag;
33 uint16_t taglen;
34 char *tagdata;
37 struct ccache_buffer
39 uint32_t length;
40 char *data;
43 struct ccache_principal
45 uint32_t name_type;
46 uint32_t num_components;
47 struct ccache_buffer realm;
48 struct ccache_buffer components[CCACHE_MAX_COMPONENTS];
51 struct ccache_keyblock
53 uint16_t keytype;
54 uint16_t etype;
55 uint16_t keylen;
56 char *keyvalue;
57 char storage[CCACHE_MAX_KEYLEN]; /* usable by caller for storing
58 keys that keyvalue point to. */
61 struct ccache_credential
63 struct ccache_principal client;
64 struct ccache_principal server;
65 struct ccache_keyblock key;
66 uint32_t authtime;
67 uint32_t starttime;
68 uint32_t endtime;
69 uint32_t renew_till;
70 uint8_t is_skey;
71 uint32_t tktflags;
72 struct ccache_buffer ticket;
73 struct ccache_buffer second_ticket;
76 struct ccache
78 uint16_t file_format_version;
79 uint16_t headerlen;
80 char *header;
81 struct ccache_principal default_principal;
82 size_t credentialslen;
83 char *credentials;
86 extern int ccache_parse (const char *data, size_t length, struct ccache *out);
88 extern int ccache_parse_credential (const char *data, size_t len,
89 struct ccache_credential *out,
90 size_t * n);
92 extern int ccache_pack (struct ccache *info, char *data, size_t *len);
93 extern int ccache_pack_credential (struct ccache_credential *cred,
94 char *out, size_t *len);
96 #ifdef ENABLE_PRINT
97 extern void ccache_print (struct ccache *ccache);
98 extern void ccache_print_principal (struct ccache_principal *princ);
99 extern void ccache_print_credential (struct ccache_credential *cred);
100 #endif
102 #endif /* CCACHE_H */