1 /* ticketset.c Shishi ticketset self tests.
2 * Copyright (C) 2002, 2003, 2004, 2006 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 static const char tkt1kdcrepb64
[] =
25 "a4ICITCCAh2gAwIBBaEDAgELow8bDUpPU0VGU1NPTi5PUkekEDAOoAMCAQGhBzAF"
26 "GwNqYXOlggECYYH/MIH8oAMCAQWhDxsNSk9TRUZTU09OLk9SR6IiMCCgAwIBAaEZ"
27 "MBcbBmtyYnRndBsNSk9TRUZTU09OLk9SR6OBvzCBvKADAgEQoQMCAQGiga8Egayq"
28 "ttjMpRNM2iVVR5RjtMNH3i75hjnUiXQ7UeT7DMShJ5IxiBr09dggaZzTAHrBAvV8"
29 "5xON3p39rMpmCg9utizrxzT1JXruoGF/+ofuT7lEDfRr437QJD5WuOtlfmkM2i5s"
30 "2bGYZlHNdBonapJCcMeUSS45HEoM5iy0dK2JeaOliOVKTDpX9gOayKSIFYnuzIb+"
31 "cg1ATHm29ahK5AY+LU9E4v8Yj1/02srRuERApoHnMIHkoAMCARChAwIBBaKB1wSB"
32 "1AiMSoSQrE5FSE2CYpTOdLgVWRw/k1cqBtswVKRTdgj2As6WG6mhFczy7RF62GVM"
33 "6gJGNQRx1mAg0d5C7pNKRCgAZ2oQdJIGW6CLTy2L0LxM104HA0XrZ+zfFLKlZTOV"
34 "T85LIoSneI/yKNh3iYeVQwp6AdMRw6562fHMie22I4sy22wNVz1toTrKixILvoMy"
35 "eoD7ET43Y1eo0SeXj8LPmZyqLARBknl2ZvNcDpjWpI57QycHV28BhcvVPu72kObJ"
36 "/68tCNEJ8J+vHArpFA5V9BDsFcGs";
38 static const char tkt1enckdcreppartb64
[] =
39 "eYGyMIGvoCMwIaADAgEQoRoEGPF/LFgc3IYq3+AZofutur+wsK5i6vSbN6EcMBow"
40 "GKADAgEAoREYDzE5NzAwMTAxMDAwMDAwWqIGAgTl7iQgpAcDBQAAQAAApREYDzIw"
41 "MDIxMjExMTM0MDU0WqcRGA8yMDAyMTIxMTEzNTczNFqpDxsNSk9TRUZTU09OLk9S"
42 "R6oiMCCgAwIBAaEZMBcbBmtyYnRndBsNSk9TRUZTU09OLk9SRw==";
44 static const char tkt1ticketb64
[] =
45 "YYH/MIH8oAMCAQWhDxsNSk9TRUZTU09OLk9SR6IiMCCgAwIBAaEZMBcbBmtyYnRn"
46 "dBsNSk9TRUZTU09OLk9SR6OBvzCBvKADAgEQoQMCAQGiga8EgayqttjMpRNM2iVV"
47 "R5RjtMNH3i75hjnUiXQ7UeT7DMShJ5IxiBr09dggaZzTAHrBAvV85xON3p39rMpm"
48 "Cg9utizrxzT1JXruoGF/+ofuT7lEDfRr437QJD5WuOtlfmkM2i5s2bGYZlHNdBon"
49 "apJCcMeUSS45HEoM5iy0dK2JeaOliOVKTDpX9gOayKSIFYnuzIb+cg1ATHm29ahK"
50 "5AY+LU9E4v8Yj1/02srRuERA";
52 static const char tkt2kdcrepb64
[] =
53 "bYICSjCCAkagAwIBBaEDAgENow8bDUpPU0VGU1NPTi5PUkekEDAOoAMCAQGhBzAF"
54 "GwNqYXOlggEYYYIBFDCCARCgAwIBBaEPGw1KT1NFRlNTT04uT1JHoiYwJKADAgEB"
55 "oR0wGxsEaG9zdBsTbGF0dGUuam9zZWZzc29uLm9yZ6OBzzCBzKADAgEQoQMCAQKi"
56 "gb8EgbzEU6KFfSSQg4xxSxJBp2QBtaNGyzawROAGFsztZcY+gl5K2ki6xDT10kCY"
57 "yfORXXXraoYIcwJl6EW8RGl4KKsZlZmNWuw0/mO4Gglga6sM06vQDs2TcSc8hWDJ"
58 "4I1vU6/WlKtwzNj0Cw+6fqyDJIt6PmRpUe/yGZe6hSQkrqgQuBhpAHZF4/aoWqOm"
59 "NufTdGa+5gHzqcEmQerWD8YhImeD+Xe5citg92XTPx2nHiNMBMmwgWJHf1Tjddiw"
60 "saaB+jCB96ADAgEQooHvBIHsmctkNNI2jJwUEdTe9o5WeHyTCWMSO9AA0luxjX2D"
61 "CR5kNOZuPx5YfHWHwKlqrOtwo1E0Cb7bpKHPUOWhhIGUXcV0z1ETSEOX8Ho3iIOc"
62 "8LSNVq8UqVf/wBnndLiljZveTbbu+YcFNbF7g+q2VDYffKgXsUi6HV2Ue7OGawvY"
63 "DxU7KDVpPWgitPGrNItdaJ1QVfVH+cXLdiqEV7RR+JOsFc8jkBxNOq/rx60Ga73F"
64 "urdXCqM1tz5T2QHgoI6y0HjGuEbjymFQfCt1hclIvu7EzWn29p2oZJUj1Vv7vpNz"
65 "tDy+gjC3uMYj7JGdoTg=";
67 static const char tkt2enckdcreppartb64
[] =
68 "eoHJMIHGoCMwIaADAgEQoRoEGFS29KeMuXZDeqcEud/gWHln/db7bje26aEcMBow"
69 "GKADAgEAoREYDzE5NzAwMTAxMDAwMDAwWqIGAgScLHDdpAcDBQAAAAAApREYDzIw"
70 "MDIxMjExMTM0MDU0WqYRGA8yMDAyMTIxMTEzNDEwNFqnERgPMjAwMjEyMTExMzU3"
71 "MzRaqQ8bDUpPU0VGU1NPTi5PUkeqJjAkoAMCAQGhHTAbGwRob3N0GxNsYXR0ZS5q"
74 static const char tkt2ticketb64
[] =
75 "YYIBFDCCARCgAwIBBaEPGw1KT1NFRlNTT04uT1JHoiYwJKADAgEBoR0wGxsEaG9z"
76 "dBsTbGF0dGUuam9zZWZzc29uLm9yZ6OBzzCBzKADAgEQoQMCAQKigb8EgbzEU6KF"
77 "fSSQg4xxSxJBp2QBtaNGyzawROAGFsztZcY+gl5K2ki6xDT10kCYyfORXXXraoYI"
78 "cwJl6EW8RGl4KKsZlZmNWuw0/mO4Gglga6sM06vQDs2TcSc8hWDJ4I1vU6/WlKtw"
79 "zNj0Cw+6fqyDJIt6PmRpUe/yGZe6hSQkrqgQuBhpAHZF4/aoWqOmNufTdGa+5gHz"
80 "qcEmQerWD8YhImeD+Xe5citg92XTPx2nHiNMBMmwgWJHf1TjddiwsQ==";
83 test (Shishi
* handle
)
86 Shishi_tkts_hint hint
;
87 Shishi_tkt
*t1
, *t2
, *t3
;
88 Shishi_asn1 tkt1asn1
, tkt1asn2
, tkt1asn3
;
89 Shishi_asn1 tkt2asn1
, tkt2asn2
, tkt2asn3
;
97 /* shishi_tkts_default_file() */
98 p
= strdup (shishi_tkts_default_file (handle
));
100 printf ("shishi_tkts_default_file () => `%s'.\n", p
? p
: "<null>");
102 success ("shishi_tkts_default_file() OK\n");
104 fail ("shishi_tkts_default_file() failed\n");
106 /* shishi_tkts_default_file_set() */
107 shishi_tkts_default_file_set (handle
, "foo");
108 q
= strdup (shishi_tkts_default_file (handle
));
110 printf ("shishi_tkts_default_file () => `%s'.\n", q
? q
: "<null>");
111 if (q
&& strcmp (q
, "foo") == 0)
112 success ("shishi_tkts_default_file_set() OK\n");
114 fail ("shishi_tkts_default_file_set() failed\n");
117 /* shishi_tkts_default_file_set() */
118 shishi_tkts_default_file_set (handle
, NULL
);
119 q
= strdup (shishi_tkts_default_file (handle
));
121 printf ("shishi_tkts_default_file () => `%s'.\n", q
? q
: "<null>");
122 if (p
&& q
&& strcmp (p
, q
) == 0)
123 success ("shishi_tkts_default_file_set() OK\n");
125 fail ("shishi_tkts_default_file_set() failed\n");
130 res
= shishi_tkts (handle
, &tktset
);
131 if (res
== SHISHI_OK
)
132 success ("shishi_tkts() OK\n");
134 fail ("shishi_tkts() failed\n");
136 /* shishi_tkts_size () */
137 n
= shishi_tkts_size (tktset
);
139 printf ("shishi_tkts_size () => `%d'.\n", n
);
141 success ("shishi_tkts_size() OK\n");
143 fail ("shishi_tkts_size() failed\n");
145 /* shishi_tkts_nth () */
146 t1
= shishi_tkts_nth (tktset
, 0);
148 success ("shishi_tkts_nth() OK\n");
150 fail ("shishi_tkts_nth() failed\n");
152 /* shishi_tkts_nth () */
153 t1
= shishi_tkts_nth (tktset
, 42);
155 success ("shishi_tkts_nth() OK\n");
157 fail ("shishi_tkts_nth() failed\n");
159 /* shishi_tkts_add () */
160 res
= shishi_tkts_add (tktset
, NULL
);
161 if (res
== SHISHI_INVALID_TICKET
)
162 success ("shishi_tkts_add() OK\n");
164 fail ("shishi_tkts_add() failed\n");
166 /* shishi_tkts_remove () */
167 res
= shishi_tkts_remove (tktset
, 0);
168 if (res
== SHISHI_OK
)
169 success ("shishi_tkts_remove() OK\n");
171 fail ("shishi_tkts_remove() failed\n");
173 /* shishi_tkts_remove () */
174 res
= shishi_tkts_remove (tktset
, 42);
175 if (res
== SHISHI_OK
)
176 success ("shishi_tkts_remove() OK\n");
178 fail ("shishi_tkts_remove() failed\n");
180 /* shishi_tkts_remove () */
181 res
= shishi_tkts_remove (NULL
, 0);
182 if (res
== SHISHI_INVALID_TKTS
)
183 success ("shishi_tkts_remove() OK\n");
185 fail ("shishi_tkts_remove() failed\n");
189 if (!base64_decode (tkt1ticketb64
, strlen (tkt1ticketb64
), buffer
, &n
))
190 fail ("base64_decode() failed\n");
191 tkt1asn1
= shishi_der2asn1_ticket (handle
, buffer
, n
);
193 fail ("shishi_der2asn1_ticket() failed\n");
196 if (!base64_decode (tkt1enckdcreppartb64
, strlen (tkt1enckdcreppartb64
),
198 fail ("base64_decode() failed\n");
199 tkt1asn2
= shishi_der2asn1_encasreppart (handle
, buffer
, n
);
201 fail ("shishi_der2asn1_encasreppart() failed\n");
204 if (!base64_decode (tkt1kdcrepb64
, strlen (tkt1kdcrepb64
),
206 fail ("base64_decode() failed\n");
207 tkt1asn3
= shishi_der2asn1_asrep (handle
, buffer
, n
);
209 fail ("shishi_der2asn1_asrep() failed\n");
211 /* shishi_tkts_new() */
212 res
= shishi_tkts_new (tktset
, tkt1asn1
, tkt1asn2
, tkt1asn3
);
213 if (res
== SHISHI_OK
)
214 success ("shishi_tkts_new() OK\n");
216 fail ("shishi_tkts_new() failed\n");
218 /* shishi_tkts_size () */
219 n
= shishi_tkts_size (tktset
);
221 printf ("shishi_tkts_size () => `%d'.\n", n
);
223 success ("shishi_tkts_size() OK\n");
225 fail ("shishi_tkts_size() failed\n");
227 /* shishi_tkts_nth () */
228 t1
= shishi_tkts_nth (tktset
, 0);
231 shishi_tkt_pretty_print (t1
, stdout
);
232 printf ("t1=%p\n", t1
);
235 success ("shishi_tkts_nth() OK\n");
237 fail ("shishi_tkts_nth() failed\n");
239 /* shishi_tkts_remove () */
240 res
= shishi_tkts_remove (tktset
, 0);
241 if (res
== SHISHI_OK
)
242 success ("shishi_tkts_remove() OK\n");
244 fail ("shishi_tkts_remove() failed\n");
246 /* shishi_tkts_size () */
247 n
= shishi_tkts_size (tktset
);
249 printf ("shishi_tkts_size () => `%d'.\n", n
);
251 success ("shishi_tkts_size() OK\n");
253 fail ("shishi_tkts_size() failed\n");
255 /* shishi_tkts_nth () */
256 t2
= shishi_tkts_nth (tktset
, 0);
258 success ("shishi_tkts_nth() OK\n");
260 fail ("shishi_tkts_nth() failed\n");
262 /* shishi_tkts_add () */
263 res
= shishi_tkts_add (tktset
, t1
);
264 if (res
== SHISHI_OK
)
265 success ("shishi_tkts_add() OK\n");
267 fail ("shishi_tkts_add() failed\n");
269 /* shishi_tkts_size () */
270 n
= shishi_tkts_size (tktset
);
272 printf ("shishi_tkts_size () => `%d'.\n", n
);
274 success ("shishi_tkts_size() OK\n");
276 fail ("shishi_tkts_size() failed\n");
280 if (!base64_decode (tkt2ticketb64
, strlen (tkt2ticketb64
),
282 fail ("base64_decode() failed\n");
283 tkt2asn1
= shishi_der2asn1_ticket (handle
, buffer
, n
);
285 fail ("shishi_der2asn1_ticket() failed\n");
288 if (!base64_decode (tkt2enckdcreppartb64
, strlen (tkt2enckdcreppartb64
),
290 fail ("base64_decode() failed\n");
291 tkt2asn2
= shishi_der2asn1_enctgsreppart (handle
, buffer
, n
);
293 fail ("shishi_der2asn1_enctgsreppart() failed\n");
296 if (!base64_decode (tkt2kdcrepb64
, strlen (tkt2kdcrepb64
),
298 fail ("base64_decode() failed\n");
299 tkt2asn3
= shishi_der2asn1_tgsrep (handle
, buffer
, n
);
301 fail ("shishi_der2asn1_kdcrep() failed\n");
303 /* shishi_tkts_new() */
304 res
= shishi_tkts_new (tktset
, tkt2asn1
, tkt2asn2
, tkt2asn3
);
305 if (res
== SHISHI_OK
)
306 success ("shishi_tkts_new() OK\n");
308 fail ("shishi_tkts_new() failed\n");
310 /* shishi_tkts_size () */
311 n
= shishi_tkts_size (tktset
);
313 printf ("shishi_tkts_size () => `%d'.\n", n
);
315 success ("shishi_tkts_size() OK\n");
317 fail ("shishi_tkts_size() failed\n");
319 /* shishi_tkts_nth () */
320 t2
= shishi_tkts_nth (tktset
, 1);
323 shishi_tkt_pretty_print (t2
, stdout
);
324 printf ("t2=%p\n", t2
);
327 success ("shishi_tkts_nth() OK\n");
329 fail ("shishi_tkts_nth() failed\n");
331 /* shishi_tkts_find () */
332 memset (&hint
, 0, sizeof (hint
));
333 hint
.server
= "host/latte.josefsson.org";
334 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
335 t3
= shishi_tkts_find (tktset
, &hint
);
337 printf ("t3=%p\n", t3
);
339 success ("shishi_tkts_find() for server OK\n");
341 fail ("shishi_tkts_find() for server failed\n");
343 /* shishi_tkts_find () */
344 memset (&hint
, 0, sizeof (hint
));
345 hint
.server
= "krbtgt/JOSEFSSON.ORG";
346 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
347 t3
= shishi_tkts_find (tktset
, &hint
);
349 success ("shishi_tkts_find() for server OK\n");
351 fail ("shishi_tkts_find() for server failed\n");
353 /* shishi_tkts_find () */
354 memset (&hint
, 0, sizeof (hint
));
356 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
357 t3
= shishi_tkts_find (tktset
, &hint
);
359 printf ("t3=%p\n", t3
);
361 success ("shishi_tkts_find() for client OK\n");
363 fail ("shishi_tkts_find() for client failed\n");
365 /* shishi_tkts_find () */
366 memset (&hint
, 0, sizeof (hint
));
368 t3
= shishi_tkts_find (tktset
, &hint
);
370 printf ("t3=%p\n", t3
);
372 success ("shishi_tkts_find() for client OK\n");
374 fail ("shishi_tkts_find() for client failed\n");
376 res
= shishi_tkts_to_file (tktset
, "tktset.tmp");
377 if (res
== SHISHI_OK
)
378 success ("shishi_tkts_to_file() OK\n");
380 fail ("shishi_tkts_to_file() failed\n");
382 /* shishi_tkts_add () */
383 res
= shishi_tkts_add (tktset
, t2
);
384 if (res
== SHISHI_OK
)
385 success ("shishi_tkts_add() OK\n");
387 fail ("shishi_tkts_add() failed\n");
389 /* shishi_tkts_add () */
390 res
= shishi_tkts_add (tktset
, t1
);
391 if (res
== SHISHI_OK
)
392 success ("shishi_tkts_add() OK\n");
394 fail ("shishi_tkts_add() failed\n");
396 /* shishi_tkts_remove () */
397 res
= shishi_tkts_remove (tktset
, 1);
398 if (res
== SHISHI_OK
)
399 success ("shishi_tkts_remove() OK\n");
401 fail ("shishi_tkts_remove() failed\n");
403 /* shishi_tkts_remove () */
404 res
= shishi_tkts_remove (tktset
, 1);
405 if (res
== SHISHI_OK
)
406 success ("shishi_tkts_remove() OK\n");
408 fail ("shishi_tkts_remove() failed\n");
410 memset (&hint
, 0, sizeof (hint
));
411 hint
.server
= "host/latte.josefsson.org";
412 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
413 t3
= shishi_tkts_find (tktset
, &hint
);
415 success ("shishi_tkts_find() for server OK\n");
417 fail ("shishi_tkts_find() for server failed\n");
419 memset (&hint
, 0, sizeof (hint
));
420 hint
.server
= "krbtgt/JOSEFSSON.ORG";
421 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
422 t3
= shishi_tkts_find (tktset
, &hint
);
424 success ("shishi_tkts_find() for server OK\n");
426 fail ("shishi_tkts_find() for server failed\n");
428 /* shishi_tkts_remove () */
429 res
= shishi_tkts_remove (tktset
, 0);
430 if (res
== SHISHI_OK
)
431 success ("shishi_tkts_remove() OK\n");
433 fail ("shishi_tkts_remove() failed\n");
435 /* shishi_tkts_remove () */
436 res
= shishi_tkts_remove (tktset
, 0);
437 if (res
== SHISHI_OK
)
438 success ("shishi_tkts_remove() OK\n");
440 fail ("shishi_tkts_remove() failed\n");
442 /* shishi_tkts_size () */
443 n
= shishi_tkts_size (tktset
);
445 printf ("shishi_tkts_size () => `%d'.\n", n
);
447 success ("shishi_tkts_size() OK\n");
449 fail ("shishi_tkts_size() failed\n");
451 /* shishi_tkts_done () */
452 shishi_tkts_done (&tktset
);
453 success ("shishi_tkts_done() OK\n");
455 shishi_tkt_done (t1
);
456 success ("shishi_tkt_done (t1) OK\n");
457 shishi_tkt_done (t2
);
458 success ("shishi_tkt_done (t2) OK\n");
460 /* shishi_tkts_done () */
461 shishi_tkts_done (NULL
);
462 success ("shishi_tkts_done() OK\n");
465 res
= shishi_tkts (handle
, &tktset
);
466 if (res
== SHISHI_OK
)
467 success ("shishi_tkts() OK\n");
469 fail ("shishi_tkts() failed\n");
471 /* shishi_tkts_from_file () */
472 res
= shishi_tkts_from_file (tktset
, "tktset.tmp");
473 if (res
== SHISHI_OK
)
474 success ("shishi_tkts_to_file() OK\n");
476 fail ("shishi_tkts_to_file() failed\n");
478 /* shishi_tkts_size () */
479 n
= shishi_tkts_size (tktset
);
481 printf ("shishi_tkts_size () => `%d'.\n", n
);
483 success ("shishi_tkts_size() OK\n");
485 fail ("shishi_tkts_size() failed\n");
487 /* shishi_tkts_nth () */
488 t1
= shishi_tkts_nth (tktset
, 0);
490 shishi_tkt_pretty_print (t1
, stdout
);
492 success ("shishi_tkts_nth() OK\n");
494 fail ("shishi_tkts_nth() failed\n");
496 /* shishi_tkts_nth () */
497 t2
= shishi_tkts_nth (tktset
, 1);
499 shishi_tkt_pretty_print (t2
, stdout
);
501 success ("shishi_tkts_nth() OK\n");
503 fail ("shishi_tkts_nth() failed\n");
505 /* DER encode and compare tkt1 ticket */
506 res
= shishi_asn1_to_der (handle
, shishi_tkt_ticket (t1
), &buf
, &n
);
507 if (res
== SHISHI_OK
)
508 success ("shishi_asn1_to_der() OK\n");
510 n
= 0, fail ("shishi_asn1_to_der() failed\n");
512 base64_encode (buf
, n
, buffer2
, BUFSIZ
);
514 if (strlen (buffer2
) == strlen (tkt1ticketb64
) &&
515 memcmp (buffer2
, tkt1ticketb64
, strlen (tkt1ticketb64
)) == 0)
516 success ("Ticket read OK\n");
518 fail ("Ticket read failed\n");
520 /* DER encode and compare tkt1 enckdcreppart */
521 res
= shishi_asn1_to_der (handle
, shishi_tkt_enckdcreppart (t1
), &buf
, &n
);
522 if (res
== SHISHI_OK
)
523 success ("shishi_asn1_to_der() OK\n");
525 n
= 0, fail ("shishi_asn1_to_der() failed\n");
527 base64_encode (buf
, n
, buffer2
, BUFSIZ
);
529 if (strlen (buffer2
) == strlen (tkt1enckdcreppartb64
) &&
530 memcmp (buffer2
, tkt1enckdcreppartb64
,
531 strlen (tkt1enckdcreppartb64
)) == 0)
532 success ("EncKDCRepPart read OK\n");
534 fail ("EncKDCRepPart read failed\n");
536 /* DER encode and compare tkt1 kdcrep */
537 res
= shishi_asn1_to_der (handle
, shishi_tkt_kdcrep (t1
), &buf
, &n
);
538 if (res
== SHISHI_OK
)
539 success ("shishi_asn1_to_der() OK\n");
541 n
= 0, fail ("shishi_asn1_to_der() failed\n");
543 base64_encode (buf
, n
, buffer2
, BUFSIZ
);
545 if (strlen (buffer2
) == strlen (tkt1kdcrepb64
) &&
546 memcmp (buffer2
, tkt1kdcrepb64
, strlen (tkt1kdcrepb64
)) == 0)
547 success ("KDC-REP read OK\n");
549 fail ("KDC-REP read failed\n");
551 /* DER encode and compare tkt2 ticket */
552 res
= shishi_asn1_to_der (handle
, shishi_tkt_ticket (t2
), &buf
, &n
);
553 if (res
== SHISHI_OK
)
554 success ("shishi_asn1_to_der() OK\n");
556 n
= 0, fail ("shishi_asn1_to_der() failed\n");
558 base64_encode (buf
, n
, buffer2
, BUFSIZ
);
560 if (strlen (buffer2
) == strlen (tkt2ticketb64
) &&
561 memcmp (buffer2
, tkt2ticketb64
, strlen (tkt2ticketb64
)) == 0)
562 success ("Ticket 2 read OK\n");
564 fail ("Ticket 2 read failed\n");
566 /* DER encode and compare tkt2 enckdcreppart */
567 res
= shishi_asn1_to_der (handle
, shishi_tkt_enckdcreppart (t2
), &buf
, &n
);
568 if (res
== SHISHI_OK
)
569 success ("shishi_asn1_to_der() OK\n");
571 n
= 0, fail ("shishi_asn1_to_der() failed\n");
573 base64_encode (buf
, n
, buffer2
, BUFSIZ
);
575 if (strlen (buffer2
) == strlen (tkt2enckdcreppartb64
) &&
576 memcmp (buffer2
, tkt2enckdcreppartb64
,
577 strlen (tkt2enckdcreppartb64
)) == 0)
578 success ("EncKDCRepPart 2 read OK\n");
580 fail ("EncKDCRepPart 2 read failed\n");
582 /* DER encode and compare tkt2 kdcrep */
583 res
= shishi_asn1_to_der (handle
, shishi_tkt_kdcrep (t2
), &buf
, &n
);
584 if (res
== SHISHI_OK
)
585 success ("shishi_asn1_to_der() OK\n");
587 n
= 0, fail ("shishi_asn1_to_der() failed\n");
589 base64_encode (buf
, n
, buffer2
, BUFSIZ
);
591 if (strlen (buffer2
) == strlen (tkt2kdcrepb64
) &&
592 memcmp (buffer2
, tkt2kdcrepb64
, strlen (tkt2kdcrepb64
)) == 0)
593 success ("KDC-REP 2 read OK\n");
595 fail ("KDC-REP 2 read failed\n");
597 res
= unlink ("tktset.tmp");
599 success ("unlink() OK\n");
601 fail ("unlink() failed\n");
603 shishi_tkt_done (t1
);
604 success ("shishi_tkt_done (t1) OK\n");
605 shishi_tkt_done (t2
);
606 success ("shishi_tkt_done (t2) OK\n");
608 /* shishi_tkts_done () */
609 shishi_tkts_done (&tktset
);
610 success ("shishi_tkts_done() OK\n");
612 shishi_asn1_done (handle
, tkt1asn1
);
613 shishi_asn1_done (handle
, tkt1asn2
);
614 shishi_asn1_done (handle
, tkt1asn3
);
615 shishi_asn1_done (handle
, tkt2asn1
);
616 shishi_asn1_done (handle
, tkt2asn2
);
617 shishi_asn1_done (handle
, tkt2asn3
);