xref: /freebsd/crypto/heimdal/lib/krb5/test_pac.c (revision fcb560670601b2a4d87bb31d7531c8dcc37ee71b)
1 /*
2  * Copyright (c) 2006 Kungliga Tekniska Högskolan
3  * (Royal Institute of Technology, Stockholm, Sweden).
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the Institute nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 
34 #include "krb5_locl.h"
35 
36 /*
37  * This PAC and keys are copied (with permission) from Samba torture
38  * regression test suite, they where created by Andrew Bartlet.
39  */
40 
41 static const unsigned char saved_pac[] = {
42 	0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd8, 0x01, 0x00, 0x00,
43 	0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
44 	0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
45 	0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
46 	0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x08, 0x00, 0xcc, 0xcc, 0xcc, 0xcc,
47 	0xc8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x30, 0xdf, 0xa6, 0xcb,
48 	0x4f, 0x7d, 0xc5, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff,
49 	0xff, 0xff, 0xff, 0x7f, 0xc0, 0x3c, 0x4e, 0x59, 0x62, 0x73, 0xc5, 0x01, 0xc0, 0x3c, 0x4e, 0x59,
50 	0x62, 0x73, 0xc5, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x16, 0x00, 0x16, 0x00,
51 	0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
52 	0x0c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
53 	0x14, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x02, 0x00, 0x65, 0x00, 0x00, 0x00,
54 	0xed, 0x03, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, 0x00,
55 	0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 	0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x16, 0x00, 0x20, 0x00, 0x02, 0x00, 0x16, 0x00, 0x18, 0x00,
57 	0x24, 0x00, 0x02, 0x00, 0x28, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 	0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 	0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 	0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
62 	0x57, 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x33, 0x00, 0x46, 0x00, 0x49, 0x00, 0x4e, 0x00,
63 	0x41, 0x00, 0x4c, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
67 	0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
68 	0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x57, 0x00, 0x32, 0x00,
69 	0x30, 0x00, 0x30, 0x00, 0x33, 0x00, 0x46, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x41, 0x00, 0x4c, 0x00,
70 	0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x57, 0x00, 0x49, 0x00,
71 	0x4e, 0x00, 0x32, 0x00, 0x4b, 0x00, 0x33, 0x00, 0x54, 0x00, 0x48, 0x00, 0x49, 0x00, 0x4e, 0x00,
72 	0x4b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
73 	0x15, 0x00, 0x00, 0x00, 0x11, 0x2f, 0xaf, 0xb5, 0x90, 0x04, 0x1b, 0xec, 0x50, 0x3b, 0xec, 0xdc,
74 	0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
75 	0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 	0x80, 0x66, 0x28, 0xea, 0x37, 0x80, 0xc5, 0x01, 0x16, 0x00, 0x77, 0x00, 0x32, 0x00, 0x30, 0x00,
77 	0x30, 0x00, 0x33, 0x00, 0x66, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x24, 0x00,
78 	0x76, 0xff, 0xff, 0xff, 0x37, 0xd5, 0xb0, 0xf7, 0x24, 0xf0, 0xd6, 0xd4, 0xec, 0x09, 0x86, 0x5a,
79 	0xa0, 0xe8, 0xc3, 0xa9, 0x00, 0x00, 0x00, 0x00, 0x76, 0xff, 0xff, 0xff, 0xb4, 0xd8, 0xb8, 0xfe,
80 	0x83, 0xb3, 0x13, 0x3f, 0xfc, 0x5c, 0x41, 0xad, 0xe2, 0x64, 0x83, 0xe0, 0x00, 0x00, 0x00, 0x00
81 };
82 
83 static int type_1_length = 472;
84 
85 static const krb5_keyblock kdc_keyblock = {
86     ETYPE_ARCFOUR_HMAC_MD5,
87     { 16, "\xB2\x86\x75\x71\x48\xAF\x7F\xD2\x52\xC5\x36\x03\xA1\x50\xB7\xE7" }
88 };
89 
90 static const krb5_keyblock member_keyblock = {
91     ETYPE_ARCFOUR_HMAC_MD5,
92     { 16, "\xD2\x17\xFA\xEA\xE5\xE6\xB5\xF9\x5C\xCC\x94\x07\x7A\xB8\xA5\xFC" }
93 };
94 
95 static time_t authtime = 1120440609;
96 static const char *user = "w2003final$";
97 
98 /*
99  * This pac from Christan Krause
100  */
101 
102 static const unsigned char saved_pac2[] =
103     "\x05\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\xc8\x01\x00\x00"
104     "\x58\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x18\x00\x00\x00"
105     "\x20\x02\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x70\x00\x00\x00"
106     "\x38\x02\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x14\x00\x00\x00"
107     "\xa8\x02\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x14\x00\x00\x00"
108     "\xc0\x02\x00\x00\x00\x00\x00\x00\x01\x10\x08\x00\xcc\xcc\xcc\xcc"
109     "\xb8\x01\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x7d\xee\x09\x76"
110     "\xf2\x39\xc9\x01\xff\xff\xff\xff\xff\xff\xff\x7f\xff\xff\xff\xff"
111     "\xff\xff\xff\x7f\x6d\x49\x38\x62\xf2\x39\xc9\x01\x6d\x09\xa2\x8c"
112     "\xbb\x3a\xc9\x01\xff\xff\xff\xff\xff\xff\xff\x7f\x0e\x00\x0e\x00"
113     "\x04\x00\x02\x00\x10\x00\x10\x00\x08\x00\x02\x00\x00\x00\x00\x00"
114     "\x0c\x00\x02\x00\x00\x00\x00\x00\x10\x00\x02\x00\x00\x00\x00\x00"
115     "\x14\x00\x02\x00\x00\x00\x00\x00\x18\x00\x02\x00\x02\x01\x00\x00"
116     "\x52\x04\x00\x00\x01\x02\x00\x00\x03\x00\x00\x00\x1c\x00\x02\x00"
117     "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
118     "\x00\x00\x00\x00\x10\x00\x12\x00\x20\x00\x02\x00\x0e\x00\x10\x00"
119     "\x24\x00\x02\x00\x28\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00"
120     "\x10\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
121     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
122     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
123     "\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00"
124     "\x6f\x00\x70\x00\x65\x00\x6e\x00\x6d\x00\x73\x00\x70\x00\x00\x00"
125     "\x08\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x6f\x00\x70\x00"
126     "\x65\x00\x6e\x00\x20\x00\x6d\x00\x73\x00\x70\x00\x00\x00\x00\x00"
127     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
128     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
129     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00"
130     "\x60\x04\x00\x00\x07\x00\x00\x00\x01\x02\x00\x00\x07\x00\x00\x00"
131     "\x5e\x04\x00\x00\x07\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00"
132     "\x08\x00\x00\x00\x43\x00\x48\x00\x4b\x00\x52\x00\x2d\x00\x41\x00"
133     "\x44\x00\x53\x00\x08\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00"
134     "\x4d\x00\x53\x00\x50\x00\x2d\x00\x41\x00\x44\x00\x53\x00\x00\x00"
135     "\x04\x00\x00\x00\x01\x04\x00\x00\x00\x00\x00\x05\x15\x00\x00\x00"
136     "\x91\xad\xdc\x4c\x63\xb8\xb5\x48\xd5\x53\xd2\xd1\x00\x00\x00\x00"
137     "\x00\x66\xeb\x75\xf2\x39\xc9\x01\x0e\x00\x6f\x00\x70\x00\x65\x00"
138     "\x6e\x00\x6d\x00\x73\x00\x70\x00\x38\x00\x10\x00\x28\x00\x48\x00"
139     "\x00\x00\x00\x00\x00\x00\x00\x00\x6f\x00\x70\x00\x65\x00\x6e\x00"
140     "\x6d\x00\x73\x00\x70\x00\x40\x00\x6d\x00\x73\x00\x70\x00\x2d\x00"
141     "\x61\x00\x64\x00\x73\x00\x2e\x00\x70\x00\x65\x00\x70\x00\x70\x00"
142     "\x65\x00\x72\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x64\x00\x65\x00"
143     "\x4d\x00\x53\x00\x50\x00\x2d\x00\x41\x00\x44\x00\x53\x00\x2e\x00"
144     "\x50\x00\x45\x00\x50\x00\x50\x00\x45\x00\x52\x00\x43\x00\x4f\x00"
145     "\x4e\x00\x2e\x00\x44\x00\x45\x00\x76\xff\xff\xff\xb3\x56\x15\x29"
146     "\x37\xc6\x5c\xf7\x97\x35\xfa\xec\x59\xe8\x96\xa0\x00\x00\x00\x00"
147     "\x76\xff\xff\xff\x50\x71\xa2\xb1\xa3\x64\x82\x5c\xfd\x23\xea\x3b"
148     "\xb0\x19\x12\xd4\x00\x00\x00\x00";
149 
150 
151 static const krb5_keyblock member_keyblock2 = {
152     ETYPE_DES_CBC_MD5,
153     { 8, "\x9e\x37\x83\x25\x4a\x7f\xf2\xf8" }
154 };
155 
156 static time_t authtime2 = 1225304188;
157 static const char *user2 = "openmsp";
158 
159 
160 
161 int
162 main(int argc, char **argv)
163 {
164     krb5_error_code ret;
165     krb5_context context;
166     krb5_pac pac;
167     krb5_data data;
168     krb5_principal p, p2;
169 
170     ret = krb5_init_context(&context);
171     if (ret)
172 	errx(1, "krb5_init_contex");
173 
174     krb5_enctype_enable(context, ETYPE_DES_CBC_MD5);
175 
176     ret = krb5_parse_name_flags(context, user,
177 				KRB5_PRINCIPAL_PARSE_NO_REALM, &p);
178     if (ret)
179 	krb5_err(context, 1, ret, "krb5_parse_name");
180 
181     ret = krb5_pac_parse(context, saved_pac, sizeof(saved_pac), &pac);
182     if (ret)
183 	krb5_err(context, 1, ret, "krb5_pac_parse");
184 
185     ret = krb5_pac_verify(context, pac, authtime, p,
186 			   &member_keyblock, &kdc_keyblock);
187     if (ret)
188 	krb5_err(context, 1, ret, "krb5_pac_verify");
189 
190     ret = _krb5_pac_sign(context, pac, authtime, p,
191 			 &member_keyblock, &kdc_keyblock, &data);
192     if (ret)
193 	krb5_err(context, 1, ret, "_krb5_pac_sign");
194 
195     krb5_pac_free(context, pac);
196 
197     ret = krb5_pac_parse(context, data.data, data.length, &pac);
198     krb5_data_free(&data);
199     if (ret)
200 	krb5_err(context, 1, ret, "krb5_pac_parse 2");
201 
202     ret = krb5_pac_verify(context, pac, authtime, p,
203 			   &member_keyblock, &kdc_keyblock);
204     if (ret)
205 	krb5_err(context, 1, ret, "krb5_pac_verify 2");
206 
207     /* make a copy and try to reproduce it */
208     {
209 	uint32_t *list;
210 	size_t len, i;
211 	krb5_pac pac2;
212 
213 	ret = krb5_pac_init(context, &pac2);
214 	if (ret)
215 	    krb5_err(context, 1, ret, "krb5_pac_init");
216 
217 	/* our two user buffer plus the three "system" buffers */
218 	ret = krb5_pac_get_types(context, pac, &len, &list);
219 	if (ret)
220 	    krb5_err(context, 1, ret, "krb5_pac_get_types");
221 
222 	for (i = 0; i < len; i++) {
223 	    /* skip server_cksum, privsvr_cksum, and logon_name */
224 	    if (list[i] == 6 || list[i] == 7 || list[i] == 10)
225 		continue;
226 
227 	    ret = krb5_pac_get_buffer(context, pac, list[i], &data);
228 	    if (ret)
229 		krb5_err(context, 1, ret, "krb5_pac_get_buffer");
230 
231 	    if (list[i] == 1) {
232 		if (type_1_length != data.length)
233 		    krb5_errx(context, 1, "type 1 have wrong length: %lu",
234 			      (unsigned long)data.length);
235 	    } else
236 		krb5_errx(context, 1, "unknown type %lu",
237 			  (unsigned long)list[i]);
238 
239 	    ret = krb5_pac_add_buffer(context, pac2, list[i], &data);
240 	    if (ret)
241 		krb5_err(context, 1, ret, "krb5_pac_add_buffer");
242 	    krb5_data_free(&data);
243 	}
244 	free(list);
245 
246 	ret = _krb5_pac_sign(context, pac2, authtime, p,
247 			     &member_keyblock, &kdc_keyblock, &data);
248 	if (ret)
249 	    krb5_err(context, 1, ret, "_krb5_pac_sign 4");
250 
251 	krb5_pac_free(context, pac2);
252 
253 	ret = krb5_pac_parse(context, data.data, data.length, &pac2);
254 	krb5_data_free(&data);
255 	if (ret)
256 	    krb5_err(context, 1, ret, "krb5_pac_parse 4");
257 
258 	ret = krb5_pac_verify(context, pac2, authtime, p,
259 			      &member_keyblock, &kdc_keyblock);
260 	if (ret)
261 	    krb5_err(context, 1, ret, "krb5_pac_verify 4");
262 
263 	krb5_pac_free(context, pac2);
264     }
265 
266     krb5_pac_free(context, pac);
267 
268     /*
269      * check pac from Christian
270      */
271 
272     ret = krb5_parse_name_flags(context, user2,
273 				KRB5_PRINCIPAL_PARSE_NO_REALM, &p2);
274     if (ret)
275 	krb5_err(context, 1, ret, "krb5_parse_name");
276 
277     ret = krb5_pac_parse(context, saved_pac2, sizeof(saved_pac2) -1, &pac);
278     if (ret)
279 	krb5_err(context, 1, ret, "krb5_pac_parse");
280 
281     ret = krb5_pac_verify(context, pac, authtime2, p2,
282 			   &member_keyblock2, NULL);
283     if (ret)
284 	krb5_err(context, 1, ret, "krb5_pac_verify c1");
285 
286     krb5_pac_free(context, pac);
287     krb5_free_principal(context, p2);
288 
289     /*
290      * Test empty free
291      */
292 
293     ret = krb5_pac_init(context, &pac);
294     if (ret)
295 	krb5_err(context, 1, ret, "krb5_pac_init");
296     krb5_pac_free(context, pac);
297 
298     /*
299      * Test add remove buffer
300      */
301 
302     ret = krb5_pac_init(context, &pac);
303     if (ret)
304 	krb5_err(context, 1, ret, "krb5_pac_init");
305 
306     {
307 	const krb5_data cdata = { 2, "\x00\x01" } ;
308 
309 	ret = krb5_pac_add_buffer(context, pac, 1, &cdata);
310 	if (ret)
311 	    krb5_err(context, 1, ret, "krb5_pac_add_buffer");
312     }
313     {
314 	ret = krb5_pac_get_buffer(context, pac, 1, &data);
315 	if (ret)
316 	    krb5_err(context, 1, ret, "krb5_pac_get_buffer");
317 	if (data.length != 2 || memcmp(data.data, "\x00\x01", 2) != 0)
318 	    krb5_errx(context, 1, "krb5_pac_get_buffer data not the same");
319 	krb5_data_free(&data);
320     }
321 
322     {
323 	const krb5_data cdata = { 2, "\x02\x00" } ;
324 
325 	ret = krb5_pac_add_buffer(context, pac, 2, &cdata);
326 	if (ret)
327 	    krb5_err(context, 1, ret, "krb5_pac_add_buffer");
328     }
329     {
330 	ret = krb5_pac_get_buffer(context, pac, 1, &data);
331 	if (ret)
332 	    krb5_err(context, 1, ret, "krb5_pac_get_buffer");
333 	if (data.length != 2 || memcmp(data.data, "\x00\x01", 2) != 0)
334 	    krb5_errx(context, 1, "krb5_pac_get_buffer data not the same");
335 	krb5_data_free(&data);
336 	/* */
337 	ret = krb5_pac_get_buffer(context, pac, 2, &data);
338 	if (ret)
339 	    krb5_err(context, 1, ret, "krb5_pac_get_buffer");
340 	if (data.length != 2 || memcmp(data.data, "\x02\x00", 2) != 0)
341 	    krb5_errx(context, 1, "krb5_pac_get_buffer data not the same");
342 	krb5_data_free(&data);
343     }
344 
345     ret = _krb5_pac_sign(context, pac, authtime, p,
346 			 &member_keyblock, &kdc_keyblock, &data);
347     if (ret)
348 	krb5_err(context, 1, ret, "_krb5_pac_sign");
349 
350     krb5_pac_free(context, pac);
351 
352     ret = krb5_pac_parse(context, data.data, data.length, &pac);
353     krb5_data_free(&data);
354     if (ret)
355 	krb5_err(context, 1, ret, "krb5_pac_parse 3");
356 
357     ret = krb5_pac_verify(context, pac, authtime, p,
358 			   &member_keyblock, &kdc_keyblock);
359     if (ret)
360 	krb5_err(context, 1, ret, "krb5_pac_verify 3");
361 
362     {
363 	uint32_t *list;
364 	size_t len;
365 
366 	/* our two user buffer plus the three "system" buffers */
367 	ret = krb5_pac_get_types(context, pac, &len, &list);
368 	if (ret)
369 	    krb5_err(context, 1, ret, "krb5_pac_get_types");
370 	if (len != 5)
371 	    krb5_errx(context, 1, "list wrong length");
372 	free(list);
373     }
374 
375     krb5_pac_free(context, pac);
376 
377     krb5_free_principal(context, p);
378     krb5_free_context(context);
379 
380     return 0;
381 }
382