1 /* ccache.h --- Read MIT style Kerberos Credential Cache file. 2 * Copyright (C) 2006-2013 Simon Josefsson 3 * 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 3 of the License, 7 * or (at your option) any later version. 8 * 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. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this file; if not, see http://www.gnu.org/licenses or 16 * write to the Free Software Foundation, Inc., 51 Franklin Street, 17 * Fifth Floor, Boston, MA 02110-1301, USA 18 * 19 */ 20 21 #ifndef CCACHE_H 22 #define CCACHE_H 1 23 24 #include <stdint.h> 25 #include <string.h> 26 27 #define CCACHE_MAX_COMPONENTS 5 28 #define CCACHE_MAX_KEYLEN 32 29 30 struct ccache_header 31 { 32 uint16_t tag; 33 uint16_t taglen; 34 char *tagdata; 35 }; 36 37 struct ccache_buffer 38 { 39 uint32_t length; 40 char *data; 41 }; 42 43 struct ccache_principal 44 { 45 uint32_t name_type; 46 uint32_t num_components; 47 struct ccache_buffer realm; 48 struct ccache_buffer components[CCACHE_MAX_COMPONENTS]; 49 }; 50 51 struct ccache_keyblock 52 { 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. */ 59 }; 60 61 struct ccache_credential 62 { 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; 74 }; 75 76 struct ccache 77 { 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; 84 }; 85 86 extern int ccache_parse (const char *data, size_t length, struct ccache *out); 87 88 extern int ccache_parse_credential (const char *data, size_t len, 89 struct ccache_credential *out, 90 size_t * n); 91 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); 95 96 extern void ccache_print (struct ccache *ccache); 97 extern void ccache_print_principal (struct ccache_principal *princ); 98 extern void ccache_print_credential (struct ccache_credential *cred); 99 100 #endif /* CCACHE_H */ 101