Branch data Line data Source code
1 : : /* ticketset.c --- Shishi ticketset self tests.
2 : : * Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Simon Josefsson
3 : : *
4 : : * This file is part of Shishi.
5 : : *
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 3 of the License, or
9 : : * (at your option) any later version.
10 : : *
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.
15 : : *
16 : : * You should have received a copy of the GNU General Public License
17 : : * along with Shishi; if not, see http://www.gnu.org/licenses or write
18 : : * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
19 : : * Floor, Boston, MA 02110-1301, USA
20 : : *
21 : : */
22 : :
23 : : #include "utils.c"
24 : :
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";
38 : :
39 : : static const char tkt1enckdcreppartb64[] =
40 : : "eYGyMIGvoCMwIaADAgEQoRoEGPF/LFgc3IYq3+AZofutur+wsK5i6vSbN6EcMBow"
41 : : "GKADAgEAoREYDzE5NzAwMTAxMDAwMDAwWqIGAgTl7iQgpAcDBQAAQAAApREYDzIw"
42 : : "MDIxMjExMTM0MDU0WqcRGA8yMDAyMTIxMTEzNTczNFqpDxsNSk9TRUZTU09OLk9S"
43 : : "R6oiMCCgAwIBAaEZMBcbBmtyYnRndBsNSk9TRUZTU09OLk9SRw==";
44 : :
45 : : static const char tkt1ticketb64[] =
46 : : "YYH/MIH8oAMCAQWhDxsNSk9TRUZTU09OLk9SR6IiMCCgAwIBAaEZMBcbBmtyYnRn"
47 : : "dBsNSk9TRUZTU09OLk9SR6OBvzCBvKADAgEQoQMCAQGiga8EgayqttjMpRNM2iVV"
48 : : "R5RjtMNH3i75hjnUiXQ7UeT7DMShJ5IxiBr09dggaZzTAHrBAvV85xON3p39rMpm"
49 : : "Cg9utizrxzT1JXruoGF/+ofuT7lEDfRr437QJD5WuOtlfmkM2i5s2bGYZlHNdBon"
50 : : "apJCcMeUSS45HEoM5iy0dK2JeaOliOVKTDpX9gOayKSIFYnuzIb+cg1ATHm29ahK"
51 : : "5AY+LU9E4v8Yj1/02srRuERA";
52 : :
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=";
67 : :
68 : : static const char tkt2enckdcreppartb64[] =
69 : : "eoHJMIHGoCMwIaADAgEQoRoEGFS29KeMuXZDeqcEud/gWHln/db7bje26aEcMBow"
70 : : "GKADAgEAoREYDzE5NzAwMTAxMDAwMDAwWqIGAgScLHDdpAcDBQAAAAAApREYDzIw"
71 : : "MDIxMjExMTM0MDU0WqYRGA8yMDAyMTIxMTEzNDEwNFqnERgPMjAwMjEyMTExMzU3"
72 : : "MzRaqQ8bDUpPU0VGU1NPTi5PUkeqJjAkoAMCAQGhHTAbGwRob3N0GxNsYXR0ZS5q"
73 : : "b3NlZnNzb24ub3Jn";
74 : :
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==";
82 : :
83 : : #define BUFSIZE 5000
84 : :
85 : : void
86 : 1 : test (Shishi * handle)
87 : : {
88 : : Shishi_tkts *tktset;
89 : : Shishi_tkts_hint hint;
90 : : Shishi_tkt *t1, *t2, *t3;
91 : : Shishi_asn1 tkt1asn1, tkt1asn2, tkt1asn3;
92 : : Shishi_asn1 tkt2asn1, tkt2asn2, tkt2asn3;
93 : : char buffer[BUFSIZE];
94 : : char buffer2[BUFSIZE];
95 : : char *buf;
96 : : char *p, *q;
97 : : size_t n;
98 : : int res;
99 : :
100 : : /* shishi_tkts_default_file() */
101 : 1 : p = strdup (shishi_tkts_default_file (handle));
102 [ - + ]: 1 : if (debug)
103 [ # # ]: 0 : printf ("shishi_tkts_default_file () => `%s'.\n", p ? p : "<null>");
104 [ + - ]: 1 : if (p)
105 : 1 : success ("shishi_tkts_default_file() OK\n");
106 : : else
107 : 0 : fail ("shishi_tkts_default_file() failed\n");
108 : :
109 : : /* shishi_tkts_default_file_set() */
110 : 1 : shishi_tkts_default_file_set (handle, "foo");
111 : 1 : q = strdup (shishi_tkts_default_file (handle));
112 [ - + ]: 1 : if (debug)
113 [ # # ]: 0 : printf ("shishi_tkts_default_file () => `%s'.\n", q ? q : "<null>");
114 [ + - ][ + - ]: 2 : if (q && strcmp (q, "foo") == 0)
115 : 1 : success ("shishi_tkts_default_file_set() OK\n");
116 : : else
117 : 0 : fail ("shishi_tkts_default_file_set() failed\n");
118 : 1 : free (q);
119 : :
120 : : /* shishi_tkts_default_file_set() */
121 : 1 : shishi_tkts_default_file_set (handle, NULL);
122 : 1 : q = strdup (shishi_tkts_default_file (handle));
123 [ - + ]: 1 : if (debug)
124 [ # # ]: 0 : printf ("shishi_tkts_default_file () => `%s'.\n", q ? q : "<null>");
125 [ + - ][ + - ]: 2 : if (p && q && strcmp (p, q) == 0)
[ + - ]
126 : 1 : success ("shishi_tkts_default_file_set() OK\n");
127 : : else
128 : 0 : fail ("shishi_tkts_default_file_set() failed\n");
129 : 1 : free (q);
130 : 1 : free (p);
131 : :
132 : : /* shishi_tkts () */
133 : 1 : res = shishi_tkts (handle, &tktset);
134 [ + - ]: 1 : if (res == SHISHI_OK)
135 : 1 : success ("shishi_tkts() OK\n");
136 : : else
137 : 0 : fail ("shishi_tkts() failed\n");
138 : :
139 : : /* shishi_tkts_size () */
140 : 1 : n = shishi_tkts_size (tktset);
141 [ - + ]: 1 : if (debug)
142 : 0 : printf ("shishi_tkts_size () => `%d'.\n", n);
143 [ + - ]: 1 : if (n == 0)
144 : 1 : success ("shishi_tkts_size() OK\n");
145 : : else
146 : 0 : fail ("shishi_tkts_size() failed\n");
147 : :
148 : : /* shishi_tkts_nth () */
149 : 1 : t1 = shishi_tkts_nth (tktset, 0);
150 [ + - ]: 1 : if (t1 == NULL)
151 : 1 : success ("shishi_tkts_nth() OK\n");
152 : : else
153 : 0 : fail ("shishi_tkts_nth() failed\n");
154 : :
155 : : /* shishi_tkts_nth () */
156 : 1 : t1 = shishi_tkts_nth (tktset, 42);
157 [ + - ]: 1 : if (t1 == NULL)
158 : 1 : success ("shishi_tkts_nth() OK\n");
159 : : else
160 : 0 : fail ("shishi_tkts_nth() failed\n");
161 : :
162 : : /* shishi_tkts_add () */
163 : 1 : res = shishi_tkts_add (tktset, NULL);
164 [ + - ]: 1 : if (res == SHISHI_INVALID_TICKET)
165 : 1 : success ("shishi_tkts_add() OK\n");
166 : : else
167 : 0 : fail ("shishi_tkts_add() failed\n");
168 : :
169 : : /* shishi_tkts_remove () */
170 : 1 : res = shishi_tkts_remove (tktset, 0);
171 [ + - ]: 1 : if (res == SHISHI_OK)
172 : 1 : success ("shishi_tkts_remove() OK\n");
173 : : else
174 : 0 : fail ("shishi_tkts_remove() failed\n");
175 : :
176 : : /* shishi_tkts_remove () */
177 : 1 : res = shishi_tkts_remove (tktset, 42);
178 [ + - ]: 1 : if (res == SHISHI_OK)
179 : 1 : success ("shishi_tkts_remove() OK\n");
180 : : else
181 : 0 : fail ("shishi_tkts_remove() failed\n");
182 : :
183 : : /* shishi_tkts_remove () */
184 : 1 : res = shishi_tkts_remove (NULL, 0);
185 [ + - ]: 1 : if (res == SHISHI_INVALID_TKTS)
186 : 1 : success ("shishi_tkts_remove() OK\n");
187 : : else
188 : 0 : fail ("shishi_tkts_remove() failed\n");
189 : :
190 : : /* create ticket */
191 : 1 : n = BUFSIZE;
192 [ - + ]: 1 : if (!base64_decode (tkt1ticketb64, strlen (tkt1ticketb64), buffer, &n))
193 : 0 : fail ("base64_decode() failed\n");
194 : 1 : tkt1asn1 = shishi_der2asn1_ticket (handle, buffer, n);
195 [ - + ]: 1 : if (!tkt1asn1)
196 : 0 : fail ("shishi_der2asn1_ticket() failed\n");
197 : :
198 : 1 : n = BUFSIZE;
199 [ - + ]: 1 : if (!base64_decode (tkt1enckdcreppartb64, strlen (tkt1enckdcreppartb64),
200 : : buffer, &n))
201 : 0 : fail ("base64_decode() failed\n");
202 : 1 : tkt1asn2 = shishi_der2asn1_encasreppart (handle, buffer, n);
203 [ - + ]: 1 : if (!tkt1asn2)
204 : 0 : fail ("shishi_der2asn1_encasreppart() failed\n");
205 : :
206 : 1 : n = BUFSIZE;
207 [ - + ]: 1 : if (!base64_decode (tkt1kdcrepb64, strlen (tkt1kdcrepb64), buffer, &n))
208 : 0 : fail ("base64_decode() failed\n");
209 : 1 : tkt1asn3 = shishi_der2asn1_asrep (handle, buffer, n);
210 [ - + ]: 1 : if (!tkt1asn3)
211 : 0 : fail ("shishi_der2asn1_asrep() failed\n");
212 : :
213 : : /* shishi_tkts_new() */
214 : 1 : res = shishi_tkts_new (tktset, tkt1asn1, tkt1asn2, tkt1asn3);
215 [ + - ]: 1 : if (res == SHISHI_OK)
216 : 1 : success ("shishi_tkts_new() OK\n");
217 : : else
218 : 0 : fail ("shishi_tkts_new() failed\n");
219 : :
220 : : /* shishi_tkts_size () */
221 : 1 : n = shishi_tkts_size (tktset);
222 [ - + ]: 1 : if (debug)
223 : 0 : printf ("shishi_tkts_size () => `%d'.\n", n);
224 [ + - ]: 1 : if (n == 1)
225 : 1 : success ("shishi_tkts_size() OK\n");
226 : : else
227 : 0 : fail ("shishi_tkts_size() failed\n");
228 : :
229 : : /* shishi_tkts_nth () */
230 : 1 : t1 = shishi_tkts_nth (tktset, 0);
231 [ - + ]: 1 : if (debug)
232 : : {
233 : 0 : shishi_tkt_pretty_print (t1, stdout);
234 : 0 : printf ("t1=%p\n", t1);
235 : : }
236 [ + - ]: 1 : if (t1)
237 : 1 : success ("shishi_tkts_nth() OK\n");
238 : : else
239 : 0 : fail ("shishi_tkts_nth() failed\n");
240 : :
241 : : /* shishi_tkts_remove () */
242 : 1 : res = shishi_tkts_remove (tktset, 0);
243 [ + - ]: 1 : if (res == SHISHI_OK)
244 : 1 : success ("shishi_tkts_remove() OK\n");
245 : : else
246 : 0 : fail ("shishi_tkts_remove() failed\n");
247 : :
248 : : /* shishi_tkts_size () */
249 : 1 : n = shishi_tkts_size (tktset);
250 [ - + ]: 1 : if (debug)
251 : 0 : printf ("shishi_tkts_size () => `%d'.\n", n);
252 [ + - ]: 1 : if (n == 0)
253 : 1 : success ("shishi_tkts_size() OK\n");
254 : : else
255 : 0 : fail ("shishi_tkts_size() failed\n");
256 : :
257 : : /* shishi_tkts_nth () */
258 : 1 : t2 = shishi_tkts_nth (tktset, 0);
259 [ + - ]: 1 : if (t2 == NULL)
260 : 1 : success ("shishi_tkts_nth() OK\n");
261 : : else
262 : 0 : fail ("shishi_tkts_nth() failed\n");
263 : :
264 : : /* shishi_tkts_add () */
265 : 1 : res = shishi_tkts_add (tktset, t1);
266 [ + - ]: 1 : if (res == SHISHI_OK)
267 : 1 : success ("shishi_tkts_add() OK\n");
268 : : else
269 : 0 : fail ("shishi_tkts_add() failed\n");
270 : :
271 : : /* shishi_tkts_size () */
272 : 1 : n = shishi_tkts_size (tktset);
273 [ - + ]: 1 : if (debug)
274 : 0 : printf ("shishi_tkts_size () => `%d'.\n", n);
275 [ + - ]: 1 : if (n == 1)
276 : 1 : success ("shishi_tkts_size() OK\n");
277 : : else
278 : 0 : fail ("shishi_tkts_size() failed\n");
279 : :
280 : : /* create ticket */
281 : 1 : n = BUFSIZE;
282 [ - + ]: 1 : if (!base64_decode (tkt2ticketb64, strlen (tkt2ticketb64), buffer, &n))
283 : 0 : fail ("base64_decode() failed\n");
284 : 1 : tkt2asn1 = shishi_der2asn1_ticket (handle, buffer, n);
285 [ - + ]: 1 : if (!tkt2asn1)
286 : 0 : fail ("shishi_der2asn1_ticket() failed\n");
287 : :
288 : 1 : n = BUFSIZE;
289 [ - + ]: 1 : if (!base64_decode (tkt2enckdcreppartb64, strlen (tkt2enckdcreppartb64),
290 : : buffer, &n))
291 : 0 : fail ("base64_decode() failed\n");
292 : 1 : tkt2asn2 = shishi_der2asn1_enctgsreppart (handle, buffer, n);
293 [ - + ]: 1 : if (!tkt2asn2)
294 : 0 : fail ("shishi_der2asn1_enctgsreppart() failed\n");
295 : :
296 : 1 : n = BUFSIZE;
297 [ - + ]: 1 : if (!base64_decode (tkt2kdcrepb64, strlen (tkt2kdcrepb64), buffer, &n))
298 : 0 : fail ("base64_decode() failed\n");
299 : 1 : tkt2asn3 = shishi_der2asn1_tgsrep (handle, buffer, n);
300 [ - + ]: 1 : if (!tkt2asn3)
301 : 0 : fail ("shishi_der2asn1_kdcrep() failed\n");
302 : :
303 : : /* shishi_tkts_new() */
304 : 1 : res = shishi_tkts_new (tktset, tkt2asn1, tkt2asn2, tkt2asn3);
305 [ + - ]: 1 : if (res == SHISHI_OK)
306 : 1 : success ("shishi_tkts_new() OK\n");
307 : : else
308 : 0 : fail ("shishi_tkts_new() failed\n");
309 : :
310 : : /* shishi_tkts_size () */
311 : 1 : n = shishi_tkts_size (tktset);
312 [ - + ]: 1 : if (debug)
313 : 0 : printf ("shishi_tkts_size () => `%d'.\n", n);
314 [ + - ]: 1 : if (n == 2)
315 : 1 : success ("shishi_tkts_size() OK\n");
316 : : else
317 : 0 : fail ("shishi_tkts_size() failed\n");
318 : :
319 : : /* shishi_tkts_nth () */
320 : 1 : t2 = shishi_tkts_nth (tktset, 1);
321 [ - + ]: 1 : if (debug)
322 : : {
323 : 0 : shishi_tkt_pretty_print (t2, stdout);
324 : 0 : printf ("t2=%p\n", t2);
325 : : }
326 [ + - ]: 1 : if (t2)
327 : 1 : success ("shishi_tkts_nth() OK\n");
328 : : else
329 : 0 : fail ("shishi_tkts_nth() failed\n");
330 : :
331 : : /* shishi_tkts_find () */
332 : 1 : memset (&hint, 0, sizeof (hint));
333 : 1 : hint.server = (char *) "host/latte.josefsson.org";
334 : 1 : hint.flags = SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED;
335 : 1 : t3 = shishi_tkts_find (tktset, &hint);
336 [ - + ]: 1 : if (debug)
337 : 0 : printf ("t3=%p\n", t3);
338 [ + - ]: 1 : if (t3 == t2)
339 : 1 : success ("shishi_tkts_find() for server OK\n");
340 : : else
341 : 0 : fail ("shishi_tkts_find() for server failed\n");
342 : :
343 : : /* shishi_tkts_find () */
344 : 1 : memset (&hint, 0, sizeof (hint));
345 : 1 : hint.server = (char *) "krbtgt/JOSEFSSON.ORG";
346 : 1 : hint.flags = SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED;
347 : 1 : t3 = shishi_tkts_find (tktset, &hint);
348 [ + - ]: 1 : if (t3 == t1)
349 : 1 : success ("shishi_tkts_find() for server OK\n");
350 : : else
351 : 0 : fail ("shishi_tkts_find() for server failed\n");
352 : :
353 : : /* shishi_tkts_find () */
354 : 1 : memset (&hint, 0, sizeof (hint));
355 : 1 : hint.client = (char *) "jas";
356 : 1 : hint.flags = SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED;
357 : 1 : t3 = shishi_tkts_find (tktset, &hint);
358 [ - + ]: 1 : if (debug)
359 : 0 : printf ("t3=%p\n", t3);
360 [ + - ]: 1 : if (t3 == t1)
361 : 1 : success ("shishi_tkts_find() for client OK\n");
362 : : else
363 : 0 : fail ("shishi_tkts_find() for client failed\n");
364 : :
365 : : /* shishi_tkts_find () */
366 : 1 : memset (&hint, 0, sizeof (hint));
367 : 1 : hint.client = (char *) "jas";
368 : 1 : t3 = shishi_tkts_find (tktset, &hint);
369 [ - + ]: 1 : if (debug)
370 : 0 : printf ("t3=%p\n", t3);
371 [ + - ]: 1 : if (t3 == NULL)
372 : 1 : success ("shishi_tkts_find() for client2 OK\n");
373 : : else
374 : 0 : fail ("shishi_tkts_find() for client2 failed\n");
375 : :
376 : 1 : res = shishi_tkts_to_file (tktset, "tktset.tmp");
377 [ + - ]: 1 : if (res == SHISHI_OK)
378 : 1 : success ("shishi_tkts_to_file() OK\n");
379 : : else
380 : 0 : fail ("shishi_tkts_to_file() failed\n");
381 : :
382 : : /* shishi_tkts_add () */
383 : 1 : res = shishi_tkts_add (tktset, t2);
384 [ + - ]: 1 : if (res == SHISHI_OK)
385 : 1 : success ("shishi_tkts_add() OK\n");
386 : : else
387 : 0 : fail ("shishi_tkts_add() failed\n");
388 : :
389 : : /* shishi_tkts_add () */
390 : 1 : res = shishi_tkts_add (tktset, t1);
391 [ + - ]: 1 : if (res == SHISHI_OK)
392 : 1 : success ("shishi_tkts_add() OK\n");
393 : : else
394 : 0 : fail ("shishi_tkts_add() failed\n");
395 : :
396 : : /* shishi_tkts_remove () */
397 : 1 : res = shishi_tkts_remove (tktset, 1);
398 [ + - ]: 1 : if (res == SHISHI_OK)
399 : 1 : success ("shishi_tkts_remove() OK\n");
400 : : else
401 : 0 : fail ("shishi_tkts_remove() failed\n");
402 : :
403 : : /* shishi_tkts_remove () */
404 : 1 : res = shishi_tkts_remove (tktset, 1);
405 [ + - ]: 1 : if (res == SHISHI_OK)
406 : 1 : success ("shishi_tkts_remove() OK\n");
407 : : else
408 : 0 : fail ("shishi_tkts_remove() failed\n");
409 : :
410 : 1 : memset (&hint, 0, sizeof (hint));
411 : 1 : hint.server = (char *) "host/latte.josefsson.org";
412 : 1 : hint.flags = SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED;
413 : 1 : t3 = shishi_tkts_find (tktset, &hint);
414 [ + - ]: 1 : if (t3 == NULL)
415 : 1 : success ("shishi_tkts_find() for server OK\n");
416 : : else
417 : 0 : fail ("shishi_tkts_find() for server failed\n");
418 : :
419 : 1 : memset (&hint, 0, sizeof (hint));
420 : 1 : hint.server = (char *) "krbtgt/JOSEFSSON.ORG";
421 : 1 : hint.flags = SHISHI_TKTSHINTFLAGS_ACCEPT_EXPIRED;
422 : 1 : t3 = shishi_tkts_find (tktset, &hint);
423 [ + - ]: 1 : if (t3 == t1)
424 : 1 : success ("shishi_tkts_find() for server OK\n");
425 : : else
426 : 0 : fail ("shishi_tkts_find() for server failed\n");
427 : :
428 : : /* shishi_tkts_remove () */
429 : 1 : res = shishi_tkts_remove (tktset, 0);
430 [ + - ]: 1 : if (res == SHISHI_OK)
431 : 1 : success ("shishi_tkts_remove() OK\n");
432 : : else
433 : 0 : fail ("shishi_tkts_remove() failed\n");
434 : :
435 : : /* shishi_tkts_remove () */
436 : 1 : res = shishi_tkts_remove (tktset, 0);
437 [ + - ]: 1 : if (res == SHISHI_OK)
438 : 1 : success ("shishi_tkts_remove() OK\n");
439 : : else
440 : 0 : fail ("shishi_tkts_remove() failed\n");
441 : :
442 : : /* shishi_tkts_size () */
443 : 1 : n = shishi_tkts_size (tktset);
444 [ - + ]: 1 : if (debug)
445 : 0 : printf ("shishi_tkts_size () => `%d'.\n", n);
446 [ + - ]: 1 : if (n == 0)
447 : 1 : success ("shishi_tkts_size() OK\n");
448 : : else
449 : 0 : fail ("shishi_tkts_size() failed\n");
450 : :
451 : : /* shishi_tkts_done () */
452 : 1 : shishi_tkts_done (&tktset);
453 : 1 : success ("shishi_tkts_done() OK\n");
454 : :
455 : 1 : shishi_tkt_done (t1);
456 : 1 : success ("shishi_tkt_done (t1) OK\n");
457 : 1 : shishi_tkt_done (t2);
458 : 1 : success ("shishi_tkt_done (t2) OK\n");
459 : :
460 : : /* shishi_tkts_done () */
461 : 1 : shishi_tkts_done (NULL);
462 : 1 : success ("shishi_tkts_done() OK\n");
463 : :
464 : : /* shishi_tkts () */
465 : 1 : res = shishi_tkts (handle, &tktset);
466 [ + - ]: 1 : if (res == SHISHI_OK)
467 : 1 : success ("shishi_tkts() OK\n");
468 : : else
469 : 0 : fail ("shishi_tkts() failed\n");
470 : :
471 : : /* shishi_tkts_from_file () */
472 : 1 : res = shishi_tkts_from_file (tktset, "tktset.tmp");
473 [ + - ]: 1 : if (res == SHISHI_OK)
474 : 1 : success ("shishi_tkts_from_file() OK\n");
475 : : else
476 : 0 : fail ("shishi_tkts_from_file() failed\n");
477 : :
478 : : /* shishi_tkts_size () */
479 : 1 : n = shishi_tkts_size (tktset);
480 [ - + ]: 1 : if (debug)
481 : 0 : printf ("shishi_tkts_size () => `%d'.\n", n);
482 [ + - ]: 1 : if (n == 2)
483 : 1 : success ("shishi_tkts_size() OK\n");
484 : : else
485 : 0 : fail ("shishi_tkts_size() failed\n");
486 : :
487 : : /* shishi_tkts_nth () */
488 : 1 : t1 = shishi_tkts_nth (tktset, 0);
489 [ - + ]: 1 : if (debug)
490 : 0 : shishi_tkt_pretty_print (t1, stdout);
491 [ + - ]: 1 : if (t1)
492 : 1 : success ("shishi_tkts_nth() OK\n");
493 : : else
494 : 0 : fail ("shishi_tkts_nth() failed\n");
495 : :
496 : : /* shishi_tkts_nth () */
497 : 1 : t2 = shishi_tkts_nth (tktset, 1);
498 [ - + ]: 1 : if (debug)
499 : 0 : shishi_tkt_pretty_print (t2, stdout);
500 [ + - ]: 1 : if (t2)
501 : 1 : success ("shishi_tkts_nth() OK\n");
502 : : else
503 : 0 : fail ("shishi_tkts_nth() failed\n");
504 : :
505 : : /* DER encode and compare tkt1 ticket */
506 : 1 : res = shishi_asn1_to_der (handle, shishi_tkt_ticket (t1), &buf, &n);
507 [ + - ]: 1 : if (res == SHISHI_OK)
508 : 1 : success ("shishi_asn1_to_der() OK\n");
509 : : else
510 : 0 : n = 0, fail ("shishi_asn1_to_der() failed\n");
511 : :
512 : 1 : base64_encode (buf, n, buffer2, BUFSIZE);
513 : 1 : free (buf);
514 [ + - + - ]: 2 : if (strlen (buffer2) == strlen (tkt1ticketb64) &&
515 : 1 : memcmp (buffer2, tkt1ticketb64, strlen (tkt1ticketb64)) == 0)
516 : 1 : success ("Ticket read OK\n");
517 : : else
518 : 0 : fail ("Ticket read failed\n");
519 : :
520 : : /* DER encode and compare tkt1 enckdcreppart */
521 : 1 : res = shishi_asn1_to_der (handle, shishi_tkt_enckdcreppart (t1), &buf, &n);
522 [ + - ]: 1 : if (res == SHISHI_OK)
523 : 1 : success ("shishi_asn1_to_der() OK\n");
524 : : else
525 : 0 : n = 0, fail ("shishi_asn1_to_der() failed\n");
526 : :
527 : 1 : base64_encode (buf, n, buffer2, BUFSIZE);
528 : 1 : free (buf);
529 [ + - + - ]: 2 : if (strlen (buffer2) == strlen (tkt1enckdcreppartb64) &&
530 : : memcmp (buffer2, tkt1enckdcreppartb64,
531 : 1 : strlen (tkt1enckdcreppartb64)) == 0)
532 : 1 : success ("EncKDCRepPart read OK\n");
533 : : else
534 : 0 : fail ("EncKDCRepPart read failed\n");
535 : :
536 : : /* DER encode and compare tkt1 kdcrep */
537 : 1 : res = shishi_asn1_to_der (handle, shishi_tkt_kdcrep (t1), &buf, &n);
538 [ + - ]: 1 : if (res == SHISHI_OK)
539 : 1 : success ("shishi_asn1_to_der() OK\n");
540 : : else
541 : 0 : n = 0, fail ("shishi_asn1_to_der() failed\n");
542 : :
543 : 1 : base64_encode (buf, n, buffer2, BUFSIZE);
544 : 1 : free (buf);
545 [ + - + - ]: 2 : if (strlen (buffer2) == strlen (tkt1kdcrepb64) &&
546 : 1 : memcmp (buffer2, tkt1kdcrepb64, strlen (tkt1kdcrepb64)) == 0)
547 : 1 : success ("KDC-REP read OK\n");
548 : : else
549 : 0 : fail ("KDC-REP read failed\n");
550 : :
551 : : /* DER encode and compare tkt2 ticket */
552 : 1 : res = shishi_asn1_to_der (handle, shishi_tkt_ticket (t2), &buf, &n);
553 [ + - ]: 1 : if (res == SHISHI_OK)
554 : 1 : success ("shishi_asn1_to_der() OK\n");
555 : : else
556 : 0 : n = 0, fail ("shishi_asn1_to_der() failed\n");
557 : :
558 : 1 : base64_encode (buf, n, buffer2, BUFSIZE);
559 : 1 : free (buf);
560 [ + - + - ]: 2 : if (strlen (buffer2) == strlen (tkt2ticketb64) &&
561 : 1 : memcmp (buffer2, tkt2ticketb64, strlen (tkt2ticketb64)) == 0)
562 : 1 : success ("Ticket 2 read OK\n");
563 : : else
564 : 0 : fail ("Ticket 2 read failed\n");
565 : :
566 : : /* DER encode and compare tkt2 enckdcreppart */
567 : 1 : res = shishi_asn1_to_der (handle, shishi_tkt_enckdcreppart (t2), &buf, &n);
568 [ + - ]: 1 : if (res == SHISHI_OK)
569 : 1 : success ("shishi_asn1_to_der() OK\n");
570 : : else
571 : 0 : n = 0, fail ("shishi_asn1_to_der() failed\n");
572 : :
573 : 1 : base64_encode (buf, n, buffer2, BUFSIZE);
574 : 1 : free (buf);
575 [ + - + - ]: 2 : if (strlen (buffer2) == strlen (tkt2enckdcreppartb64) &&
576 : : memcmp (buffer2, tkt2enckdcreppartb64,
577 : 1 : strlen (tkt2enckdcreppartb64)) == 0)
578 : 1 : success ("EncKDCRepPart 2 read OK\n");
579 : : else
580 : 0 : fail ("EncKDCRepPart 2 read failed\n");
581 : :
582 : : /* DER encode and compare tkt2 kdcrep */
583 : 1 : res = shishi_asn1_to_der (handle, shishi_tkt_kdcrep (t2), &buf, &n);
584 [ + - ]: 1 : if (res == SHISHI_OK)
585 : 1 : success ("shishi_asn1_to_der() OK\n");
586 : : else
587 : 0 : n = 0, fail ("shishi_asn1_to_der() failed\n");
588 : :
589 : 1 : base64_encode (buf, n, buffer2, BUFSIZE);
590 : 1 : free (buf);
591 [ + - + - ]: 2 : if (strlen (buffer2) == strlen (tkt2kdcrepb64) &&
592 : 1 : memcmp (buffer2, tkt2kdcrepb64, strlen (tkt2kdcrepb64)) == 0)
593 : 1 : success ("KDC-REP 2 read OK\n");
594 : : else
595 : 0 : fail ("KDC-REP 2 read failed\n");
596 : :
597 : 1 : res = unlink ("tktset.tmp");
598 [ + - ]: 1 : if (res == 0)
599 : 1 : success ("unlink() OK\n");
600 : : else
601 : 0 : fail ("unlink() failed\n");
602 : :
603 : 1 : shishi_tkt_done (t1);
604 : 1 : success ("shishi_tkt_done (t1) OK\n");
605 : 1 : shishi_tkt_done (t2);
606 : 1 : success ("shishi_tkt_done (t2) OK\n");
607 : :
608 : : /* shishi_tkts_done () */
609 : 1 : shishi_tkts_done (&tktset);
610 : 1 : success ("shishi_tkts_done() OK\n");
611 : :
612 : 1 : shishi_asn1_done (handle, tkt1asn1);
613 : 1 : shishi_asn1_done (handle, tkt1asn2);
614 : 1 : shishi_asn1_done (handle, tkt1asn3);
615 : 1 : shishi_asn1_done (handle, tkt2asn1);
616 : 1 : shishi_asn1_done (handle, tkt2asn2);
617 : 1 : shishi_asn1_done (handle, tkt2asn3);
618 : 1 : }
|