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
;
98 if (strcmp (argv
[argc
- 1], "-v") == 0 ||
99 strcmp (argv
[argc
- 1], "--verbose") == 0)
101 else if (strcmp (argv
[argc
- 1], "-d") == 0 ||
102 strcmp (argv
[argc
- 1], "--debug") == 0)
104 else if (strcmp (argv
[argc
- 1], "-b") == 0 ||
105 strcmp (argv
[argc
- 1], "--break-on-error") == 0)
107 else if (strcmp (argv
[argc
- 1], "-h") == 0 ||
108 strcmp (argv
[argc
- 1], "-?") == 0 ||
109 strcmp (argv
[argc
- 1], "--help") == 0)
111 printf ("Usage: %s [-vdbh?] [--verbose] [--debug] "
112 "[--break-on-error] [--help]\n", argv
[0]);
120 fail ("Could not initialize shishi\n");
125 shishi_cfg (handle
, strdup ("verbose"));
127 escapeprint (NULL
, 0);
131 /* shishi_tkts_default_file() */
132 p
= strdup (shishi_tkts_default_file (handle
));
134 printf ("shishi_tkts_default_file () => `%s'.\n", p
? p
: "<null>");
136 success ("shishi_tkts_default_file() OK\n");
138 fail ("shishi_tkts_default_file() failed\n");
140 /* shishi_tkts_default_file_set() */
141 shishi_tkts_default_file_set (handle
, "foo");
142 q
= strdup (shishi_tkts_default_file (handle
));
144 printf ("shishi_tkts_default_file () => `%s'.\n", q
? q
: "<null>");
145 if (q
&& strcmp (q
, "foo") == 0)
146 success ("shishi_tkts_default_file_set() OK\n");
148 fail ("shishi_tkts_default_file_set() failed\n");
151 /* shishi_tkts_default_file_set() */
152 shishi_tkts_default_file_set (handle
, NULL
);
153 q
= strdup (shishi_tkts_default_file (handle
));
155 printf ("shishi_tkts_default_file () => `%s'.\n", q
? q
: "<null>");
156 if (p
&& q
&& strcmp (p
, q
) == 0)
157 success ("shishi_tkts_default_file_set() OK\n");
159 fail ("shishi_tkts_default_file_set() failed\n");
164 res
= shishi_tkts (handle
, &tktset
);
165 if (res
== SHISHI_OK
)
166 success ("shishi_tkts() OK\n");
168 fail ("shishi_tkts() failed\n");
170 /* shishi_tkts_size () */
171 n
= shishi_tkts_size (tktset
);
173 printf ("shishi_tkts_size () => `%d'.\n", n
);
175 success ("shishi_tkts_size() OK\n");
177 fail ("shishi_tkts_size() failed\n");
179 /* shishi_tkts_nth () */
180 t1
= shishi_tkts_nth (tktset
, 0);
182 success ("shishi_tkts_nth() OK\n");
184 fail ("shishi_tkts_nth() failed\n");
186 /* shishi_tkts_nth () */
187 t1
= shishi_tkts_nth (tktset
, 42);
189 success ("shishi_tkts_nth() OK\n");
191 fail ("shishi_tkts_nth() failed\n");
193 /* shishi_tkts_add () */
194 res
= shishi_tkts_add (tktset
, NULL
);
195 if (res
== SHISHI_INVALID_TICKET
)
196 success ("shishi_tkts_add() OK\n");
198 fail ("shishi_tkts_add() failed\n");
200 /* shishi_tkts_remove () */
201 res
= shishi_tkts_remove (tktset
, 0);
202 if (res
== SHISHI_OK
)
203 success ("shishi_tkts_remove() OK\n");
205 fail ("shishi_tkts_remove() failed\n");
207 /* shishi_tkts_remove () */
208 res
= shishi_tkts_remove (tktset
, 42);
209 if (res
== SHISHI_OK
)
210 success ("shishi_tkts_remove() OK\n");
212 fail ("shishi_tkts_remove() failed\n");
214 /* shishi_tkts_remove () */
215 res
= shishi_tkts_remove (NULL
, 0);
216 if (res
== SHISHI_INVALID_TKTS
)
217 success ("shishi_tkts_remove() OK\n");
219 fail ("shishi_tkts_remove() failed\n");
222 n
= base64_from (buffer
, tkt1ticketb64
);
224 fail ("base64_from() failed\n");
225 n1
= shishi_der2asn1_ticket (handle
, buffer
, n
);
227 fail ("shishi_der2asn1_ticket() failed\n");
229 n
= base64_from (buffer
, tkt1enckdcreppartb64
);
231 fail ("base64_from() failed\n");
232 n2
= shishi_der2asn1_encasreppart (handle
, buffer
, n
);
234 fail ("shishi_der2asn1_encasreppart() failed\n");
236 n
= base64_from (buffer
, tkt1kdcrepb64
);
238 fail ("base64_from() failed\n");
239 n3
= shishi_der2asn1_asrep (handle
, buffer
, n
);
241 fail ("shishi_der2asn1_asrep() failed\n");
243 /* shishi_tkts_new() */
244 res
= shishi_tkts_new (tktset
, n1
, n2
, n3
);
245 if (res
== SHISHI_OK
)
246 success ("shishi_tkts_new() OK\n");
248 fail ("shishi_tkts_new() failed\n");
250 /* shishi_tkts_size () */
251 n
= shishi_tkts_size (tktset
);
253 printf ("shishi_tkts_size () => `%d'.\n", n
);
255 success ("shishi_tkts_size() OK\n");
257 fail ("shishi_tkts_size() failed\n");
259 /* shishi_tkts_nth () */
260 t1
= shishi_tkts_nth (tktset
, 0);
263 shishi_tkt_pretty_print (t1
, stdout
);
264 printf ("t1=%p\n", t1
);
267 success ("shishi_tkts_nth() OK\n");
269 fail ("shishi_tkts_nth() failed\n");
271 /* shishi_tkts_remove () */
272 res
= shishi_tkts_remove (tktset
, 0);
273 if (res
== SHISHI_OK
)
274 success ("shishi_tkts_remove() OK\n");
276 fail ("shishi_tkts_remove() failed\n");
278 /* shishi_tkts_size () */
279 n
= shishi_tkts_size (tktset
);
281 printf ("shishi_tkts_size () => `%d'.\n", n
);
283 success ("shishi_tkts_size() OK\n");
285 fail ("shishi_tkts_size() failed\n");
287 /* shishi_tkts_nth () */
288 t2
= shishi_tkts_nth (tktset
, 0);
290 success ("shishi_tkts_nth() OK\n");
292 fail ("shishi_tkts_nth() failed\n");
294 /* shishi_tkts_add () */
295 res
= shishi_tkts_add (tktset
, t1
);
296 if (res
== SHISHI_OK
)
297 success ("shishi_tkts_add() OK\n");
299 fail ("shishi_tkts_add() failed\n");
301 /* shishi_tkts_size () */
302 n
= shishi_tkts_size (tktset
);
304 printf ("shishi_tkts_size () => `%d'.\n", n
);
306 success ("shishi_tkts_size() OK\n");
308 fail ("shishi_tkts_size() failed\n");
311 n
= base64_from (buffer
, tkt2ticketb64
);
313 fail ("base64_from() failed\n");
314 n1
= shishi_der2asn1_ticket (handle
, buffer
, n
);
316 fail ("shishi_der2asn1_ticket() failed\n");
318 n
= base64_from (buffer
, tkt2enckdcreppartb64
);
320 fail ("base64_from() failed\n");
321 n2
= shishi_der2asn1_enctgsreppart (handle
, buffer
, n
);
323 fail ("shishi_der2asn1_enctgsreppart() failed\n");
325 n
= base64_from (buffer
, tkt2kdcrepb64
);
327 fail ("base64_from() failed\n");
328 n3
= shishi_der2asn1_tgsrep (handle
, buffer
, n
);
330 fail ("shishi_der2asn1_kdcrep() failed\n");
332 /* shishi_tkts_new() */
333 res
= shishi_tkts_new (tktset
, n1
, n2
, n3
);
334 if (res
== SHISHI_OK
)
335 success ("shishi_tkts_new() OK\n");
337 fail ("shishi_tkts_new() failed\n");
339 /* shishi_tkts_size () */
340 n
= shishi_tkts_size (tktset
);
342 printf ("shishi_tkts_size () => `%d'.\n", n
);
344 success ("shishi_tkts_size() OK\n");
346 fail ("shishi_tkts_size() failed\n");
348 /* shishi_tkts_nth () */
349 t2
= shishi_tkts_nth (tktset
, 1);
352 shishi_tkt_pretty_print (t2
, stdout
);
353 printf ("t2=%p\n", t2
);
356 success ("shishi_tkts_nth() OK\n");
358 fail ("shishi_tkts_nth() failed\n");
360 /* shishi_tkts_find () */
361 memset (&hint
, 0, sizeof (hint
));
362 hint
.server
= "host/latte.josefsson.org";
363 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
364 t3
= shishi_tkts_find (tktset
, &hint
);
366 printf ("t3=%p\n", t3
);
368 success ("shishi_tkts_find() for server OK\n");
370 fail ("shishi_tkts_find() for server failed\n");
372 /* shishi_tkts_find () */
373 memset (&hint
, 0, sizeof (hint
));
374 hint
.server
= "krbtgt/JOSEFSSON.ORG";
375 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
376 t3
= shishi_tkts_find (tktset
, &hint
);
378 success ("shishi_tkts_find() for server OK\n");
380 fail ("shishi_tkts_find() for server failed\n");
382 /* shishi_tkts_find () */
383 memset (&hint
, 0, sizeof (hint
));
385 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
386 t3
= shishi_tkts_find (tktset
, &hint
);
388 printf ("t3=%p\n", t3
);
390 success ("shishi_tkts_find() for client OK\n");
392 fail ("shishi_tkts_find() for client failed\n");
394 /* shishi_tkts_find () */
395 memset (&hint
, 0, sizeof (hint
));
397 t3
= shishi_tkts_find (tktset
, &hint
);
399 printf ("t3=%p\n", t3
);
401 success ("shishi_tkts_find() for client OK\n");
403 fail ("shishi_tkts_find() for client failed\n");
405 res
= shishi_tkts_to_file (tktset
, "tktset.tmp");
406 if (res
== SHISHI_OK
)
407 success ("shishi_tkts_to_file() OK\n");
409 fail ("shishi_tkts_to_file() failed\n");
411 /* shishi_tkts_add () */
412 res
= shishi_tkts_add (tktset
, t2
);
413 if (res
== SHISHI_OK
)
414 success ("shishi_tkts_add() OK\n");
416 fail ("shishi_tkts_add() failed\n");
418 /* shishi_tkts_add () */
419 res
= shishi_tkts_add (tktset
, t1
);
420 if (res
== SHISHI_OK
)
421 success ("shishi_tkts_add() OK\n");
423 fail ("shishi_tkts_add() failed\n");
425 /* shishi_tkts_remove () */
426 res
= shishi_tkts_remove (tktset
, 1);
427 if (res
== SHISHI_OK
)
428 success ("shishi_tkts_remove() OK\n");
430 fail ("shishi_tkts_remove() failed\n");
432 /* shishi_tkts_remove () */
433 res
= shishi_tkts_remove (tktset
, 1);
434 if (res
== SHISHI_OK
)
435 success ("shishi_tkts_remove() OK\n");
437 fail ("shishi_tkts_remove() failed\n");
439 memset (&hint
, 0, sizeof (hint
));
440 hint
.server
= "host/latte.josefsson.org";
441 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
442 t3
= shishi_tkts_find (tktset
, &hint
);
444 success ("shishi_tkts_find() for server OK\n");
446 fail ("shishi_tkts_find() for server failed\n");
448 memset (&hint
, 0, sizeof (hint
));
449 hint
.server
= "krbtgt/JOSEFSSON.ORG";
450 hint
.flags
= SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED
;
451 t3
= shishi_tkts_find (tktset
, &hint
);
453 success ("shishi_tkts_find() for server OK\n");
455 fail ("shishi_tkts_find() for server failed\n");
457 /* shishi_tkts_remove () */
458 res
= shishi_tkts_remove (tktset
, 0);
459 if (res
== SHISHI_OK
)
460 success ("shishi_tkts_remove() OK\n");
462 fail ("shishi_tkts_remove() failed\n");
464 /* shishi_tkts_remove () */
465 res
= shishi_tkts_remove (tktset
, 0);
466 if (res
== SHISHI_OK
)
467 success ("shishi_tkts_remove() OK\n");
469 fail ("shishi_tkts_remove() failed\n");
471 /* shishi_tkts_size () */
472 n
= shishi_tkts_size (tktset
);
474 printf ("shishi_tkts_size () => `%d'.\n", n
);
476 success ("shishi_tkts_size() OK\n");
478 fail ("shishi_tkts_size() failed\n");
480 /* shishi_tkts_done () */
481 shishi_tkts_done (&tktset
);
482 success ("shishi_tkts_done() OK\n");
484 shishi_tkt_done (t1
);
485 success ("shishi_tkt_done (t1) OK\n");
486 shishi_tkt_done (t2
);
487 success ("shishi_tkt_done (t2) OK\n");
489 /* shishi_tkts_done () */
490 shishi_tkts_done (NULL
);
491 success ("shishi_tkts_done() OK\n");
494 res
= shishi_tkts (handle
, &tktset
);
495 if (res
== SHISHI_OK
)
496 success ("shishi_tkts() OK\n");
498 fail ("shishi_tkts() failed\n");
500 /* shishi_tkts_from_file () */
501 res
= shishi_tkts_from_file (tktset
, "tktset.tmp");
502 if (res
== SHISHI_OK
)
503 success ("shishi_tkts_to_file() OK\n");
505 fail ("shishi_tkts_to_file() failed\n");
507 /* shishi_tkts_size () */
508 n
= shishi_tkts_size (tktset
);
510 printf ("shishi_tkts_size () => `%d'.\n", n
);
512 success ("shishi_tkts_size() OK\n");
514 fail ("shishi_tkts_size() failed\n");
516 /* shishi_tkts_nth () */
517 t1
= shishi_tkts_nth (tktset
, 0);
519 shishi_tkt_pretty_print (t1
, stdout
);
521 success ("shishi_tkts_nth() OK\n");
523 fail ("shishi_tkts_nth() failed\n");
525 /* shishi_tkts_nth () */
526 t2
= shishi_tkts_nth (tktset
, 1);
528 shishi_tkt_pretty_print (t2
, stdout
);
530 success ("shishi_tkts_nth() OK\n");
532 fail ("shishi_tkts_nth() failed\n");
534 /* DER encode and compare tkt1 ticket */
536 res
= shishi_a2d (handle
, shishi_tkt_ticket (t1
), buffer
, &n
);
537 if (res
== SHISHI_OK
)
538 success ("shishi_a2d() OK\n");
540 n
= 0, fail ("shishi_a2d() failed\n");
542 base64_to (buffer2
, buffer
, n
, BUFSIZ
);
543 if (strlen (buffer2
) == strlen (tkt1ticketb64
) &&
544 memcmp (buffer2
, tkt1ticketb64
, strlen (tkt1ticketb64
)) == 0)
545 success ("Ticket read OK\n");
547 fail ("Ticket read failed\n");
549 /* DER encode and compare tkt1 enckdcreppart */
551 res
= shishi_a2d (handle
, shishi_tkt_enckdcreppart (t1
), buffer
, &n
);
552 if (res
== SHISHI_OK
)
553 success ("shishi_a2d() OK\n");
555 n
= 0, fail ("shishi_a2d() failed\n");
557 base64_to (buffer2
, buffer
, n
, BUFSIZ
);
558 if (strlen (buffer2
) == strlen (tkt1enckdcreppartb64
) &&
559 memcmp (buffer2
, tkt1enckdcreppartb64
,
560 strlen (tkt1enckdcreppartb64
)) == 0)
561 success ("EncKDCRepPart read OK\n");
563 fail ("EncKDCRepPart read failed\n");
565 /* DER encode and compare tkt1 kdcrep */
567 res
= shishi_a2d (handle
, shishi_tkt_kdcrep (t1
), buffer
, &n
);
568 if (res
== SHISHI_OK
)
569 success ("shishi_a2d() OK\n");
571 n
= 0, fail ("shishi_a2d() failed\n");
573 base64_to (buffer2
, buffer
, n
, BUFSIZ
);
574 if (strlen (buffer2
) == strlen (tkt1kdcrepb64
) &&
575 memcmp (buffer2
, tkt1kdcrepb64
, strlen (tkt1kdcrepb64
)) == 0)
576 success ("KDC-REP read OK\n");
578 fail ("KDC-REP read failed\n");
580 /* DER encode and compare tkt2 ticket */
582 res
= shishi_a2d (handle
, shishi_tkt_ticket (t2
), buffer
, &n
);
583 if (res
== SHISHI_OK
)
584 success ("shishi_a2d() OK\n");
586 n
= 0, fail ("shishi_a2d() failed\n");
588 base64_to (buffer2
, buffer
, n
, BUFSIZ
);
589 if (strlen (buffer2
) == strlen (tkt2ticketb64
) &&
590 memcmp (buffer2
, tkt2ticketb64
, strlen (tkt2ticketb64
)) == 0)
591 success ("Ticket 2 read OK\n");
593 fail ("Ticket 2 read failed\n");
595 /* DER encode and compare tkt2 enckdcreppart */
597 res
= shishi_a2d (handle
, shishi_tkt_enckdcreppart (t2
), buffer
, &n
);
598 if (res
== SHISHI_OK
)
599 success ("shishi_a2d() OK\n");
601 n
= 0, fail ("shishi_a2d() failed\n");
603 base64_to (buffer2
, buffer
, n
, BUFSIZ
);
604 if (strlen (buffer2
) == strlen (tkt2enckdcreppartb64
) &&
605 memcmp (buffer2
, tkt2enckdcreppartb64
,
606 strlen (tkt2enckdcreppartb64
)) == 0)
607 success ("EncKDCRepPart 2 read OK\n");
609 fail ("EncKDCRepPart 2 read failed\n");
611 /* DER encode and compare tkt2 kdcrep */
613 res
= shishi_a2d (handle
, shishi_tkt_kdcrep (t2
), buffer
, &n
);
614 if (res
== SHISHI_OK
)
615 success ("shishi_a2d() OK\n");
617 n
= 0, fail ("shishi_a2d() failed\n");
619 base64_to (buffer2
, buffer
, n
, BUFSIZ
);
620 if (strlen (buffer2
) == strlen (tkt2kdcrepb64
) &&
621 memcmp (buffer2
, tkt2kdcrepb64
, strlen (tkt2kdcrepb64
)) == 0)
622 success ("KDC-REP 2 read OK\n");
624 fail ("KDC-REP 2 read failed\n");
626 res
= unlink ("tktset.tmp");
628 success ("unlink() OK\n");
630 fail ("unlink() failed\n");
632 shishi_tkt_done (t1
);
633 success ("shishi_tkt_done (t1) OK\n");
634 shishi_tkt_done (t2
);
635 success ("shishi_tkt_done (t2) OK\n");
637 /* shishi_tkts_done () */
638 shishi_tkts_done (&tktset
);
639 success ("shishi_tkts_done() OK\n");
641 shishi_done (handle
);
644 printf ("Ticket set self tests done with %d errors\n", error_count
);
646 return error_count
? 1 : 0;