Branch data Line data Source code
1 : : /* obsolete.c --- Obsolete functions kept around for backwards compatibility.
2 : : * Copyright (C) 2002-2012 Simon Josefsson
3 : : *
4 : : * This file is part of GNU SASL Library.
5 : : *
6 : : * GNU SASL Library is free software; you can redistribute it and/or
7 : : * modify it under the terms of the GNU Lesser General Public License
8 : : * as published by the Free Software Foundation; either version 2.1 of
9 : : * the License, or (at your option) any later version.
10 : : *
11 : : * GNU SASL Library 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.
15 : : *
16 : : * You should have received a copy of the GNU Lesser General Public
17 : : * License License along with GNU SASL Library; if not, write to the
18 : : * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 : : * Boston, MA 02110-1301, USA.
20 : : *
21 : : */
22 : :
23 : : #include "internal.h"
24 : :
25 : : #if USE_DIGEST_MD5
26 : : #include "qop.h"
27 : : #endif
28 : :
29 : : /**
30 : : * gsasl_client_listmech:
31 : : * @ctx: libgsasl handle.
32 : : * @out: output character array.
33 : : * @outlen: input maximum size of output character array, on output
34 : : * contains actual length of output array.
35 : : *
36 : : * Write SASL names, separated by space, of mechanisms supported by
37 : : * the libgsasl client to the output array. To find out how large the
38 : : * output array must be, call this function with a NULL @out
39 : : * parameter.
40 : : *
41 : : * Return value: Returns %GSASL_OK if successful, or error code.
42 : : *
43 : : * Deprecated: Use gsasl_client_mechlist() instead.
44 : : **/
45 : : int
46 : 1 : gsasl_client_listmech (Gsasl * ctx, char *out, size_t * outlen)
47 : : {
48 : : char *tmp;
49 : : int rc;
50 : :
51 : 1 : rc = gsasl_client_mechlist (ctx, &tmp);
52 : :
53 [ + - ]: 1 : if (rc == GSASL_OK)
54 : : {
55 : 1 : size_t tmplen = strlen (tmp);
56 : :
57 [ - + ]: 1 : if (tmplen >= *outlen)
58 : : {
59 : 0 : free (tmp);
60 : 0 : return GSASL_TOO_SMALL_BUFFER;
61 : : }
62 : :
63 [ + - ]: 1 : if (out)
64 : 1 : strcpy (out, tmp);
65 : 1 : *outlen = tmplen + 1;
66 : 1 : free (tmp);
67 : : }
68 : :
69 : 1 : return rc;
70 : : }
71 : :
72 : : /**
73 : : * gsasl_server_listmech:
74 : : * @ctx: libgsasl handle.
75 : : * @out: output character array.
76 : : * @outlen: input maximum size of output character array, on output
77 : : * contains actual length of output array.
78 : : *
79 : : * Write SASL names, separated by space, of mechanisms supported by
80 : : * the libgsasl server to the output array. To find out how large the
81 : : * output array must be, call this function with a NULL @out
82 : : * parameter.
83 : : *
84 : : * Return value: Returns %GSASL_OK if successful, or error code.
85 : : *
86 : : * Deprecated: Use gsasl_server_mechlist() instead.
87 : : **/
88 : : int
89 : 1 : gsasl_server_listmech (Gsasl * ctx, char *out, size_t * outlen)
90 : : {
91 : : char *tmp;
92 : : int rc;
93 : :
94 : 1 : rc = gsasl_server_mechlist (ctx, &tmp);
95 : :
96 [ + - ]: 1 : if (rc == GSASL_OK)
97 : : {
98 : 1 : size_t tmplen = strlen (tmp);
99 : :
100 [ - + ]: 1 : if (tmplen >= *outlen)
101 : : {
102 : 0 : free (tmp);
103 : 0 : return GSASL_TOO_SMALL_BUFFER;
104 : : }
105 : :
106 [ + - ]: 1 : if (out)
107 : 1 : strcpy (out, tmp);
108 : 1 : *outlen = tmplen + 1;
109 : 1 : free (tmp);
110 : : }
111 : :
112 : 1 : return rc;
113 : : }
114 : :
115 : : static int
116 : 0 : _gsasl_step (Gsasl_session * sctx,
117 : : const char *input, size_t input_len,
118 : : char *output, size_t * output_len)
119 : : {
120 : : char *tmp;
121 : : size_t tmplen;
122 : : int rc;
123 : :
124 : 0 : rc = gsasl_step (sctx, input, input_len, &tmp, &tmplen);
125 : :
126 [ # # ][ # # ]: 0 : if (rc == GSASL_OK || rc == GSASL_NEEDS_MORE)
127 : : {
128 [ # # ]: 0 : if (tmplen >= *output_len)
129 : : {
130 : 0 : free (tmp);
131 : : /* XXX We lose the step token here, don't we? */
132 : 0 : return GSASL_TOO_SMALL_BUFFER;
133 : : }
134 : :
135 [ # # ]: 0 : if (output)
136 : 0 : memcpy (output, tmp, tmplen);
137 : 0 : *output_len = tmplen;
138 : 0 : free (tmp);
139 : : }
140 : :
141 : 0 : return rc;
142 : : }
143 : :
144 : : /**
145 : : * gsasl_client_step:
146 : : * @sctx: libgsasl client handle.
147 : : * @input: input byte array.
148 : : * @input_len: size of input byte array.
149 : : * @output: output byte array.
150 : : * @output_len: size of output byte array.
151 : : *
152 : : * Perform one step of SASL authentication in client. This reads data
153 : : * from server (specified with input and input_len), processes it
154 : : * (potentially invoking callbacks to the application), and writes
155 : : * data to server (into variables output and output_len).
156 : : *
157 : : * The contents of the output buffer is unspecified if this functions
158 : : * returns anything other than %GSASL_NEEDS_MORE.
159 : : *
160 : : * Return value: Returns %GSASL_OK if authenticated terminated
161 : : * successfully, %GSASL_NEEDS_MORE if more data is needed, or error
162 : : * code.
163 : : *
164 : : * Deprecated: Use gsasl_step() instead.
165 : : **/
166 : : int
167 : 0 : gsasl_client_step (Gsasl_session * sctx,
168 : : const char *input,
169 : : size_t input_len, char *output, size_t * output_len)
170 : : {
171 : 0 : return _gsasl_step (sctx, input, input_len, output, output_len);
172 : : }
173 : :
174 : : /**
175 : : * gsasl_server_step:
176 : : * @sctx: libgsasl server handle.
177 : : * @input: input byte array.
178 : : * @input_len: size of input byte array.
179 : : * @output: output byte array.
180 : : * @output_len: size of output byte array.
181 : : *
182 : : * Perform one step of SASL authentication in server. This reads data
183 : : * from client (specified with input and input_len), processes it
184 : : * (potentially invoking callbacks to the application), and writes
185 : : * data to client (into variables output and output_len).
186 : : *
187 : : * The contents of the output buffer is unspecified if this functions
188 : : * returns anything other than %GSASL_NEEDS_MORE.
189 : : *
190 : : * Return value: Returns %GSASL_OK if authenticated terminated
191 : : * successfully, %GSASL_NEEDS_MORE if more data is needed, or error
192 : : * code.
193 : : *
194 : : * Deprecated: Use gsasl_step() instead.
195 : : **/
196 : : int
197 : 0 : gsasl_server_step (Gsasl_session * sctx,
198 : : const char *input,
199 : : size_t input_len, char *output, size_t * output_len)
200 : : {
201 : 0 : return _gsasl_step (sctx, input, input_len, output, output_len);
202 : : }
203 : :
204 : : static int
205 : 38 : _gsasl_step64 (Gsasl_session * sctx,
206 : : const char *b64input, char *b64output, size_t b64output_len)
207 : : {
208 : : char *tmp;
209 : : int rc;
210 : :
211 : 38 : rc = gsasl_step64 (sctx, b64input, &tmp);
212 : :
213 [ + + ][ + - ]: 38 : if (rc == GSASL_OK || rc == GSASL_NEEDS_MORE)
214 : : {
215 [ - + ]: 38 : if (b64output_len <= strlen (tmp))
216 : : {
217 : 0 : free (tmp);
218 : : /* XXX We lose the step token here, don't we? */
219 : 0 : return GSASL_TOO_SMALL_BUFFER;
220 : : }
221 : :
222 [ + - ]: 38 : if (b64output)
223 : 38 : strcpy (b64output, tmp);
224 : 38 : free (tmp);
225 : : }
226 : :
227 : 38 : return rc;
228 : : }
229 : :
230 : : /**
231 : : * gsasl_client_step_base64:
232 : : * @sctx: libgsasl client handle.
233 : : * @b64input: input base64 encoded byte array.
234 : : * @b64output: output base64 encoded byte array.
235 : : * @b64output_len: size of output base64 encoded byte array.
236 : : *
237 : : * This is a simple wrapper around gsasl_client_step() that base64
238 : : * decodes the input and base64 encodes the output.
239 : : *
240 : : * Return value: See gsasl_client_step().
241 : : *
242 : : * Deprecated: Use gsasl_step64() instead.
243 : : **/
244 : : int
245 : 22 : gsasl_client_step_base64 (Gsasl_session * sctx,
246 : : const char *b64input,
247 : : char *b64output, size_t b64output_len)
248 : : {
249 : 22 : return _gsasl_step64 (sctx, b64input, b64output, b64output_len);
250 : : }
251 : :
252 : : /**
253 : : * gsasl_server_step_base64:
254 : : * @sctx: libgsasl server handle.
255 : : * @b64input: input base64 encoded byte array.
256 : : * @b64output: output base64 encoded byte array.
257 : : * @b64output_len: size of output base64 encoded byte array.
258 : : *
259 : : * This is a simple wrapper around gsasl_server_step() that base64
260 : : * decodes the input and base64 encodes the output.
261 : : *
262 : : * Return value: See gsasl_server_step().
263 : : *
264 : : * Deprecated: Use gsasl_step64() instead.
265 : : **/
266 : : int
267 : 16 : gsasl_server_step_base64 (Gsasl_session * sctx,
268 : : const char *b64input,
269 : : char *b64output, size_t b64output_len)
270 : : {
271 : 16 : return _gsasl_step64 (sctx, b64input, b64output, b64output_len);
272 : : }
273 : :
274 : : /**
275 : : * gsasl_client_finish:
276 : : * @sctx: libgsasl client handle.
277 : : *
278 : : * Destroy a libgsasl client handle. The handle must not be used with
279 : : * other libgsasl functions after this call.
280 : : *
281 : : * Deprecated: Use gsasl_finish() instead.
282 : : **/
283 : : void
284 : 24 : gsasl_client_finish (Gsasl_session * sctx)
285 : : {
286 : 24 : gsasl_finish (sctx);
287 : 24 : }
288 : :
289 : : /**
290 : : * gsasl_server_finish:
291 : : * @sctx: libgsasl server handle.
292 : : *
293 : : * Destroy a libgsasl server handle. The handle must not be used with
294 : : * other libgsasl functions after this call.
295 : : *
296 : : * Deprecated: Use gsasl_finish() instead.
297 : : **/
298 : : void
299 : 20 : gsasl_server_finish (Gsasl_session * sctx)
300 : : {
301 : 20 : gsasl_finish (sctx);
302 : 20 : }
303 : :
304 : : /**
305 : : * gsasl_client_ctx_get:
306 : : * @sctx: libgsasl client handle
307 : : *
308 : : * Get the libgsasl handle given a libgsasl client handle.
309 : : *
310 : : * Return value: Returns the libgsasl handle given a libgsasl client handle.
311 : : *
312 : : * Deprecated: This function is not useful with the new 0.2.0 API.
313 : : **/
314 : : Gsasl *
315 : 31 : gsasl_client_ctx_get (Gsasl_session * sctx)
316 : : {
317 : 31 : return sctx->ctx;
318 : : }
319 : :
320 : : /**
321 : : * gsasl_client_application_data_set:
322 : : * @sctx: libgsasl client handle.
323 : : * @application_data: opaque pointer to application specific data.
324 : : *
325 : : * Store application specific data in the libgsasl client handle. The
326 : : * application data can be later (for instance, inside a callback) be
327 : : * retrieved by calling gsasl_client_application_data_get(). It is
328 : : * normally used by the application to maintain state between the main
329 : : * program and the callback.
330 : : *
331 : : * Deprecated: Use gsasl_callback_hook_set() or
332 : : * gsasl_session_hook_set() instead.
333 : : **/
334 : : void
335 : 22 : gsasl_client_application_data_set (Gsasl_session * sctx,
336 : : void *application_data)
337 : : {
338 : 22 : gsasl_appinfo_set (sctx, application_data);
339 : 22 : }
340 : :
341 : : /**
342 : : * gsasl_client_application_data_get:
343 : : * @sctx: libgsasl client handle.
344 : : *
345 : : * Retrieve application specific data from libgsasl client handle. The
346 : : * application data is set using gsasl_client_application_data_set().
347 : : * It is normally used by the application to maintain state between
348 : : * the main program and the callback.
349 : : *
350 : : * Return value: Returns the application specific data, or NULL.
351 : : *
352 : : * Deprecated: Use gsasl_callback_hook_get() or
353 : : * gsasl_session_hook_get() instead.
354 : : **/
355 : : void *
356 : 0 : gsasl_client_application_data_get (Gsasl_session * sctx)
357 : : {
358 : 0 : return gsasl_appinfo_get (sctx);
359 : : }
360 : :
361 : : /**
362 : : * gsasl_server_ctx_get:
363 : : * @sctx: libgsasl server handle
364 : : *
365 : : * Get the libgsasl handle given a libgsasl server handle.
366 : : *
367 : : * Return value: Returns the libgsasl handle given a libgsasl server handle.
368 : : *
369 : : * Deprecated: This function is not useful with the new 0.2.0 API.
370 : : **/
371 : : Gsasl *
372 : 18 : gsasl_server_ctx_get (Gsasl_session * sctx)
373 : : {
374 : 18 : return sctx->ctx;
375 : : }
376 : :
377 : : /**
378 : : * gsasl_server_application_data_set:
379 : : * @sctx: libgsasl server handle.
380 : : * @application_data: opaque pointer to application specific data.
381 : : *
382 : : * Store application specific data in the libgsasl server handle. The
383 : : * application data can be later (for instance, inside a callback) be
384 : : * retrieved by calling gsasl_server_application_data_get(). It is
385 : : * normally used by the application to maintain state between the main
386 : : * program and the callback.
387 : : *
388 : : * Deprecated: Use gsasl_callback_hook_set() or
389 : : * gsasl_session_hook_set() instead.
390 : : **/
391 : : void
392 : 16 : gsasl_server_application_data_set (Gsasl_session * sctx,
393 : : void *application_data)
394 : : {
395 : 16 : gsasl_appinfo_set (sctx, application_data);
396 : 16 : }
397 : :
398 : : /**
399 : : * gsasl_server_application_data_get:
400 : : * @sctx: libgsasl server handle.
401 : : *
402 : : * Retrieve application specific data from libgsasl server handle. The
403 : : * application data is set using gsasl_server_application_data_set().
404 : : * It is normally used by the application to maintain state between
405 : : * the main program and the callback.
406 : : *
407 : : * Return value: Returns the application specific data, or NULL.
408 : : *
409 : : * Deprecated: Use gsasl_callback_hook_get() or
410 : : * gsasl_session_hook_get() instead.
411 : : **/
412 : : void *
413 : 0 : gsasl_server_application_data_get (Gsasl_session * sctx)
414 : : {
415 : 0 : return gsasl_appinfo_get (sctx);
416 : : }
417 : :
418 : : /**
419 : : * gsasl_randomize:
420 : : * @strong: 0 iff operation should not block, non-0 for very strong randomness.
421 : : * @data: output array to be filled with random data.
422 : : * @datalen: size of output array.
423 : : *
424 : : * Store cryptographically random data of given size in the provided
425 : : * buffer.
426 : : *
427 : : * Return value: Returns %GSASL_OK iff successful.
428 : : *
429 : : * Deprecated: Use gsasl_random() or gsasl_nonce() instead.
430 : : **/
431 : : int
432 : 0 : gsasl_randomize (int strong, char *data, size_t datalen)
433 : : {
434 [ # # ]: 0 : if (strong)
435 : 0 : return gsasl_random (data, datalen);
436 : 0 : return gsasl_nonce (data, datalen);
437 : : }
438 : :
439 : : /**
440 : : * gsasl_ctx_get:
441 : : * @sctx: libgsasl session handle
442 : : *
443 : : * Get the libgsasl handle given a libgsasl session handle.
444 : : *
445 : : * Return value: Returns the libgsasl handle given a libgsasl session handle.
446 : : *
447 : : * Deprecated: This function is not useful with the new 0.2.0 API.
448 : : **/
449 : : Gsasl *
450 : 0 : gsasl_ctx_get (Gsasl_session * sctx)
451 : : {
452 : 0 : return sctx->ctx;
453 : : }
454 : :
455 : : /**
456 : : * gsasl_encode_inline:
457 : : * @sctx: libgsasl session handle.
458 : : * @input: input byte array.
459 : : * @input_len: size of input byte array.
460 : : * @output: output byte array.
461 : : * @output_len: size of output byte array.
462 : : *
463 : : * Encode data according to negotiated SASL mechanism. This might mean
464 : : * that data is integrity or privacy protected.
465 : : *
466 : : * Return value: Returns %GSASL_OK if encoding was successful,
467 : : * otherwise an error code.
468 : : *
469 : : * Deprecated: Use gsasl_encode() instead.
470 : : *
471 : : * Since: 0.2.0
472 : : **/
473 : : int
474 : 0 : gsasl_encode_inline (Gsasl_session * sctx,
475 : : const char *input, size_t input_len,
476 : : char *output, size_t * output_len)
477 : : {
478 : : char *tmp;
479 : : size_t tmplen;
480 : : int res;
481 : :
482 : 0 : res = gsasl_encode (sctx, input, input_len, &tmp, &tmplen);
483 [ # # ]: 0 : if (res == GSASL_OK)
484 : : {
485 [ # # ]: 0 : if (*output_len < tmplen)
486 : 0 : return GSASL_TOO_SMALL_BUFFER;
487 : 0 : *output_len = tmplen;
488 : 0 : memcpy (output, tmp, tmplen);
489 : 0 : free (output);
490 : : }
491 : :
492 : 0 : return res;
493 : : }
494 : :
495 : : /**
496 : : * gsasl_decode_inline:
497 : : * @sctx: libgsasl session handle.
498 : : * @input: input byte array.
499 : : * @input_len: size of input byte array.
500 : : * @output: output byte array.
501 : : * @output_len: size of output byte array.
502 : : *
503 : : * Decode data according to negotiated SASL mechanism. This might mean
504 : : * that data is integrity or privacy protected.
505 : : *
506 : : * Return value: Returns %GSASL_OK if encoding was successful,
507 : : * otherwise an error code.
508 : : *
509 : : * Deprecated: Use gsasl_decode() instead.
510 : : *
511 : : * Since: 0.2.0
512 : : **/
513 : : int
514 : 0 : gsasl_decode_inline (Gsasl_session * sctx,
515 : : const char *input, size_t input_len,
516 : : char *output, size_t * output_len)
517 : : {
518 : : char *tmp;
519 : : size_t tmplen;
520 : : int res;
521 : :
522 : 0 : res = gsasl_decode (sctx, input, input_len, &tmp, &tmplen);
523 [ # # ]: 0 : if (res == GSASL_OK)
524 : : {
525 [ # # ]: 0 : if (*output_len < tmplen)
526 : 0 : return GSASL_TOO_SMALL_BUFFER;
527 : 0 : *output_len = tmplen;
528 : 0 : memcpy (output, tmp, tmplen);
529 : 0 : free (output);
530 : : }
531 : :
532 : 0 : return res;
533 : : }
534 : :
535 : : /**
536 : : * gsasl_application_data_set:
537 : : * @ctx: libgsasl handle.
538 : : * @appdata: opaque pointer to application specific data.
539 : : *
540 : : * Store application specific data in the libgsasl handle. The
541 : : * application data can be later (for instance, inside a callback) be
542 : : * retrieved by calling gsasl_application_data_get(). It is normally
543 : : * used by the application to maintain state between the main program
544 : : * and the callback.
545 : : *
546 : : * Deprecated: Use gsasl_callback_hook_set() instead.
547 : : **/
548 : : void
549 : 25 : gsasl_application_data_set (Gsasl * ctx, void *appdata)
550 : : {
551 : 25 : ctx->application_hook = appdata;
552 : 25 : }
553 : :
554 : : /**
555 : : * gsasl_application_data_get:
556 : : * @ctx: libgsasl handle.
557 : : *
558 : : * Retrieve application specific data from libgsasl handle. The
559 : : * application data is set using gsasl_application_data_set(). It is
560 : : * normally used by the application to maintain state between the main
561 : : * program and the callback.
562 : : *
563 : : * Return value: Returns the application specific data, or NULL.
564 : : *
565 : : * Deprecated: Use gsasl_callback_hook_get() instead.
566 : : **/
567 : : void *
568 : 49 : gsasl_application_data_get (Gsasl * ctx)
569 : : {
570 : 49 : return ctx->application_hook;
571 : : }
572 : :
573 : : /**
574 : : * gsasl_appinfo_set:
575 : : * @sctx: libgsasl session handle.
576 : : * @appdata: opaque pointer to application specific data.
577 : : *
578 : : * Store application specific data in the libgsasl session handle.
579 : : * The application data can be later (for instance, inside a callback)
580 : : * be retrieved by calling gsasl_appinfo_get(). It is normally used
581 : : * by the application to maintain state between the main program and
582 : : * the callback.
583 : : *
584 : : * Deprecated: Use gsasl_callback_hook_set() instead.
585 : : **/
586 : : void
587 : 43 : gsasl_appinfo_set (Gsasl_session * sctx, void *appdata)
588 : : {
589 : 43 : sctx->application_data = appdata;
590 : 43 : }
591 : :
592 : : /**
593 : : * gsasl_appinfo_get:
594 : : * @sctx: libgsasl session handle.
595 : : *
596 : : * Retrieve application specific data from libgsasl session
597 : : * handle. The application data is set using gsasl_appinfo_set(). It
598 : : * is normally used by the application to maintain state between the
599 : : * main program and the callback.
600 : : *
601 : : * Return value: Returns the application specific data, or NULL.
602 : : *
603 : : * Deprecated: Use gsasl_callback_hook_get() instead.
604 : : **/
605 : : void *
606 : 5 : gsasl_appinfo_get (Gsasl_session * sctx)
607 : : {
608 : 5 : return sctx->application_data;
609 : : }
610 : :
611 : : /**
612 : : * gsasl_server_suggest_mechanism:
613 : : * @ctx: libgsasl handle.
614 : : * @mechlist: input character array with SASL mechanism names,
615 : : * separated by invalid characters (e.g. SPC).
616 : : *
617 : : * Get name of "best" SASL mechanism supported by the libgsasl server
618 : : * which is present in the input string.
619 : : *
620 : : * Return value: Returns name of "best" SASL mechanism supported by
621 : : * the libgsasl server which is present in the input string.
622 : : *
623 : : * Deprecated: This function was never useful, since it is the client
624 : : * that chose which mechanism to use.
625 : : **/
626 : : const char *
627 : 0 : gsasl_server_suggest_mechanism (Gsasl * ctx, const char *mechlist)
628 : : {
629 : 0 : return NULL; /* This function is just silly. */
630 : : }
631 : :
632 : : /**
633 : : * gsasl_client_callback_authentication_id_set:
634 : : * @ctx: libgsasl handle.
635 : : * @cb: callback function
636 : : *
637 : : * Specify the callback function to use in the client to set the
638 : : * authentication identity. The function can be later retrieved using
639 : : * gsasl_client_callback_authentication_id_get().
640 : : *
641 : : * Deprecated: This function is part of the old callback interface.
642 : : * The new interface uses gsasl_callback_set() to set the application
643 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
644 : : * invoke the callback for certain properties.
645 : : **/
646 : : void
647 : 3 : gsasl_client_callback_authentication_id_set (Gsasl * ctx,
648 : : Gsasl_client_callback_authentication_id
649 : : cb)
650 : : {
651 : 3 : ctx->cbc_authentication_id = cb;
652 : 3 : }
653 : :
654 : : /**
655 : : * gsasl_client_callback_authentication_id_get:
656 : : * @ctx: libgsasl handle.
657 : : *
658 : : * Get the callback earlier set by calling
659 : : * gsasl_client_callback_authentication_id_set().
660 : : *
661 : : * Return value: Returns the callback earlier set by calling
662 : : * gsasl_client_callback_authentication_id_set().
663 : : *
664 : : * Deprecated: This function is part of the old callback interface.
665 : : * The new interface uses gsasl_callback_set() to set the application
666 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
667 : : * invoke the callback for certain properties.
668 : : **/
669 : : Gsasl_client_callback_authentication_id
670 : 51 : gsasl_client_callback_authentication_id_get (Gsasl * ctx)
671 : : {
672 [ + - ]: 51 : return ctx ? ctx->cbc_authentication_id : NULL;
673 : : }
674 : :
675 : : /**
676 : : * gsasl_client_callback_authorization_id_set:
677 : : * @ctx: libgsasl handle.
678 : : * @cb: callback function
679 : : *
680 : : * Specify the callback function to use in the client to set the
681 : : * authorization identity. The function can be later retrieved using
682 : : * gsasl_client_callback_authorization_id_get().
683 : : *
684 : : * Deprecated: This function is part of the old callback interface.
685 : : * The new interface uses gsasl_callback_set() to set the application
686 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
687 : : * invoke the callback for certain properties.
688 : : **/
689 : : void
690 : 1 : gsasl_client_callback_authorization_id_set (Gsasl * ctx,
691 : : Gsasl_client_callback_authorization_id
692 : : cb)
693 : : {
694 : 1 : ctx->cbc_authorization_id = cb;
695 : 1 : }
696 : :
697 : : /**
698 : : * gsasl_client_callback_authorization_id_get:
699 : : * @ctx: libgsasl handle.
700 : : *
701 : : * Get the callback earlier set by calling
702 : : * gsasl_client_callback_authorization_id_set().
703 : : *
704 : : * Return value: Returns the callback earlier set by calling
705 : : * gsasl_client_callback_authorization_id_set().
706 : : *
707 : : * Deprecated: This function is part of the old callback interface.
708 : : * The new interface uses gsasl_callback_set() to set the application
709 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
710 : : * invoke the callback for certain properties.
711 : : **/
712 : : Gsasl_client_callback_authorization_id
713 : 82 : gsasl_client_callback_authorization_id_get (Gsasl * ctx)
714 : : {
715 [ + - ]: 82 : return ctx ? ctx->cbc_authorization_id : NULL;
716 : : }
717 : :
718 : : /**
719 : : * gsasl_client_callback_password_set:
720 : : * @ctx: libgsasl handle.
721 : : * @cb: callback function
722 : : *
723 : : * Specify the callback function to use in the client to set the
724 : : * password. The function can be later retrieved using
725 : : * gsasl_client_callback_password_get().
726 : : *
727 : : * Deprecated: This function is part of the old callback interface.
728 : : * The new interface uses gsasl_callback_set() to set the application
729 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
730 : : * invoke the callback for certain properties.
731 : : **/
732 : : void
733 : 3 : gsasl_client_callback_password_set (Gsasl * ctx,
734 : : Gsasl_client_callback_password cb)
735 : : {
736 : 3 : ctx->cbc_password = cb;
737 : 3 : }
738 : :
739 : :
740 : : /**
741 : : * gsasl_client_callback_password_get:
742 : : * @ctx: libgsasl handle.
743 : : *
744 : : * Get the callback earlier set by calling
745 : : * gsasl_client_callback_password_set().
746 : : *
747 : : * Return value: Returns the callback earlier set by calling
748 : : * gsasl_client_callback_password_set().
749 : : *
750 : : * Deprecated: This function is part of the old callback interface.
751 : : * The new interface uses gsasl_callback_set() to set the application
752 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
753 : : * invoke the callback for certain properties.
754 : : **/
755 : : Gsasl_client_callback_password
756 : 5 : gsasl_client_callback_password_get (Gsasl * ctx)
757 : : {
758 [ + - ]: 5 : return ctx ? ctx->cbc_password : NULL;
759 : : }
760 : :
761 : : /**
762 : : * gsasl_client_callback_passcode_set:
763 : : * @ctx: libgsasl handle.
764 : : * @cb: callback function
765 : : *
766 : : * Specify the callback function to use in the client to set the
767 : : * passcode. The function can be later retrieved using
768 : : * gsasl_client_callback_passcode_get().
769 : : *
770 : : * Deprecated: This function is part of the old callback interface.
771 : : * The new interface uses gsasl_callback_set() to set the application
772 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
773 : : * invoke the callback for certain properties.
774 : : **/
775 : : void
776 : 1 : gsasl_client_callback_passcode_set (Gsasl * ctx,
777 : : Gsasl_client_callback_passcode cb)
778 : : {
779 : 1 : ctx->cbc_passcode = cb;
780 : 1 : }
781 : :
782 : :
783 : : /**
784 : : * gsasl_client_callback_passcode_get:
785 : : * @ctx: libgsasl handle.
786 : : *
787 : : * Get the callback earlier set by calling
788 : : * gsasl_client_callback_passcode_set().
789 : : *
790 : : * Return value: Returns the callback earlier set by calling
791 : : * gsasl_client_callback_passcode_set().
792 : : *
793 : : * Deprecated: This function is part of the old callback interface.
794 : : * The new interface uses gsasl_callback_set() to set the application
795 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
796 : : * invoke the callback for certain properties.
797 : : **/
798 : : Gsasl_client_callback_passcode
799 : 5 : gsasl_client_callback_passcode_get (Gsasl * ctx)
800 : : {
801 [ + - ]: 5 : return ctx ? ctx->cbc_passcode : NULL;
802 : : }
803 : :
804 : : /**
805 : : * gsasl_client_callback_pin_set:
806 : : * @ctx: libgsasl handle.
807 : : * @cb: callback function
808 : : *
809 : : * Specify the callback function to use in the client to chose a new
810 : : * pin, possibly suggested by the server, for the SECURID mechanism.
811 : : * This is not normally invoked, but only when the server requests it.
812 : : * The function can be later retrieved using
813 : : * gsasl_client_callback_pin_get().
814 : : *
815 : : * Deprecated: This function is part of the old callback interface.
816 : : * The new interface uses gsasl_callback_set() to set the application
817 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
818 : : * invoke the callback for certain properties.
819 : : **/
820 : : void
821 : 1 : gsasl_client_callback_pin_set (Gsasl * ctx, Gsasl_client_callback_pin cb)
822 : : {
823 : 1 : ctx->cbc_pin = cb;
824 : 1 : }
825 : :
826 : :
827 : : /**
828 : : * gsasl_client_callback_pin_get:
829 : : * @ctx: libgsasl handle.
830 : : *
831 : : * Get the callback earlier set by calling
832 : : * gsasl_client_callback_pin_set().
833 : : *
834 : : * Return value: Returns the callback earlier set by calling
835 : : * gsasl_client_callback_pin_set().
836 : : *
837 : : * Deprecated: This function is part of the old callback interface.
838 : : * The new interface uses gsasl_callback_set() to set the application
839 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
840 : : * invoke the callback for certain properties.
841 : : **/
842 : : Gsasl_client_callback_pin
843 : 3 : gsasl_client_callback_pin_get (Gsasl * ctx)
844 : : {
845 [ + - ]: 3 : return ctx ? ctx->cbc_pin : NULL;
846 : : }
847 : :
848 : : /**
849 : : * gsasl_client_callback_service_set:
850 : : * @ctx: libgsasl handle.
851 : : * @cb: callback function
852 : : *
853 : : * Specify the callback function to use in the client to set the name
854 : : * of the service. The service buffer should be a registered GSSAPI
855 : : * host-based service name, hostname the name of the server.
856 : : * Servicename is used by DIGEST-MD5 and should be the name of generic
857 : : * server in case of a replicated service. The function can be later
858 : : * retrieved using gsasl_client_callback_service_get().
859 : : *
860 : : * Deprecated: This function is part of the old callback interface.
861 : : * The new interface uses gsasl_callback_set() to set the application
862 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
863 : : * invoke the callback for certain properties.
864 : : **/
865 : : void
866 : 2 : gsasl_client_callback_service_set (Gsasl * ctx,
867 : : Gsasl_client_callback_service cb)
868 : : {
869 : 2 : ctx->cbc_service = cb;
870 : 2 : }
871 : :
872 : : /**
873 : : * gsasl_client_callback_service_get:
874 : : * @ctx: libgsasl handle.
875 : : *
876 : : * Get the callback earlier set by calling
877 : : * gsasl_client_callback_service_set().
878 : : *
879 : : * Return value: Returns the callback earlier set by calling
880 : : * gsasl_client_callback_service_set().
881 : : *
882 : : * Deprecated: This function is part of the old callback interface.
883 : : * The new interface uses gsasl_callback_set() to set the application
884 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
885 : : * invoke the callback for certain properties.
886 : : **/
887 : : Gsasl_client_callback_service
888 : 10 : gsasl_client_callback_service_get (Gsasl * ctx)
889 : : {
890 [ + - ]: 10 : return ctx ? ctx->cbc_service : NULL;
891 : : }
892 : :
893 : : /**
894 : : * gsasl_client_callback_anonymous_set:
895 : : * @ctx: libgsasl handle.
896 : : * @cb: callback function
897 : : *
898 : : * Specify the callback function to use in the client to set the
899 : : * anonymous token, which usually is the users email address. The
900 : : * function can be later retrieved using
901 : : * gsasl_client_callback_anonymous_get().
902 : : *
903 : : * Deprecated: This function is part of the old callback interface.
904 : : * The new interface uses gsasl_callback_set() to set the application
905 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
906 : : * invoke the callback for certain properties.
907 : : **/
908 : : void
909 : 1 : gsasl_client_callback_anonymous_set (Gsasl * ctx,
910 : : Gsasl_client_callback_anonymous cb)
911 : : {
912 : 1 : ctx->cbc_anonymous = cb;
913 : 1 : }
914 : :
915 : : /**
916 : : * gsasl_client_callback_anonymous_get:
917 : : * @ctx: libgsasl handle.
918 : : *
919 : : * Get the callback earlier set by calling
920 : : * gsasl_client_callback_anonymous_set().
921 : : *
922 : : * Return value: Returns the callback earlier set by calling
923 : : * gsasl_client_callback_anonymous_set().
924 : : *
925 : : * Deprecated: This function is part of the old callback interface.
926 : : * The new interface uses gsasl_callback_set() to set the application
927 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
928 : : * invoke the callback for certain properties.
929 : : **/
930 : : Gsasl_client_callback_anonymous
931 : 6 : gsasl_client_callback_anonymous_get (Gsasl * ctx)
932 : : {
933 [ + - ]: 6 : return ctx ? ctx->cbc_anonymous : NULL;
934 : : }
935 : :
936 : : /**
937 : : * gsasl_client_callback_qop_set:
938 : : * @ctx: libgsasl handle.
939 : : * @cb: callback function
940 : : *
941 : : * Specify the callback function to use in the client to determine the
942 : : * qop to use after looking at what the server offered. The function
943 : : * can be later retrieved using gsasl_client_callback_qop_get().
944 : : *
945 : : * Deprecated: This function is part of the old callback interface.
946 : : * The new interface uses gsasl_callback_set() to set the application
947 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
948 : : * invoke the callback for certain properties.
949 : : **/
950 : : void
951 : 2 : gsasl_client_callback_qop_set (Gsasl * ctx, Gsasl_client_callback_qop cb)
952 : : {
953 : 2 : ctx->cbc_qop = cb;
954 : 2 : }
955 : :
956 : : /**
957 : : * gsasl_client_callback_qop_get:
958 : : * @ctx: libgsasl handle.
959 : : *
960 : : * Get the callback earlier set by calling
961 : : * gsasl_client_callback_qop_set().
962 : : *
963 : : * Return value: Returns the callback earlier set by calling
964 : : * gsasl_client_callback_qop_set().
965 : : *
966 : : * Deprecated: This function is part of the old callback interface.
967 : : * The new interface uses gsasl_callback_set() to set the application
968 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
969 : : * invoke the callback for certain properties.
970 : : **/
971 : : Gsasl_client_callback_qop
972 : 7 : gsasl_client_callback_qop_get (Gsasl * ctx)
973 : : {
974 [ + - ]: 7 : return ctx ? ctx->cbc_qop : NULL;
975 : : }
976 : :
977 : : /**
978 : : * gsasl_client_callback_maxbuf_set:
979 : : * @ctx: libgsasl handle.
980 : : * @cb: callback function
981 : : *
982 : : * Specify the callback function to use in the client to inform the
983 : : * server of the largest buffer the client is able to receive when
984 : : * using the DIGEST-MD5 "auth-int" or "auth-conf" Quality of
985 : : * Protection (qop). If this directive is missing, the default value
986 : : * 65536 will be assumed. The function can be later retrieved using
987 : : * gsasl_client_callback_maxbuf_get().
988 : : *
989 : : * Deprecated: This function is part of the old callback interface.
990 : : * The new interface uses gsasl_callback_set() to set the application
991 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
992 : : * invoke the callback for certain properties.
993 : : **/
994 : : void
995 : 0 : gsasl_client_callback_maxbuf_set (Gsasl * ctx,
996 : : Gsasl_client_callback_maxbuf cb)
997 : : {
998 : 0 : ctx->cbc_maxbuf = cb;
999 : 0 : }
1000 : :
1001 : : /**
1002 : : * gsasl_client_callback_maxbuf_get:
1003 : : * @ctx: libgsasl handle.
1004 : : *
1005 : : * Get the callback earlier set by calling
1006 : : * gsasl_client_callback_maxbuf_set().
1007 : : *
1008 : : * Return value: Returns the callback earlier set by calling
1009 : : * gsasl_client_callback_maxbuf_set().
1010 : : *
1011 : : * Deprecated: This function is part of the old callback interface.
1012 : : * The new interface uses gsasl_callback_set() to set the application
1013 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1014 : : * invoke the callback for certain properties.
1015 : : **/
1016 : : Gsasl_client_callback_maxbuf
1017 : 0 : gsasl_client_callback_maxbuf_get (Gsasl * ctx)
1018 : : {
1019 [ # # ]: 0 : return ctx ? ctx->cbc_maxbuf : NULL;
1020 : : }
1021 : :
1022 : : /**
1023 : : * gsasl_client_callback_realm_set:
1024 : : * @ctx: libgsasl handle.
1025 : : * @cb: callback function
1026 : : *
1027 : : * Specify the callback function to use in the client to know which
1028 : : * realm it belongs to. The realm is used by the server to determine
1029 : : * which username and password to use. The function can be later
1030 : : * retrieved using gsasl_client_callback_realm_get().
1031 : : *
1032 : : * Deprecated: This function is part of the old callback interface.
1033 : : * The new interface uses gsasl_callback_set() to set the application
1034 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1035 : : * invoke the callback for certain properties.
1036 : : **/
1037 : : void
1038 : 0 : gsasl_client_callback_realm_set (Gsasl * ctx, Gsasl_client_callback_realm cb)
1039 : : {
1040 : 0 : ctx->cbc_realm = cb;
1041 : 0 : }
1042 : :
1043 : : /**
1044 : : * gsasl_client_callback_realm_get:
1045 : : * @ctx: libgsasl handle.
1046 : : *
1047 : : * Get the callback earlier set by calling
1048 : : * gsasl_client_callback_realm_set().
1049 : : *
1050 : : * Return value: Returns the callback earlier set by calling
1051 : : * gsasl_client_callback_realm_set().
1052 : : *
1053 : : * Deprecated: This function is part of the old callback interface.
1054 : : * The new interface uses gsasl_callback_set() to set the application
1055 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1056 : : * invoke the callback for certain properties.
1057 : : **/
1058 : : Gsasl_client_callback_realm
1059 : 14 : gsasl_client_callback_realm_get (Gsasl * ctx)
1060 : : {
1061 [ + - ]: 14 : return ctx ? ctx->cbc_realm : NULL;
1062 : : }
1063 : :
1064 : : /**
1065 : : * gsasl_server_callback_validate_set:
1066 : : * @ctx: libgsasl handle.
1067 : : * @cb: callback function
1068 : : *
1069 : : * Specify the callback function to use in the server for deciding if
1070 : : * user is authenticated using authentication identity, authorization
1071 : : * identity and password. The function can be later retrieved using
1072 : : * gsasl_server_callback_validate_get().
1073 : : *
1074 : : * Deprecated: This function is part of the old callback interface.
1075 : : * The new interface uses gsasl_callback_set() to set the application
1076 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1077 : : * invoke the callback for certain properties.
1078 : : **/
1079 : : void
1080 : 1 : gsasl_server_callback_validate_set (Gsasl * ctx,
1081 : : Gsasl_server_callback_validate cb)
1082 : : {
1083 : 1 : ctx->cbs_validate = cb;
1084 : 1 : }
1085 : :
1086 : : /**
1087 : : * gsasl_server_callback_validate_get:
1088 : : * @ctx: libgsasl handle.
1089 : : *
1090 : : * Get the callback earlier set by calling
1091 : : * gsasl_server_callback_validate_set().
1092 : : *
1093 : : * Return value: Returns the callback earlier set by calling
1094 : : * gsasl_server_callback_validate_set().
1095 : : *
1096 : : * Deprecated: This function is part of the old callback interface.
1097 : : * The new interface uses gsasl_callback_set() to set the application
1098 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1099 : : * invoke the callback for certain properties.
1100 : : **/
1101 : : Gsasl_server_callback_validate
1102 : 3 : gsasl_server_callback_validate_get (Gsasl * ctx)
1103 : : {
1104 [ + - ]: 3 : return ctx ? ctx->cbs_validate : NULL;
1105 : : }
1106 : :
1107 : : /**
1108 : : * gsasl_server_callback_retrieve_set:
1109 : : * @ctx: libgsasl handle.
1110 : : * @cb: callback function
1111 : : *
1112 : : * Specify the callback function to use in the server for deciding if
1113 : : * user is authenticated using authentication identity, authorization
1114 : : * identity and password. The function can be later retrieved using
1115 : : * gsasl_server_callback_retrieve_get().
1116 : : *
1117 : : * Deprecated: This function is part of the old callback interface.
1118 : : * The new interface uses gsasl_callback_set() to set the application
1119 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1120 : : * invoke the callback for certain properties.
1121 : : **/
1122 : : void
1123 : 3 : gsasl_server_callback_retrieve_set (Gsasl * ctx,
1124 : : Gsasl_server_callback_retrieve cb)
1125 : : {
1126 : 3 : ctx->cbs_retrieve = cb;
1127 : 3 : }
1128 : :
1129 : : /**
1130 : : * gsasl_server_callback_retrieve_get:
1131 : : * @ctx: libgsasl handle.
1132 : : *
1133 : : * Get the callback earlier set by calling
1134 : : * gsasl_server_callback_retrieve_set().
1135 : : *
1136 : : * Return value: Returns the callback earlier set by calling
1137 : : * gsasl_server_callback_retrieve_set().
1138 : : *
1139 : : * Deprecated: This function is part of the old callback interface.
1140 : : * The new interface uses gsasl_callback_set() to set the application
1141 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1142 : : * invoke the callback for certain properties.
1143 : : **/
1144 : : Gsasl_server_callback_retrieve
1145 : 32 : gsasl_server_callback_retrieve_get (Gsasl * ctx)
1146 : : {
1147 [ + - ]: 32 : return ctx ? ctx->cbs_retrieve : NULL;
1148 : : }
1149 : :
1150 : : /**
1151 : : * gsasl_server_callback_cram_md5_set:
1152 : : * @ctx: libgsasl handle.
1153 : : * @cb: callback function
1154 : : *
1155 : : * Specify the callback function to use in the server for deciding if
1156 : : * user is authenticated using CRAM-MD5 challenge and response. The
1157 : : * function can be later retrieved using
1158 : : * gsasl_server_callback_cram_md5_get().
1159 : : *
1160 : : * Deprecated: This function is part of the old callback interface.
1161 : : * The new interface uses gsasl_callback_set() to set the application
1162 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1163 : : * invoke the callback for certain properties.
1164 : : **/
1165 : : void
1166 : 0 : gsasl_server_callback_cram_md5_set (Gsasl * ctx,
1167 : : Gsasl_server_callback_cram_md5 cb)
1168 : : {
1169 : 0 : ctx->cbs_cram_md5 = cb;
1170 : 0 : }
1171 : :
1172 : : /**
1173 : : * gsasl_server_callback_cram_md5_get:
1174 : : * @ctx: libgsasl handle.
1175 : : *
1176 : : * Get the callback earlier set by calling
1177 : : * gsasl_server_callback_cram_md5_set().
1178 : : *
1179 : : * Return value: Returns the callback earlier set by calling
1180 : : * gsasl_server_callback_cram_md5_set().
1181 : : *
1182 : : * Deprecated: This function is part of the old callback interface.
1183 : : * The new interface uses gsasl_callback_set() to set the application
1184 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1185 : : * invoke the callback for certain properties.
1186 : : **/
1187 : : Gsasl_server_callback_cram_md5
1188 : 0 : gsasl_server_callback_cram_md5_get (Gsasl * ctx)
1189 : : {
1190 [ # # ]: 0 : return ctx ? ctx->cbs_cram_md5 : NULL;
1191 : : }
1192 : :
1193 : : /**
1194 : : * gsasl_server_callback_digest_md5_set:
1195 : : * @ctx: libgsasl handle.
1196 : : * @cb: callback function
1197 : : *
1198 : : * Specify the callback function to use in the server for retrieving
1199 : : * the secret hash of the username, realm and password for use in the
1200 : : * DIGEST-MD5 mechanism. The function can be later retrieved using
1201 : : * gsasl_server_callback_digest_md5_get().
1202 : : *
1203 : : * Deprecated: This function is part of the old callback interface.
1204 : : * The new interface uses gsasl_callback_set() to set the application
1205 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1206 : : * invoke the callback for certain properties.
1207 : : **/
1208 : : void
1209 : 0 : gsasl_server_callback_digest_md5_set (Gsasl * ctx,
1210 : : Gsasl_server_callback_digest_md5 cb)
1211 : : {
1212 : 0 : ctx->cbs_digest_md5 = cb;
1213 : 0 : }
1214 : :
1215 : : /**
1216 : : * gsasl_server_callback_digest_md5_get:
1217 : : * @ctx: libgsasl handle.
1218 : : *
1219 : : * Get the callback earlier set by calling
1220 : : * gsasl_server_callback_digest_md5_set().
1221 : : *
1222 : : * Return value: Return the callback earlier set by calling
1223 : : * gsasl_server_callback_digest_md5_set().
1224 : : *
1225 : : * Deprecated: This function is part of the old callback interface.
1226 : : * The new interface uses gsasl_callback_set() to set the application
1227 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1228 : : * invoke the callback for certain properties.
1229 : : **/
1230 : : Gsasl_server_callback_digest_md5
1231 : 0 : gsasl_server_callback_digest_md5_get (Gsasl * ctx)
1232 : : {
1233 : 0 : return ctx->cbs_digest_md5;
1234 : : }
1235 : :
1236 : : /**
1237 : : * gsasl_server_callback_external_set:
1238 : : * @ctx: libgsasl handle.
1239 : : * @cb: callback function
1240 : : *
1241 : : * Specify the callback function to use in the server for deciding if
1242 : : * user is authenticated out of band. The function can be later
1243 : : * retrieved using gsasl_server_callback_external_get().
1244 : : *
1245 : : * Deprecated: This function is part of the old callback interface.
1246 : : * The new interface uses gsasl_callback_set() to set the application
1247 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1248 : : * invoke the callback for certain properties.
1249 : : **/
1250 : : void
1251 : 1 : gsasl_server_callback_external_set (Gsasl * ctx,
1252 : : Gsasl_server_callback_external cb)
1253 : : {
1254 : 1 : ctx->cbs_external = cb;
1255 : 1 : }
1256 : :
1257 : : /**
1258 : : * gsasl_server_callback_external_get:
1259 : : * @ctx: libgsasl handle.
1260 : : *
1261 : : * Get the callback earlier set by calling
1262 : : * gsasl_server_callback_external_set().
1263 : : *
1264 : : * Return value: Returns the callback earlier set by calling
1265 : : * gsasl_server_callback_external_set().
1266 : : *
1267 : : * Deprecated: This function is part of the old callback interface.
1268 : : * The new interface uses gsasl_callback_set() to set the application
1269 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1270 : : * invoke the callback for certain properties.
1271 : : **/
1272 : : Gsasl_server_callback_external
1273 : 6 : gsasl_server_callback_external_get (Gsasl * ctx)
1274 : : {
1275 [ + - ]: 6 : return ctx ? ctx->cbs_external : NULL;
1276 : : }
1277 : :
1278 : : /**
1279 : : * gsasl_server_callback_anonymous_set:
1280 : : * @ctx: libgsasl handle.
1281 : : * @cb: callback function
1282 : : *
1283 : : * Specify the callback function to use in the server for deciding if
1284 : : * user is permitted anonymous access. The function can be later
1285 : : * retrieved using gsasl_server_callback_anonymous_get().
1286 : : *
1287 : : * Deprecated: This function is part of the old callback interface.
1288 : : * The new interface uses gsasl_callback_set() to set the application
1289 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1290 : : * invoke the callback for certain properties.
1291 : : **/
1292 : : void
1293 : 1 : gsasl_server_callback_anonymous_set (Gsasl * ctx,
1294 : : Gsasl_server_callback_anonymous cb)
1295 : : {
1296 : 1 : ctx->cbs_anonymous = cb;
1297 : 1 : }
1298 : :
1299 : : /**
1300 : : * gsasl_server_callback_anonymous_get:
1301 : : * @ctx: libgsasl handle.
1302 : : *
1303 : : * Get the callback earlier set by calling
1304 : : * gsasl_server_callback_anonymous_set().
1305 : : *
1306 : : * Return value: Returns the callback earlier set by calling
1307 : : * gsasl_server_callback_anonymous_set().
1308 : : *
1309 : : * Deprecated: This function is part of the old callback interface.
1310 : : * The new interface uses gsasl_callback_set() to set the application
1311 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1312 : : * invoke the callback for certain properties.
1313 : : **/
1314 : : Gsasl_server_callback_anonymous
1315 : 5 : gsasl_server_callback_anonymous_get (Gsasl * ctx)
1316 : : {
1317 [ + - ]: 5 : return ctx ? ctx->cbs_anonymous : NULL;
1318 : : }
1319 : :
1320 : : /**
1321 : : * gsasl_server_callback_realm_set:
1322 : : * @ctx: libgsasl handle.
1323 : : * @cb: callback function
1324 : : *
1325 : : * Specify the callback function to use in the server to know which
1326 : : * realm it serves. The realm is used by the user to determine which
1327 : : * username and password to use. The function can be later retrieved
1328 : : * using gsasl_server_callback_realm_get().
1329 : : *
1330 : : * Deprecated: This function is part of the old callback interface.
1331 : : * The new interface uses gsasl_callback_set() to set the application
1332 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1333 : : * invoke the callback for certain properties.
1334 : : **/
1335 : : void
1336 : 0 : gsasl_server_callback_realm_set (Gsasl * ctx, Gsasl_server_callback_realm cb)
1337 : : {
1338 : 0 : ctx->cbs_realm = cb;
1339 : 0 : }
1340 : :
1341 : : /**
1342 : : * gsasl_server_callback_realm_get:
1343 : : * @ctx: libgsasl handle.
1344 : : *
1345 : : * Get the callback earlier set by calling
1346 : : * gsasl_server_callback_realm_set().
1347 : : *
1348 : : * Return value: Returns the callback earlier set by calling
1349 : : * gsasl_server_callback_realm_set().
1350 : : *
1351 : : * Deprecated: This function is part of the old callback interface.
1352 : : * The new interface uses gsasl_callback_set() to set the application
1353 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1354 : : * invoke the callback for certain properties.
1355 : : **/
1356 : : Gsasl_server_callback_realm
1357 : 0 : gsasl_server_callback_realm_get (Gsasl * ctx)
1358 : : {
1359 [ # # ]: 0 : return ctx ? ctx->cbs_realm : NULL;
1360 : : }
1361 : :
1362 : : /**
1363 : : * gsasl_server_callback_qop_set:
1364 : : * @ctx: libgsasl handle.
1365 : : * @cb: callback function
1366 : : *
1367 : : * Specify the callback function to use in the server to know which
1368 : : * quality of protection it accepts. The quality of protection
1369 : : * eventually used is selected by the client though. It is currently
1370 : : * used by the DIGEST-MD5 mechanism. The function can be later
1371 : : * retrieved using gsasl_server_callback_qop_get().
1372 : : *
1373 : : * Deprecated: This function is part of the old callback interface.
1374 : : * The new interface uses gsasl_callback_set() to set the application
1375 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1376 : : * invoke the callback for certain properties.
1377 : : **/
1378 : : void
1379 : 1 : gsasl_server_callback_qop_set (Gsasl * ctx, Gsasl_server_callback_qop cb)
1380 : : {
1381 : 1 : ctx->cbs_qop = cb;
1382 : 1 : }
1383 : :
1384 : : /**
1385 : : * gsasl_server_callback_qop_get:
1386 : : * @ctx: libgsasl handle.
1387 : : *
1388 : : * Get the callback earlier set by calling
1389 : : * gsasl_server_callback_qop_set().
1390 : : *
1391 : : * Return value: Returns the callback earlier set by calling
1392 : : * gsasl_server_callback_qop_set().
1393 : : *
1394 : : * Deprecated: This function is part of the old callback interface.
1395 : : * The new interface uses gsasl_callback_set() to set the application
1396 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1397 : : * invoke the callback for certain properties.
1398 : : **/
1399 : : Gsasl_server_callback_qop
1400 : 10 : gsasl_server_callback_qop_get (Gsasl * ctx)
1401 : : {
1402 [ + - ]: 10 : return ctx ? ctx->cbs_qop : NULL;
1403 : : }
1404 : :
1405 : : /**
1406 : : * gsasl_server_callback_maxbuf_set:
1407 : : * @ctx: libgsasl handle.
1408 : : * @cb: callback function
1409 : : *
1410 : : * Specify the callback function to use in the server to inform the
1411 : : * client of the largest buffer the server is able to receive when
1412 : : * using the DIGEST-MD5 "auth-int" or "auth-conf" Quality of
1413 : : * Protection (qop). If this directive is missing, the default value
1414 : : * 65536 will be assumed. The function can be later retrieved using
1415 : : * gsasl_server_callback_maxbuf_get().
1416 : : *
1417 : : * Deprecated: This function is part of the old callback interface.
1418 : : * The new interface uses gsasl_callback_set() to set the application
1419 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1420 : : * invoke the callback for certain properties.
1421 : : **/
1422 : : void
1423 : 0 : gsasl_server_callback_maxbuf_set (Gsasl * ctx,
1424 : : Gsasl_server_callback_maxbuf cb)
1425 : : {
1426 : 0 : ctx->cbs_maxbuf = cb;
1427 : 0 : }
1428 : :
1429 : : /**
1430 : : * gsasl_server_callback_maxbuf_get:
1431 : : * @ctx: libgsasl handle.
1432 : : *
1433 : : * Get the callback earlier set by calling
1434 : : * gsasl_server_callback_maxbuf_set().
1435 : : *
1436 : : * Return value: Returns the callback earlier set by calling
1437 : : * gsasl_server_callback_maxbuf_set().
1438 : : *
1439 : : * Deprecated: This function is part of the old callback interface.
1440 : : * The new interface uses gsasl_callback_set() to set the application
1441 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1442 : : * invoke the callback for certain properties.
1443 : : **/
1444 : : Gsasl_server_callback_maxbuf
1445 : 0 : gsasl_server_callback_maxbuf_get (Gsasl * ctx)
1446 : : {
1447 [ # # ]: 0 : return ctx ? ctx->cbs_maxbuf : NULL;
1448 : : }
1449 : :
1450 : : /**
1451 : : * gsasl_server_callback_cipher_set:
1452 : : * @ctx: libgsasl handle.
1453 : : * @cb: callback function
1454 : : *
1455 : : * Specify the callback function to use in the server to inform the
1456 : : * client of the cipher suites supported. The DES and 3DES ciphers
1457 : : * must be supported for interoperability. It is currently used by
1458 : : * the DIGEST-MD5 mechanism. The function can be later retrieved
1459 : : * using gsasl_server_callback_cipher_get().
1460 : : *
1461 : : * Deprecated: This function is part of the old callback interface.
1462 : : * The new interface uses gsasl_callback_set() to set the application
1463 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1464 : : * invoke the callback for certain properties.
1465 : : **/
1466 : : void
1467 : 0 : gsasl_server_callback_cipher_set (Gsasl * ctx,
1468 : : Gsasl_server_callback_cipher cb)
1469 : : {
1470 : 0 : ctx->cbs_cipher = cb;
1471 : 0 : }
1472 : :
1473 : : /**
1474 : : * gsasl_server_callback_cipher_get:
1475 : : * @ctx: libgsasl handle.
1476 : : *
1477 : : * Get the callback earlier set by calling
1478 : : * gsasl_server_callback_cipher_set().
1479 : : *
1480 : : * Return value: Returns the callback earlier set by calling
1481 : : * gsasl_server_callback_cipher_set().
1482 : : *
1483 : : * Deprecated: This function is part of the old callback interface.
1484 : : * The new interface uses gsasl_callback_set() to set the application
1485 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1486 : : * invoke the callback for certain properties.
1487 : : **/
1488 : : Gsasl_server_callback_cipher
1489 : 0 : gsasl_server_callback_cipher_get (Gsasl * ctx)
1490 : : {
1491 [ # # ]: 0 : return ctx ? ctx->cbs_cipher : NULL;
1492 : : }
1493 : :
1494 : : /**
1495 : : * gsasl_server_callback_securid_set:
1496 : : * @ctx: libgsasl handle.
1497 : : * @cb: callback function
1498 : : *
1499 : : * Specify the callback function to use in the server for validating a
1500 : : * user via the SECURID mechanism. The function should return
1501 : : * GSASL_OK if user authenticated successfully,
1502 : : * GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODE if it wants another
1503 : : * passcode, GSASL_SECURID_SERVER_NEED_NEW_PIN if it wants a PIN
1504 : : * change, or an error. When (and only when)
1505 : : * GSASL_SECURID_SERVER_NEED_NEW_PIN is returned, suggestpin can be
1506 : : * populated with a PIN code the server suggests, and suggestpinlen
1507 : : * set to the length of the PIN. The function can be later retrieved
1508 : : * using gsasl_server_callback_securid_get().
1509 : : *
1510 : : * Deprecated: This function is part of the old callback interface.
1511 : : * The new interface uses gsasl_callback_set() to set the application
1512 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1513 : : * invoke the callback for certain properties.
1514 : : **/
1515 : : void
1516 : 1 : gsasl_server_callback_securid_set (Gsasl * ctx,
1517 : : Gsasl_server_callback_securid cb)
1518 : : {
1519 : 1 : ctx->cbs_securid = cb;
1520 : 1 : }
1521 : :
1522 : : /**
1523 : : * gsasl_server_callback_securid_get:
1524 : : * @ctx: libgsasl handle.
1525 : : *
1526 : : * Get the callback earlier set by calling
1527 : : * gsasl_server_callback_securid_set().
1528 : : *
1529 : : * Return value: Returns the callback earlier set by calling
1530 : : * gsasl_server_callback_securid_set().
1531 : : *
1532 : : * Deprecated: This function is part of the old callback interface.
1533 : : * The new interface uses gsasl_callback_set() to set the application
1534 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1535 : : * invoke the callback for certain properties.
1536 : : **/
1537 : : Gsasl_server_callback_securid
1538 : 8 : gsasl_server_callback_securid_get (Gsasl * ctx)
1539 : : {
1540 [ + - ]: 8 : return ctx ? ctx->cbs_securid : NULL;
1541 : : }
1542 : :
1543 : : /**
1544 : : * gsasl_server_callback_gssapi_set:
1545 : : * @ctx: libgsasl handle.
1546 : : * @cb: callback function
1547 : : *
1548 : : * Specify the callback function to use in the server for checking if
1549 : : * a GSSAPI user is authorized for username (by, e.g., calling
1550 : : * krb5_kuserok). The function should return GSASL_OK if the user
1551 : : * should be permitted access, or an error code such as
1552 : : * GSASL_AUTHENTICATION_ERROR on failure. The function can be later
1553 : : * retrieved using gsasl_server_callback_gssapi_get().
1554 : : *
1555 : : * Deprecated: This function is part of the old callback interface.
1556 : : * The new interface uses gsasl_callback_set() to set the application
1557 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1558 : : * invoke the callback for certain properties.
1559 : : **/
1560 : : void
1561 : 0 : gsasl_server_callback_gssapi_set (Gsasl * ctx,
1562 : : Gsasl_server_callback_gssapi cb)
1563 : : {
1564 : 0 : ctx->cbs_gssapi = cb;
1565 : 0 : }
1566 : :
1567 : : /**
1568 : : * gsasl_server_callback_gssapi_get:
1569 : : * @ctx: libgsasl handle.
1570 : : *
1571 : : * Get the callback earlier set by calling
1572 : : * gsasl_server_callback_gssapi_set().
1573 : : *
1574 : : * Return value: Returns the callback earlier set by calling
1575 : : * gsasl_server_callback_gssapi_set().
1576 : : *
1577 : : * Deprecated: This function is part of the old callback interface.
1578 : : * The new interface uses gsasl_callback_set() to set the application
1579 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1580 : : * invoke the callback for certain properties.
1581 : : **/
1582 : : Gsasl_server_callback_gssapi
1583 : 0 : gsasl_server_callback_gssapi_get (Gsasl * ctx)
1584 : : {
1585 [ # # ]: 0 : return ctx ? ctx->cbs_gssapi : NULL;
1586 : : }
1587 : :
1588 : : /**
1589 : : * gsasl_server_callback_service_set:
1590 : : * @ctx: libgsasl handle.
1591 : : * @cb: callback function
1592 : : *
1593 : : * Specify the callback function to use in the server to set the name
1594 : : * of the service. The service buffer should be a registered GSSAPI
1595 : : * host-based service name, hostname the name of the server. The
1596 : : * function can be later retrieved using
1597 : : * gsasl_server_callback_service_get().
1598 : : *
1599 : : * Deprecated: This function is part of the old callback interface.
1600 : : * The new interface uses gsasl_callback_set() to set the application
1601 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1602 : : * invoke the callback for certain properties.
1603 : : **/
1604 : : void
1605 : 0 : gsasl_server_callback_service_set (Gsasl * ctx,
1606 : : Gsasl_server_callback_service cb)
1607 : : {
1608 : 0 : ctx->cbs_service = cb;
1609 : 0 : }
1610 : :
1611 : : /**
1612 : : * gsasl_server_callback_service_get:
1613 : : * @ctx: libgsasl handle.
1614 : : *
1615 : : * Get the callback earlier set by calling
1616 : : * gsasl_server_callback_service_set().
1617 : : *
1618 : : * Return value: Returns the callback earlier set by calling
1619 : : * gsasl_server_callback_service_set().
1620 : : *
1621 : : * Deprecated: This function is part of the old callback interface.
1622 : : * The new interface uses gsasl_callback_set() to set the application
1623 : : * callback, and uses gsasl_callback() or gsasl_property_get() to
1624 : : * invoke the callback for certain properties.
1625 : : **/
1626 : : Gsasl_server_callback_service
1627 : 0 : gsasl_server_callback_service_get (Gsasl * ctx)
1628 : : {
1629 [ # # ]: 0 : return ctx ? ctx->cbs_service : NULL;
1630 : : }
1631 : :
1632 : : #if HAVE_LIBIDN
1633 : : #include <stringprep.h>
1634 : : #endif
1635 : :
1636 : : /**
1637 : : * gsasl_stringprep_nfkc:
1638 : : * @in: a UTF-8 encoded string.
1639 : : * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
1640 : : *
1641 : : * Converts a string into canonical form, standardizing such issues as
1642 : : * whether a character with an accent is represented as a base
1643 : : * character and combining accent or as a single precomposed
1644 : : * character.
1645 : : *
1646 : : * The normalization mode is NFKC (ALL COMPOSE). It standardizes
1647 : : * differences that do not affect the text content, such as the
1648 : : * above-mentioned accent representation. It standardizes the
1649 : : * "compatibility" characters in Unicode, such as SUPERSCRIPT THREE to
1650 : : * the standard forms (in this case DIGIT THREE). Formatting
1651 : : * information may be lost but for most text operations such
1652 : : * characters should be considered the same. It returns a result with
1653 : : * composed forms rather than a maximally decomposed form.
1654 : : *
1655 : : * Return value: Return a newly allocated string, that is the NFKC
1656 : : * normalized form of @str, or NULL on error.
1657 : : *
1658 : : * Deprecated: No replacement functionality in GNU SASL, use GNU
1659 : : * Libidn instead. Note that in SASL, you most likely want to use
1660 : : * SASLprep and not bare NFKC, see gsasl_saslprep().
1661 : : **/
1662 : : char *
1663 : 0 : gsasl_stringprep_nfkc (const char *in, ssize_t len)
1664 : : {
1665 : 0 : char *out = NULL;
1666 : :
1667 : : #if HAVE_LIBIDN
1668 : 0 : out = stringprep_utf8_nfkc_normalize (in, len);
1669 : : #endif
1670 : :
1671 : 0 : return out;
1672 : : }
1673 : :
1674 : : /**
1675 : : * gsasl_stringprep_saslprep:
1676 : : * @in: input ASCII or UTF-8 string with data to prepare according to SASLprep.
1677 : : * @stringprep_rc: pointer to output variable with stringprep error code,
1678 : : * or NULL to indicate that you don't care about it.
1679 : : *
1680 : : * Process a Unicode string for comparison, according to the
1681 : : * "SASLprep" stringprep profile. This function is intended to be
1682 : : * used by Simple Authentication and Security Layer (SASL) mechanisms
1683 : : * (such as PLAIN, CRAM-MD5, and DIGEST-MD5) as well as other
1684 : : * protocols exchanging user names and/or passwords.
1685 : : *
1686 : : * Return value: Return a newly allocated string that is the
1687 : : * "SASLprep" processed form of the input string, or NULL on error,
1688 : : * in which case @stringprep_rc contain the stringprep library error
1689 : : * code.
1690 : : *
1691 : : * Deprecated: Use gsasl_saslprep() instead.
1692 : : **/
1693 : : char *
1694 : 0 : gsasl_stringprep_saslprep (const char *in, int *stringprep_rc)
1695 : : {
1696 : 0 : char *out = NULL;
1697 : : #if HAVE_LIBIDN
1698 : : int rc;
1699 : :
1700 : 0 : rc = stringprep_profile (in, &out, "SASLprep", 0);
1701 [ # # ]: 0 : if (stringprep_rc)
1702 : 0 : *stringprep_rc = rc;
1703 [ # # ]: 0 : if (rc != STRINGPREP_OK)
1704 : 0 : out = NULL;
1705 : : #endif
1706 : :
1707 : 0 : return out;
1708 : : }
1709 : :
1710 : : /**
1711 : : * gsasl_stringprep_trace:
1712 : : * @in: input ASCII or UTF-8 string with data to prepare according to "trace".
1713 : : * @stringprep_rc: pointer to output variable with stringprep error code,
1714 : : * or NULL to indicate that you don't care about it.
1715 : : *
1716 : : * Process a Unicode string for use as trace information, according to
1717 : : * the "trace" stringprep profile. The profile is designed for use
1718 : : * with the SASL ANONYMOUS Mechanism.
1719 : : *
1720 : : * Return value: Return a newly allocated string that is the "trace"
1721 : : * processed form of the input string, or NULL on error, in which
1722 : : * case @stringprep_rc contain the stringprep library error code.
1723 : : *
1724 : : * Deprecated: No replacement functionality in GNU SASL, use GNU
1725 : : * Libidn instead.
1726 : : **/
1727 : : char *
1728 : 0 : gsasl_stringprep_trace (const char *in, int *stringprep_rc)
1729 : : {
1730 : 0 : char *out = NULL;
1731 : : #if HAVE_LIBIDN
1732 : : int rc;
1733 : :
1734 : 0 : rc = stringprep_profile (in, &out, "trace", 0);
1735 [ # # ]: 0 : if (stringprep_rc)
1736 : 0 : *stringprep_rc = rc;
1737 [ # # ]: 0 : if (rc != STRINGPREP_OK)
1738 : 0 : out = NULL;
1739 : : #endif
1740 : :
1741 : 0 : return out;
1742 : : }
1743 : :
1744 : : /**
1745 : : * gsasl_md5pwd_get_password:
1746 : : * @filename: filename of file containing passwords.
1747 : : * @username: username string.
1748 : : * @key: output character array.
1749 : : * @keylen: input maximum size of output character array, on output
1750 : : * contains actual length of output array.
1751 : : *
1752 : : * Retrieve password for user from specified file. To find out how
1753 : : * large the output array must be, call this function with out=NULL.
1754 : : *
1755 : : * The file should be on the UoW "MD5 Based Authentication" format,
1756 : : * which means it is in text format with comments denoted by # first
1757 : : * on the line, with user entries looking as "usernameTABpassword".
1758 : : * This function removes CR and LF at the end of lines before
1759 : : * processing. TAB, CR, and LF denote ASCII values 9, 13, and 10,
1760 : : * respectively.
1761 : : *
1762 : : * Return value: Return GSASL_OK if output buffer contains the
1763 : : * password, GSASL_AUTHENTICATION_ERROR if the user could not be
1764 : : * found, or other error code.
1765 : : *
1766 : : * Deprecated: Use gsasl_simple_getpass() instead.
1767 : : **/
1768 : : int
1769 : 4 : gsasl_md5pwd_get_password (const char *filename,
1770 : : const char *username, char *key, size_t * keylen)
1771 : : {
1772 : : char *tmp;
1773 : : size_t tmplen;
1774 : : int res;
1775 : : FILE *fh;
1776 : :
1777 : 4 : fh = fopen (filename, "r");
1778 [ + + ]: 4 : if (fh == NULL)
1779 : 1 : return GSASL_FOPEN_ERROR;
1780 : 3 : fclose (fh);
1781 : :
1782 : 3 : res = gsasl_simple_getpass (filename, username, &tmp);
1783 [ + + ]: 3 : if (res != GSASL_OK)
1784 : 1 : return res;
1785 : :
1786 : 2 : tmplen = strlen (tmp);
1787 : :
1788 [ + + ]: 2 : if (*keylen < tmplen + 1)
1789 : : {
1790 : 1 : free (tmp);
1791 : 1 : return GSASL_TOO_SMALL_BUFFER;
1792 : : }
1793 : :
1794 : 1 : *keylen = tmplen;
1795 : :
1796 [ + - ]: 1 : if (key)
1797 : 1 : memcpy (key, tmp, tmplen);
1798 : :
1799 : 1 : free (tmp);
1800 : :
1801 : 4 : return GSASL_OK;
1802 : : }
1803 : :
1804 : : #include <minmax.h>
1805 : :
1806 : : /**
1807 : : * gsasl_base64_encode:
1808 : : * @src: input byte array
1809 : : * @srclength: size of input byte array
1810 : : * @target: output byte array
1811 : : * @targsize: size of output byte array
1812 : : *
1813 : : * Encode data as base64. Converts characters, three at a time,
1814 : : * starting at src into four base64 characters in the target area
1815 : : * until the entire input buffer is encoded.
1816 : : *
1817 : : * Return value: Returns the number of data bytes stored at the
1818 : : * target, or -1 on error.
1819 : : *
1820 : : * Deprecated: Use gsasl_base64_to() instead.
1821 : : **/
1822 : : int
1823 : 1 : gsasl_base64_encode (char const *src,
1824 : : size_t srclength, char *target, size_t targsize)
1825 : : {
1826 : : int rc;
1827 : : char *out;
1828 : : size_t outlen;
1829 : : int copied;
1830 : :
1831 : 1 : rc = gsasl_base64_to (src, srclength, &out, &outlen);
1832 [ - + ]: 1 : if (rc)
1833 : 0 : return -1;
1834 : :
1835 : 1 : copied = MIN (outlen, targsize);
1836 : 1 : memcpy (target, out, copied);
1837 : 1 : free (out);
1838 : :
1839 : 1 : return copied;
1840 : : }
1841 : :
1842 : : /**
1843 : : * gsasl_base64_decode:
1844 : : * @src: input byte array
1845 : : * @target: output byte array
1846 : : * @targsize: size of output byte array
1847 : : *
1848 : : * Decode Base64 data. Skips all whitespace anywhere. Converts
1849 : : * characters, four at a time, starting at (or after) src from Base64
1850 : : * numbers into three 8 bit bytes in the target area.
1851 : : *
1852 : : * Return value: Returns the number of data bytes stored at the
1853 : : * target, or -1 on error.
1854 : : *
1855 : : * Deprecated: Use gsasl_base64_from() instead.
1856 : : **/
1857 : : int
1858 : 1 : gsasl_base64_decode (char const *src, char *target, size_t targsize)
1859 : : {
1860 : : int rc;
1861 : : char *out;
1862 : : size_t outlen;
1863 : : int copied;
1864 : :
1865 : 1 : rc = gsasl_base64_from (src, strlen (src), &out, &outlen);
1866 [ - + ]: 1 : if (rc)
1867 : 0 : return -1;
1868 : :
1869 : 1 : copied = MIN (outlen, targsize);
1870 : 1 : memcpy (target, out, copied);
1871 : 1 : free (out);
1872 : :
1873 : 1 : return copied;
1874 : : }
1875 : :
1876 : : static const char *
1877 : 366 : pmap (Gsasl_session * sctx, Gsasl_property prop, char *buf, size_t buflen)
1878 : : {
1879 : : int res;
1880 : :
1881 : 366 : buf[0] = '\0';
1882 : :
1883 : : /* Translate obsolete callbacks to modern properties. */
1884 : :
1885 [ + + + + : 366 : switch (prop)
+ + + + +
+ + ]
1886 : : {
1887 : : case GSASL_SERVICE:
1888 : : {
1889 : 5 : Gsasl_client_callback_service cb_service
1890 : 5 : = gsasl_client_callback_service_get (sctx->ctx);
1891 [ - + ]: 5 : if (!cb_service)
1892 : 0 : break;
1893 : 5 : res = cb_service (sctx, buf, &buflen, NULL, 0, NULL, 0);
1894 [ - + ]: 5 : if (res != GSASL_OK)
1895 : 0 : break;
1896 : 5 : buf[buflen] = '\0';
1897 : 5 : gsasl_property_set (sctx, prop, buf);
1898 : 5 : break;
1899 : : }
1900 : :
1901 : : case GSASL_HOSTNAME:
1902 : : {
1903 : 5 : Gsasl_client_callback_service cb_service
1904 : 5 : = gsasl_client_callback_service_get (sctx->ctx);
1905 [ - + ]: 5 : if (!cb_service)
1906 : 0 : break;
1907 : 5 : res = cb_service (sctx, NULL, 0, buf, &buflen, NULL, 0);
1908 [ - + ]: 5 : if (res != GSASL_OK)
1909 : 0 : break;
1910 : 5 : buf[buflen] = '\0';
1911 : 5 : gsasl_property_set (sctx, prop, buf);
1912 : 5 : break;
1913 : : }
1914 : :
1915 : : case GSASL_ANONYMOUS_TOKEN:
1916 : : {
1917 : 6 : Gsasl_client_callback_anonymous cb_anonymous
1918 : 6 : = gsasl_client_callback_anonymous_get (sctx->ctx);
1919 [ + + ]: 6 : if (!cb_anonymous)
1920 : 5 : break;
1921 : 1 : res = cb_anonymous (sctx, buf, &buflen);
1922 [ - + ]: 1 : if (res != GSASL_OK)
1923 : 0 : break;
1924 : 1 : buf[buflen] = '\0';
1925 : 1 : gsasl_property_set (sctx, prop, buf);
1926 : 1 : break;
1927 : : }
1928 : :
1929 : : case GSASL_AUTHID:
1930 : : {
1931 : 51 : Gsasl_client_callback_authentication_id cb_authentication_id
1932 : 51 : = gsasl_client_callback_authentication_id_get (sctx->ctx);
1933 [ + + ]: 51 : if (!cb_authentication_id)
1934 : 29 : break;
1935 : 22 : res = cb_authentication_id (sctx, buf, &buflen);
1936 [ - + ]: 22 : if (res != GSASL_OK)
1937 : 0 : break;
1938 : 22 : buf[buflen] = '\0';
1939 : 22 : gsasl_property_set (sctx, prop, buf);
1940 : 22 : break;
1941 : : }
1942 : :
1943 : : case GSASL_AUTHZID:
1944 : : {
1945 : 82 : Gsasl_client_callback_authorization_id cb_authorization_id
1946 : 82 : = gsasl_client_callback_authorization_id_get (sctx->ctx);
1947 [ + + ]: 82 : if (!cb_authorization_id)
1948 : 73 : break;
1949 : 9 : res = cb_authorization_id (sctx, buf, &buflen);
1950 [ - + ]: 9 : if (res != GSASL_OK)
1951 : 0 : break;
1952 : 9 : buf[buflen] = '\0';
1953 : 9 : gsasl_property_set (sctx, prop, buf);
1954 : 9 : break;
1955 : : }
1956 : :
1957 : : case GSASL_PASSWORD:
1958 : : {
1959 : 5 : Gsasl_client_callback_password cb_password
1960 : 5 : = gsasl_client_callback_password_get (sctx->ctx);
1961 [ + - ]: 5 : if (!cb_password)
1962 : 5 : break;
1963 : 0 : res = cb_password (sctx, buf, &buflen);
1964 [ # # ]: 0 : if (res != GSASL_OK)
1965 : 0 : break;
1966 : 0 : buf[buflen] = '\0';
1967 : 0 : gsasl_property_set (sctx, prop, buf);
1968 : 0 : break;
1969 : : }
1970 : :
1971 : : case GSASL_PASSCODE:
1972 : : {
1973 : 5 : Gsasl_client_callback_passcode cb_passcode
1974 : 5 : = gsasl_client_callback_passcode_get (sctx->ctx);
1975 [ - + ]: 5 : if (!cb_passcode)
1976 : 0 : break;
1977 : 5 : res = cb_passcode (sctx, buf, &buflen);
1978 [ - + ]: 5 : if (res != GSASL_OK)
1979 : 0 : break;
1980 : 5 : buf[buflen] = '\0';
1981 : 5 : gsasl_property_set (sctx, prop, buf);
1982 : 5 : break;
1983 : : }
1984 : :
1985 : : case GSASL_PIN:
1986 : : {
1987 : 3 : Gsasl_client_callback_pin cb_pin
1988 : 3 : = gsasl_client_callback_pin_get (sctx->ctx);
1989 [ - + ]: 3 : if (!cb_pin)
1990 : 0 : break;
1991 : 3 : res = cb_pin (sctx, sctx->suggestedpin, buf, &buflen);
1992 [ - + ]: 3 : if (res != GSASL_OK)
1993 : 0 : break;
1994 : 3 : buf[buflen] = '\0';
1995 : 3 : gsasl_property_set (sctx, prop, buf);
1996 : 3 : break;
1997 : : }
1998 : :
1999 : : case GSASL_REALM:
2000 : : {
2001 : 14 : Gsasl_client_callback_realm cb_realm
2002 : 14 : = gsasl_client_callback_realm_get (sctx->ctx);
2003 [ + - ]: 14 : if (!cb_realm)
2004 : 14 : break;
2005 : 0 : res = cb_realm (sctx, buf, &buflen);
2006 [ # # ]: 0 : if (res != GSASL_OK)
2007 : 0 : break;
2008 : 0 : buf[buflen] = '\0';
2009 : 0 : gsasl_property_set (sctx, prop, buf);
2010 : 0 : break;
2011 : : }
2012 : :
2013 : : #if USE_DIGEST_MD5
2014 : : case GSASL_QOP:
2015 : : {
2016 : 7 : Gsasl_client_callback_qop cb_qop
2017 : 7 : = gsasl_client_callback_qop_get (sctx->ctx);
2018 : : int serverqops;
2019 : : Gsasl_qop qop;
2020 [ + + ]: 7 : if (!cb_qop)
2021 : 5 : break;
2022 : 2 : serverqops = digest_md5_qopstr2qops (sctx->qops);
2023 [ - + ]: 2 : if (serverqops == -1)
2024 : 0 : return NULL;
2025 : 2 : qop = cb_qop (sctx, serverqops);
2026 [ + - ]: 2 : if (qop & 0x07)
2027 : 2 : gsasl_property_set (sctx, prop, digest_md5_qops2qopstr (qop));
2028 : 2 : break;
2029 : : }
2030 : : break;
2031 : : #endif
2032 : :
2033 : : default:
2034 : 183 : break;
2035 : : }
2036 : :
2037 : 366 : return gsasl_property_fast (sctx, prop);
2038 : : }
2039 : :
2040 : : const char *
2041 : 366 : _gsasl_obsolete_property_map (Gsasl_session * sctx, Gsasl_property prop)
2042 : : {
2043 : : const char *ret;
2044 : : char *buf;
2045 : :
2046 : 366 : buf = malloc (BUFSIZ);
2047 [ - + ]: 366 : if (!buf)
2048 : 0 : return NULL;
2049 : :
2050 : 366 : ret = pmap (sctx, prop, buf, BUFSIZ - 1);
2051 : :
2052 : 366 : free (buf);
2053 : :
2054 : 366 : return ret;
2055 : : }
2056 : :
2057 : : int
2058 : 227 : _gsasl_obsolete_callback (Gsasl * ctx, Gsasl_session * sctx,
2059 : : Gsasl_property prop)
2060 : : {
2061 : : int res;
2062 : :
2063 : : /* Call obsolete callbacks. */
2064 : :
2065 [ + + + - : 227 : switch (prop)
+ + + + ]
2066 : : {
2067 : : case GSASL_VALIDATE_ANONYMOUS:
2068 : : {
2069 : : Gsasl_server_callback_anonymous cb_anonymous;
2070 [ - + ]: 5 : if (!sctx->anonymous_token)
2071 : 0 : break;
2072 : 5 : cb_anonymous = gsasl_server_callback_anonymous_get (sctx->ctx);
2073 [ + + ]: 5 : if (!cb_anonymous)
2074 : 4 : break;
2075 : 1 : res = cb_anonymous (sctx, sctx->anonymous_token);
2076 : 1 : return res;
2077 : : break;
2078 : : }
2079 : :
2080 : : case GSASL_VALIDATE_EXTERNAL:
2081 : : {
2082 : 6 : Gsasl_server_callback_external cb_external
2083 : 6 : = gsasl_server_callback_external_get (sctx->ctx);
2084 [ + + ]: 6 : if (!cb_external)
2085 : 5 : break;
2086 : 1 : res = cb_external (sctx);
2087 : 1 : return res;
2088 : : break;
2089 : : }
2090 : :
2091 : : case GSASL_VALIDATE_SECURID:
2092 : : {
2093 : 8 : Gsasl_server_callback_securid cb_securid
2094 : 8 : = gsasl_server_callback_securid_get (sctx->ctx);
2095 : : #define MAX_SECURID 32 /* See RFC 2808. */
2096 : : char buf[MAX_SECURID + 1];
2097 : 8 : size_t buflen = MAX_SECURID;
2098 [ - + ]: 8 : if (!cb_securid)
2099 : 0 : break;
2100 : 8 : res = cb_securid (sctx, sctx->authid, sctx->authzid, sctx->passcode,
2101 : : sctx->pin, buf, &buflen);
2102 [ + + ][ + + ]: 8 : if (buflen > 0 && buflen < MAX_SECURID)
2103 : : {
2104 : 1 : buf[buflen] = '\0';
2105 : 1 : gsasl_property_set (sctx, GSASL_SUGGESTED_PIN, buf);
2106 : : }
2107 : 8 : return res;
2108 : : break;
2109 : : }
2110 : :
2111 : : case GSASL_VALIDATE_GSSAPI:
2112 : : {
2113 : 0 : Gsasl_server_callback_gssapi cb_gssapi
2114 : 0 : = gsasl_server_callback_gssapi_get (sctx->ctx);
2115 [ # # ]: 0 : if (!cb_gssapi)
2116 : 0 : break;
2117 : 0 : res = cb_gssapi (sctx, sctx->gssapi_display_name, sctx->authzid);
2118 : 0 : return res;
2119 : : break;
2120 : : }
2121 : :
2122 : : case GSASL_VALIDATE_SIMPLE:
2123 : : {
2124 : 3 : Gsasl_server_callback_validate cb_validate
2125 : 3 : = gsasl_server_callback_validate_get (sctx->ctx);
2126 [ - + ]: 3 : if (!cb_validate)
2127 : 0 : break;
2128 : 3 : res = cb_validate (sctx, sctx->authzid, sctx->authid, sctx->password);
2129 : 3 : return res;
2130 : : break;
2131 : : }
2132 : :
2133 : : case GSASL_PASSWORD:
2134 : : {
2135 : 32 : Gsasl_server_callback_retrieve cb_retrieve
2136 : 32 : = gsasl_server_callback_retrieve_get (sctx->ctx);
2137 : : char *buf;
2138 : 32 : size_t buflen = BUFSIZ - 1;
2139 [ + + ]: 32 : if (!cb_retrieve)
2140 : 5 : break;
2141 : 27 : buf = malloc (BUFSIZ);
2142 [ - + ]: 27 : if (!buf)
2143 : 0 : return GSASL_MALLOC_ERROR;
2144 : 27 : res = cb_retrieve (sctx, sctx->authid, sctx->authzid,
2145 : 27 : sctx->hostname, buf, &buflen);
2146 [ + - ]: 27 : if (res == GSASL_OK)
2147 : 27 : gsasl_property_set_raw (sctx, GSASL_PASSWORD, buf, buflen);
2148 : : /* FIXME else if (res == GSASL_TOO_SMALL_BUFFER)... */
2149 : 27 : free (buf);
2150 : 27 : return res;
2151 : : break;
2152 : : }
2153 : :
2154 : : #if USE_DIGEST_MD5
2155 : : case GSASL_QOPS:
2156 : : {
2157 : 10 : Gsasl_server_callback_qop cb_qop
2158 : 10 : = gsasl_server_callback_qop_get (sctx->ctx);
2159 : : Gsasl_qop qops;
2160 [ + + ]: 10 : if (!cb_qop)
2161 : 5 : break;
2162 : 5 : qops = cb_qop (sctx);
2163 [ + + ]: 5 : if (qops & 0x07)
2164 : 3 : gsasl_property_set (sctx, GSASL_QOPS,
2165 : : digest_md5_qops2qopstr (qops));
2166 : 5 : return GSASL_OK;
2167 : : break;
2168 : : }
2169 : : #endif
2170 : :
2171 : : default:
2172 : 163 : break;
2173 : : }
2174 : :
2175 : 227 : return GSASL_NO_CALLBACK;
2176 : : }
|