1 /* ticketset.c Shishi ticketset self tests.
2 * Copyright (C) 2002, 2003 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 static const char tkt1kdcrepb64
[] =
26 "a4ICITCCAh2gAwIBBaEDAgELow8bDUpPU0VGU1NPTi5PUkekEDAOoAMCAQGhBzAF"
27 "GwNqYXOlggECYYH/MIH8oAMCAQWhDxsNSk9TRUZTU09OLk9SR6IiMCCgAwIBAaEZ"
28 "MBcbBmtyYnRndBsNSk9TRUZTU09OLk9SR6OBvzCBvKADAgEQoQMCAQGiga8Egayq"
29 "ttjMpRNM2iVVR5RjtMNH3i75hjnUiXQ7UeT7DMShJ5IxiBr09dggaZzTAHrBAvV8"
30 "5xON3p39rMpmCg9utizrxzT1JXruoGF/+ofuT7lEDfRr437QJD5WuOtlfmkM2i5s"
31 "2bGYZlHNdBonapJCcMeUSS45HEoM5iy0dK2JeaOliOVKTDpX9gOayKSIFYnuzIb+"
32 "cg1ATHm29ahK5AY+LU9E4v8Yj1/02srRuERApoHnMIHkoAMCARChAwIBBaKB1wSB"
33 "1AiMSoSQrE5FSE2CYpTOdLgVWRw/k1cqBtswVKRTdgj2As6WG6mhFczy7RF62GVM"
34 "6gJGNQRx1mAg0d5C7pNKRCgAZ2oQdJIGW6CLTy2L0LxM104HA0XrZ+zfFLKlZTOV"
35 "T85LIoSneI/yKNh3iYeVQwp6AdMRw6562fHMie22I4sy22wNVz1toTrKixILvoMy"
36 "eoD7ET43Y1eo0SeXj8LPmZyqLARBknl2ZvNcDpjWpI57QycHV28BhcvVPu72kObJ"
37 "/68tCNEJ8J+vHArpFA5V9BDsFcGs";
39 static const char tkt1enckdcreppartb64
[] =
40 "eYGyMIGvoCMwIaADAgEQoRoEGPF/LFgc3IYq3+AZofutur+wsK5i6vSbN6EcMBow"
41 "GKADAgEAoREYDzE5NzAwMTAxMDAwMDAwWqIGAgTl7iQgpAcDBQAAQAAApREYDzIw"
42 "MDIxMjExMTM0MDU0WqcRGA8yMDAyMTIxMTEzNTczNFqpDxsNSk9TRUZTU09OLk9S"
43 "R6oiMCCgAwIBAaEZMBcbBmtyYnRndBsNSk9TRUZTU09OLk9SRw==";
45 static const char tkt1ticketb64
[] =
46 "YYH/MIH8oAMCAQWhDxsNSk9TRUZTU09OLk9SR6IiMCCgAwIBAaEZMBcbBmtyYnRn"
47 "dBsNSk9TRUZTU09OLk9SR6OBvzCBvKADAgEQoQMCAQGiga8EgayqttjMpRNM2iVV"
48 "R5RjtMNH3i75hjnUiXQ7UeT7DMShJ5IxiBr09dggaZzTAHrBAvV85xON3p39rMpm"
49 "Cg9utizrxzT1JXruoGF/+ofuT7lEDfRr437QJD5WuOtlfmkM2i5s2bGYZlHNdBon"
50 "apJCcMeUSS45HEoM5iy0dK2JeaOliOVKTDpX9gOayKSIFYnuzIb+cg1ATHm29ahK"
51 "5AY+LU9E4v8Yj1/02srRuERA";
53 static const char tkt2kdcrepb64
[] =
54 "bYICSjCCAkagAwIBBaEDAgENow8bDUpPU0VGU1NPTi5PUkekEDAOoAMCAQGhBzAF"
55 "GwNqYXOlggEYYYIBFDCCARCgAwIBBaEPGw1KT1NFRlNTT04uT1JHoiYwJKADAgEB"
56 "oR0wGxsEaG9zdBsTbGF0dGUuam9zZWZzc29uLm9yZ6OBzzCBzKADAgEQoQMCAQKi"
57 "gb8EgbzEU6KFfSSQg4xxSxJBp2QBtaNGyzawROAGFsztZcY+gl5K2ki6xDT10kCY"
58 "yfORXXXraoYIcwJl6EW8RGl4KKsZlZmNWuw0/mO4Gglga6sM06vQDs2TcSc8hWDJ"
59 "4I1vU6/WlKtwzNj0Cw+6fqyDJIt6PmRpUe/yGZe6hSQkrqgQuBhpAHZF4/aoWqOm"
60 "NufTdGa+5gHzqcEmQerWD8YhImeD+Xe5citg92XTPx2nHiNMBMmwgWJHf1Tjddiw"
61 "saaB+jCB96ADAgEQooHvBIHsmctkNNI2jJwUEdTe9o5WeHyTCWMSO9AA0luxjX2D"
62 "CR5kNOZuPx5YfHWHwKlqrOtwo1E0Cb7bpKHPUOWhhIGUXcV0z1ETSEOX8Ho3iIOc"
63 "8LSNVq8UqVf/wBnndLiljZveTbbu+YcFNbF7g+q2VDYffKgXsUi6HV2Ue7OGawvY"
64 "DxU7KDVpPWgitPGrNItdaJ1QVfVH+cXLdiqEV7RR+JOsFc8jkBxNOq/rx60Ga73F"
65 "urdXCqM1tz5T2QHgoI6y0HjGuEbjymFQfCt1hclIvu7EzWn29p2oZJUj1Vv7vpNz"
66 "tDy+gjC3uMYj7JGdoTg=";
68 static const char tkt2enckdcreppartb64
[] =
69 "eoHJMIHGoCMwIaADAgEQoRoEGFS29KeMuXZDeqcEud/gWHln/db7bje26aEcMBow"
70 "GKADAgEAoREYDzE5NzAwMTAxMDAwMDAwWqIGAgScLHDdpAcDBQAAAAAApREYDzIw"
71 "MDIxMjExMTM0MDU0WqYRGA8yMDAyMTIxMTEzNDEwNFqnERgPMjAwMjEyMTExMzU3"
72 "MzRaqQ8bDUpPU0VGU1NPTi5PUkeqJjAkoAMCAQGhHTAbGwRob3N0GxNsYXR0ZS5q"
75 static const char tkt2ticketb64
[] =
76 "YYIBFDCCARCgAwIBBaEPGw1KT1NFRlNTT04uT1JHoiYwJKADAgEBoR0wGxsEaG9z"
77 "dBsTbGF0dGUuam9zZWZzc29uLm9yZ6OBzzCBzKADAgEQoQMCAQKigb8EgbzEU6KF"
78 "fSSQg4xxSxJBp2QBtaNGyzawROAGFsztZcY+gl5K2ki6xDT10kCYyfORXXXraoYI"
79 "cwJl6EW8RGl4KKsZlZmNWuw0/mO4Gglga6sM06vQDs2TcSc8hWDJ4I1vU6/WlKtw"
80 "zNj0Cw+6fqyDJIt6PmRpUe/yGZe6hSQkrqgQuBhpAHZF4/aoWqOmNufTdGa+5gHz"
81 "qcEmQerWD8YhImeD+Xe5citg92XTPx2nHiNMBMmwgWJHf1TjddiwsQ==";
84 main (int argc
, char *argv
[])
88 Shishi_tkts_hint hint
;
89 Shishi_tkt
*t1
, *t2
, *t3
;
90 Shishi_asn1 n1
, n2
, n3
;
97 if (strcmp (argv
[argc
- 1], "-v") == 0 ||
98 strcmp (argv
[argc
- 1], "--verbose") == 0)
100 else if (strcmp (argv
[argc
- 1], "-d") == 0 ||
101 strcmp (argv
[argc
- 1], "--debug") == 0)
103 else if (strcmp (argv
[argc
- 1], "-b") == 0 ||
104 strcmp (argv
[argc
- 1], "--break-on-error") == 0)
106 else if (strcmp (argv
[argc
- 1], "-h") == 0 ||
107 strcmp (argv
[argc
- 1], "-?") == 0 ||
108 strcmp (argv
[argc
- 1], "--help") == 0)
110 printf ("Usage: %s [-vdbh?] [--verbose] [--debug] "
111 "[--break-on-error] [--help]\n", argv
[0]);
119 fail ("Could not initialize shishi\n");
124 shishi_cfg (handle
, strdup ("verbose"));
126 escapeprint (NULL
, 0);
130 /* shishi_tkts_default_file() */
131 p
= strdup (shishi_tkts_default_file (handle
));
133 printf ("shishi_tkts_default_file () => `%s'.\n", p
? p
: "<null>");
135 success ("shishi_tkts_default_file() OK\n");
137 fail ("shishi_tkts_default_file() failed\n");
139 /* shishi_tkts_default_file_set() */
140 shishi_tkts_default_file_set (handle
, "foo");
141 q
= strdup (shishi_tkts_default_file (handle
));
143 printf ("shishi_tkts_default_file () => `%s'.\n", q
? q
: "<null>");
144 if (q
&& strcmp (q
, "foo") == 0)
145 success ("shishi_tkts_default_file_set() OK\n");
147 fail ("shishi_tkts_default_file_set() failed\n");
150 /* shishi_tkts_default_file_set() */
151 shishi_tkts_default_file_set (handle
, NULL
);
152 q
= strdup (shishi_tkts_default_file (handle
));
154 printf ("shishi_tkts_default_file () => `%s'.\n", q
? q
: "<null>");
155 if (p
&& q
&& strcmp (p
, q
) == 0)
156 success ("shishi_tkts_default_file_set() OK\n");
158 fail ("shishi_tkts_default_file_set() failed\n");
163 res
= shishi_tkts (handle
, &tktset
);
164 if (res
== SHISHI_OK
)
165 success ("shishi_tkts() OK\n");
167 fail ("shishi_tkts() failed\n");
169 /* shishi_tkts_size () */
170 n
= shishi_tkts_size (tktset
);
172 printf ("shishi_tkts_size () => `%d'.\n", n
);
174 success ("shishi_tkts_size() OK\n");
176 fail ("shishi_tkts_size() failed\n");
178 /* shishi_tkts_nth () */
179 t1
= shishi_tkts_nth (tktset
, 0);
181 success ("shishi_tkts_nth() OK\n");
183 fail ("shishi_tkts_nth() failed\n");
185 /* shishi_tkts_nth () */
186 t1
= shishi_tkts_nth (tktset
, 42);
188 success ("shishi_tkts_nth() OK\n");
190 fail ("shishi_tkts_nth() failed\n");
192 /* shishi_tkts_add () */
193 res
= shishi_tkts_add (tktset
, NULL
);
194 if (res
== SHISHI_INVALID_TICKET
)
195 success ("shishi_tkts_add() OK\n");
197 fail ("shishi_tkts_add() failed\n");
199 /* shishi_tkts_remove () */
200 res
= shishi_tkts_remove (tktset
, 0);
201 if (res
== SHISHI_OK
)
202 success ("shishi_tkts_remove() OK\n");
204 fail ("shishi_tkts_remove() failed\n");
206 /* shishi_tkts_remove () */
207 res
= shishi_tkts_remove (tktset
, 42);
208 if (res
== SHISHI_OK
)
209 success ("shishi_tkts_remove() OK\n");
211 fail ("shishi_tkts_remove() failed\n");
213 /* shishi_tkts_remove () */
214 res
= shishi_tkts_remove (NULL
, 0);
215 if (res
== SHISHI_INVALID_TKTS
)
216 success ("shishi_tkts_remove() OK\n");
218 fail ("shishi_tkts_remove() failed\n");
221 n
= shishi_from_base64 (buffer
, tkt1ticketb64
);
223 die ("shishi_from_base64() failed\n");
224 n1
= shishi_der2asn1_ticket (handle
, buffer
, n
);
226 die ("shishi_der2asn1_ticket() failed\n");
228 n
= shishi_from_base64 (buffer
, tkt1enckdcreppartb64
);
230 die ("shishi_from_base64() failed\n");
231 n2
= shishi_der2asn1_encasreppart (handle
, buffer
, n
);
233 die ("shishi_der2asn1_encasreppart() failed\n");
235 n
= shishi_from_base64 (buffer
, tkt1kdcrepb64
);
237 die ("shishi_from_base64() failed\n");
238 n3
= shishi_der2asn1_asrep (handle
, buffer
, n
);
240 die ("shishi_der2asn1_asrep() failed\n");
242 /* shishi_tkts_new() */
243 res
= shishi_tkts_new (tktset
, n1
, n2
, n3
);
244 if (res
== SHISHI_OK
)
245 success ("shishi_tkts_new() OK\n");
247 fail ("shishi_tkts_new() failed\n");
249 /* shishi_tkts_size () */
250 n
= shishi_tkts_size (tktset
);
252 printf ("shishi_tkts_size () => `%d'.\n", n
);
254 success ("shishi_tkts_size() OK\n");
256 fail ("shishi_tkts_size() failed\n");
258 /* shishi_tkts_nth () */
259 t1
= shishi_tkts_nth (tktset
, 0);
262 shishi_tkt_pretty_print (t1
, stdout
);
263 printf ("t1=%p\n", t1
);
266 success ("shishi_tkts_nth() OK\n");
268 fail ("shishi_tkts_nth() failed\n");
270 /* shishi_tkts_remove () */
271 res
= shishi_tkts_remove (tktset
, 0);
272 if (res
== SHISHI_OK
)
273 success ("shishi_tkts_remove() OK\n");
275 fail ("shishi_tkts_remove() failed\n");
277 /* shishi_tkts_size () */
278 n
= shishi_tkts_size (tktset
);
280 printf ("shishi_tkts_size () => `%d'.\n", n
);
282 success ("shishi_tkts_size() OK\n");
284 fail ("shishi_tkts_size() failed\n");
286 /* shishi_tkts_nth () */
287 t2
= shishi_tkts_nth (tktset
, 0);
289 success ("shishi_tkts_nth() OK\n");
291 fail ("shishi_tkts_nth() failed\n");
293 /* shishi_tkts_add () */
294 res
= shishi_tkts_add (tktset
, t1
);
295 if (res
== SHISHI_OK
)
296 success ("shishi_tkts_add() OK\n");
298 fail ("shishi_tkts_add() failed\n");
300 /* shishi_tkts_size () */
301 n
= shishi_tkts_size (tktset
);
303 printf ("shishi_tkts_size () => `%d'.\n", n
);
305 success ("shishi_tkts_size() OK\n");
307 fail ("shishi_tkts_size() failed\n");
310 n
= shishi_from_base64 (buffer
, tkt2ticketb64
);
312 die ("shishi_from_base64() failed\n");
313 n1
= shishi_der2asn1_ticket (handle
, buffer
, n
);
315 die ("shishi_der2asn1_ticket() failed\n");
317 n
= shishi_from_base64 (buffer
, tkt2enckdcreppartb64
);
319 die ("shishi_from_base64() failed\n");
320 n2
= shishi_der2asn1_enctgsreppart (handle
, buffer
, n
);
322 die ("shishi_der2asn1_enctgsreppart() failed\n");
324 n
= shishi_from_base64 (buffer
, tkt2kdcrepb64
);
326 die ("shishi_from_base64() failed\n");
327 n3
= shishi_der2asn1_tgsrep (handle
, buffer
, n
);
329 die ("shishi_der2asn1_kdcrep() failed\n");
331 /* shishi_tkts_new() */
332 res
= shishi_tkts_new (tktset
, n1
, n2
, n3
);
333 if (res
== SHISHI_OK
)
334 success ("shishi_tkts_new() OK\n");
336 fail ("shishi_tkts_new() failed\n");
338 /* shishi_tkts_size () */
339 n
= shishi_tkts_size (tktset
);
341 printf ("shishi_tkts_size () => `%d'.\n", n
);
343 success ("shishi_tkts_size() OK\n");
345 fail ("shishi_tkts_size() failed\n");
347 /* shishi_tkts_nth () */
348 t2
= shishi_tkts_nth (tktset
, 1);
351 shishi_tkt_pretty_print (t2
, stdout
);
352 printf ("t2=%p\n", t2
);
355 success ("shishi_tkts_nth() OK\n");
357 fail ("shishi_tkts_nth() failed\n");
359 /* shishi_tkts_find () */
360 memset (&hint
, 0, sizeof (hint
));
361 hint
.server
= "host/latte.josefsson.org";
362 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
363 t3
= shishi_tkts_find (tktset
, &hint
);
365 printf ("t3=%p\n", t3
);
367 success ("shishi_tkts_find() for server OK\n");
369 fail ("shishi_tkts_find() for server failed\n");
371 /* shishi_tkts_find () */
372 memset (&hint
, 0, sizeof (hint
));
373 hint
.server
= "krbtgt/JOSEFSSON.ORG";
374 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
375 t3
= shishi_tkts_find (tktset
, &hint
);
377 success ("shishi_tkts_find() for server OK\n");
379 fail ("shishi_tkts_find() for server failed\n");
381 /* shishi_tkts_find () */
382 memset (&hint
, 0, sizeof (hint
));
384 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
385 t3
= shishi_tkts_find (tktset
, &hint
);
387 printf ("t3=%p\n", t3
);
389 success ("shishi_tkts_find() for client OK\n");
391 fail ("shishi_tkts_find() for client failed\n");
393 /* shishi_tkts_find () */
394 memset (&hint
, 0, sizeof (hint
));
396 t3
= shishi_tkts_find (tktset
, &hint
);
398 printf ("t3=%p\n", t3
);
400 success ("shishi_tkts_find() for client OK\n");
402 fail ("shishi_tkts_find() for client failed\n");
404 res
= shishi_tkts_to_file (tktset
, "tktset.tmp");
405 if (res
== SHISHI_OK
)
406 success ("shishi_tkts_to_file() OK\n");
408 fail ("shishi_tkts_to_file() failed\n");
410 /* shishi_tkts_add () */
411 res
= shishi_tkts_add (tktset
, t2
);
412 if (res
== SHISHI_OK
)
413 success ("shishi_tkts_add() OK\n");
415 fail ("shishi_tkts_add() failed\n");
417 /* shishi_tkts_add () */
418 res
= shishi_tkts_add (tktset
, t1
);
419 if (res
== SHISHI_OK
)
420 success ("shishi_tkts_add() OK\n");
422 fail ("shishi_tkts_add() failed\n");
424 /* shishi_tkts_remove () */
425 res
= shishi_tkts_remove (tktset
, 1);
426 if (res
== SHISHI_OK
)
427 success ("shishi_tkts_remove() OK\n");
429 fail ("shishi_tkts_remove() failed\n");
431 /* shishi_tkts_remove () */
432 res
= shishi_tkts_remove (tktset
, 1);
433 if (res
== SHISHI_OK
)
434 success ("shishi_tkts_remove() OK\n");
436 fail ("shishi_tkts_remove() failed\n");
438 memset (&hint
, 0, sizeof (hint
));
439 hint
.server
= "host/latte.josefsson.org";
440 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
441 t3
= shishi_tkts_find (tktset
, &hint
);
443 success ("shishi_tkts_find() for server OK\n");
445 fail ("shishi_tkts_find() for server failed\n");
447 memset (&hint
, 0, sizeof (hint
));
448 hint
.server
= "krbtgt/JOSEFSSON.ORG";
449 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
450 t3
= shishi_tkts_find (tktset
, &hint
);
452 success ("shishi_tkts_find() for server OK\n");
454 fail ("shishi_tkts_find() for server failed\n");
456 /* shishi_tkts_remove () */
457 res
= shishi_tkts_remove (tktset
, 0);
458 if (res
== SHISHI_OK
)
459 success ("shishi_tkts_remove() OK\n");
461 fail ("shishi_tkts_remove() failed\n");
463 /* shishi_tkts_remove () */
464 res
= shishi_tkts_remove (tktset
, 0);
465 if (res
== SHISHI_OK
)
466 success ("shishi_tkts_remove() OK\n");
468 fail ("shishi_tkts_remove() failed\n");
470 /* shishi_tkts_size () */
471 n
= shishi_tkts_size (tktset
);
473 printf ("shishi_tkts_size () => `%d'.\n", n
);
475 success ("shishi_tkts_size() OK\n");
477 fail ("shishi_tkts_size() failed\n");
479 /* shishi_tkts_done () */
480 shishi_tkts_done (&tktset
);
481 success ("shishi_tkts_done() OK\n");
483 shishi_tkt_done (t1
);
484 success ("shishi_tkt_done (t1) OK\n");
485 shishi_tkt_done (t2
);
486 success ("shishi_tkt_done (t2) OK\n");
488 /* shishi_tkts_done () */
489 shishi_tkts_done (NULL
);
490 success ("shishi_tkts_done() OK\n");
493 res
= shishi_tkts (handle
, &tktset
);
494 if (res
== SHISHI_OK
)
495 success ("shishi_tkts() OK\n");
497 fail ("shishi_tkts() failed\n");
499 /* shishi_tkts_from_file () */
500 res
= shishi_tkts_from_file (tktset
, "tktset.tmp");
501 if (res
== SHISHI_OK
)
502 success ("shishi_tkts_to_file() OK\n");
504 fail ("shishi_tkts_to_file() failed\n");
506 /* shishi_tkts_size () */
507 n
= shishi_tkts_size (tktset
);
509 printf ("shishi_tkts_size () => `%d'.\n", n
);
511 success ("shishi_tkts_size() OK\n");
513 fail ("shishi_tkts_size() failed\n");
515 /* shishi_tkts_nth () */
516 t1
= shishi_tkts_nth (tktset
, 0);
518 shishi_tkt_pretty_print (t1
, stdout
);
520 success ("shishi_tkts_nth() OK\n");
522 fail ("shishi_tkts_nth() failed\n");
524 /* shishi_tkts_nth () */
525 t2
= shishi_tkts_nth (tktset
, 1);
527 shishi_tkt_pretty_print (t2
, stdout
);
529 success ("shishi_tkts_nth() OK\n");
531 fail ("shishi_tkts_nth() failed\n");
533 /* DER encode and compare tkt1 ticket */
534 res
= shishi_a2d (handle
, shishi_tkt_ticket (t1
), buffer
, &n
);
535 if (res
== SHISHI_OK
)
536 success ("shishi_a2d() OK\n");
538 n
= 0, fail ("shishi_a2d() failed\n");
540 shishi_to_base64 (buffer2
, buffer
, n
, BUFSIZ
);
541 if (strlen (buffer2
) == strlen (tkt1ticketb64
) &&
542 memcmp (buffer2
, tkt1ticketb64
, strlen (tkt1ticketb64
)) == 0)
543 success ("Ticket read OK\n");
545 fail ("Ticket read failed\n");
547 /* DER encode and compare tkt1 enckdcreppart */
548 res
= shishi_a2d (handle
, shishi_tkt_enckdcreppart (t1
), buffer
, &n
);
549 if (res
== SHISHI_OK
)
550 success ("shishi_a2d() OK\n");
552 n
= 0, fail ("shishi_a2d() failed\n");
554 shishi_to_base64 (buffer2
, buffer
, n
, BUFSIZ
);
555 if (strlen (buffer2
) == strlen (tkt1enckdcreppartb64
) &&
556 memcmp (buffer2
, tkt1enckdcreppartb64
,
557 strlen (tkt1enckdcreppartb64
)) == 0)
558 success ("EncKDCRepPart read OK\n");
560 fail ("EncKDCRepPart read failed\n");
562 /* DER encode and compare tkt1 kdcrep */
563 res
= shishi_a2d (handle
, shishi_tkt_kdcrep (t1
), buffer
, &n
);
564 if (res
== SHISHI_OK
)
565 success ("shishi_a2d() OK\n");
567 n
= 0, fail ("shishi_a2d() failed\n");
569 shishi_to_base64 (buffer2
, buffer
, n
, BUFSIZ
);
570 if (strlen (buffer2
) == strlen (tkt1kdcrepb64
) &&
571 memcmp (buffer2
, tkt1kdcrepb64
, strlen (tkt1kdcrepb64
)) == 0)
572 success ("KDC-REP read OK\n");
574 fail ("KDC-REP read failed\n");
576 /* DER encode and compare tkt2 ticket */
577 res
= shishi_a2d (handle
, shishi_tkt_ticket (t2
), buffer
, &n
);
578 if (res
== SHISHI_OK
)
579 success ("shishi_a2d() OK\n");
581 n
= 0, fail ("shishi_a2d() failed\n");
583 shishi_to_base64 (buffer2
, buffer
, n
, BUFSIZ
);
584 if (strlen (buffer2
) == strlen (tkt2ticketb64
) &&
585 memcmp (buffer2
, tkt2ticketb64
, strlen (tkt2ticketb64
)) == 0)
586 success ("Ticket 2 read OK\n");
588 fail ("Ticket 2 read failed\n");
590 /* DER encode and compare tkt2 enckdcreppart */
591 res
= shishi_a2d (handle
, shishi_tkt_enckdcreppart (t2
), buffer
, &n
);
592 if (res
== SHISHI_OK
)
593 success ("shishi_a2d() OK\n");
595 n
= 0, fail ("shishi_a2d() failed\n");
597 shishi_to_base64 (buffer2
, buffer
, n
, BUFSIZ
);
598 if (strlen (buffer2
) == strlen (tkt2enckdcreppartb64
) &&
599 memcmp (buffer2
, tkt2enckdcreppartb64
,
600 strlen (tkt2enckdcreppartb64
)) == 0)
601 success ("EncKDCRepPart 2 read OK\n");
603 fail ("EncKDCRepPart 2 read failed\n");
605 /* DER encode and compare tkt2 kdcrep */
606 res
= shishi_a2d (handle
, shishi_tkt_kdcrep (t2
), buffer
, &n
);
607 if (res
== SHISHI_OK
)
608 success ("shishi_a2d() OK\n");
610 n
= 0, fail ("shishi_a2d() failed\n");
612 shishi_to_base64 (buffer2
, buffer
, n
, BUFSIZ
);
613 if (strlen (buffer2
) == strlen (tkt2kdcrepb64
) &&
614 memcmp (buffer2
, tkt2kdcrepb64
, strlen (tkt2kdcrepb64
)) == 0)
615 success ("KDC-REP 2 read OK\n");
617 fail ("KDC-REP 2 read failed\n");
619 res
= unlink ("tktset.tmp");
621 success ("unlink() OK\n");
623 fail ("unlink() failed\n");
625 shishi_tkt_done (t1
);
626 success ("shishi_tkt_done (t1) OK\n");
627 shishi_tkt_done (t2
);
628 success ("shishi_tkt_done (t2) OK\n");
630 /* shishi_tkts_done () */
631 shishi_tkts_done (&tktset
);
632 success ("shishi_tkts_done() OK\n");
634 shishi_done (handle
);
637 printf ("Ticket set self tests done with %d errors\n", error_count
);
639 return error_count
? 1 : 0;