Bump versions.
[gsasl.git] / lib / src / obsolete.c
blob232629d22a795b33296178d2f215562a08f49f03
1 /* obsolete.c --- Obsolete functions kept around for backwards compatibility.
2 * Copyright (C) 2002, 2003, 2004, 2005, 2006 Simon Josefsson
4 * This file is part of GNU SASL Library.
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.
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.
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.
23 #include "internal.h"
25 /**
26 * gsasl_client_listmech:
27 * @ctx: libgsasl handle.
28 * @out: output character array.
29 * @outlen: input maximum size of output character array, on output
30 * contains actual length of output array.
32 * Write SASL names, separated by space, of mechanisms supported by
33 * the libgsasl client to the output array. To find out how large the
34 * output array must be, call this function with out=NULL.
36 * Return value: Returns GSASL_OK if successful, or error code.
38 * Deprecated: Use gsasl_client_mechlist() instead.
39 **/
40 int
41 gsasl_client_listmech (Gsasl * ctx, char *out, size_t * outlen)
43 char *tmp;
44 int rc;
46 rc = gsasl_client_mechlist (ctx, &tmp);
48 if (rc == GSASL_OK)
50 size_t tmplen = strlen (tmp);
52 if (tmplen >= *outlen)
54 free (tmp);
55 return GSASL_TOO_SMALL_BUFFER;
58 if (out)
59 strcpy (out, tmp);
60 *outlen = tmplen + 1;
61 free (tmp);
64 return rc;
67 /**
68 * gsasl_server_listmech:
69 * @ctx: libgsasl handle.
70 * @out: output character array.
71 * @outlen: input maximum size of output character array, on output
72 * contains actual length of output array.
74 * Write SASL names, separated by space, of mechanisms supported by
75 * the libgsasl server to the output array. To find out how large the
76 * output array must be, call this function with out=NULL.
78 * Return value: Returns GSASL_OK if successful, or error code.
80 * Deprecated: Use gsasl_server_mechlist() instead.
81 **/
82 int
83 gsasl_server_listmech (Gsasl * ctx, char *out, size_t * outlen)
85 char *tmp;
86 int rc;
88 rc = gsasl_server_mechlist (ctx, &tmp);
90 if (rc == GSASL_OK)
92 size_t tmplen = strlen (tmp);
94 if (tmplen >= *outlen)
96 free (tmp);
97 return GSASL_TOO_SMALL_BUFFER;
100 if (out)
101 strcpy (out, tmp);
102 *outlen = tmplen + 1;
103 free (tmp);
106 return rc;
109 static int
110 _gsasl_step (Gsasl_session * sctx,
111 const char *input, size_t input_len,
112 char *output, size_t * output_len)
114 char *tmp;
115 size_t tmplen;
116 int rc;
118 rc = gsasl_step (sctx, input, input_len, &tmp, &tmplen);
120 if (rc == GSASL_OK || rc == GSASL_NEEDS_MORE)
122 if (tmplen >= *output_len)
124 free (tmp);
125 /* XXX We lose the step token here, don't we? */
126 return GSASL_TOO_SMALL_BUFFER;
129 if (output)
130 memcpy (output, tmp, tmplen);
131 *output_len = tmplen;
132 free (tmp);
135 return rc;
139 * gsasl_client_step:
140 * @sctx: libgsasl client handle.
141 * @input: input byte array.
142 * @input_len: size of input byte array.
143 * @output: output byte array.
144 * @output_len: size of output byte array.
146 * Perform one step of SASL authentication in client. This reads data
147 * from server (specified with input and input_len), processes it
148 * (potentially invoking callbacks to the application), and writes
149 * data to server (into variables output and output_len).
151 * The contents of the output buffer is unspecified if this functions
152 * returns anything other than GSASL_NEEDS_MORE.
154 * Return value: Returns GSASL_OK if authenticated terminated
155 * successfully, GSASL_NEEDS_MORE if more data is needed, or error
156 * code.
158 * Deprecated: Use gsasl_step() instead.
161 gsasl_client_step (Gsasl_session * sctx,
162 const char *input,
163 size_t input_len, char *output, size_t * output_len)
165 return _gsasl_step (sctx, input, input_len, output, output_len);
169 * gsasl_server_step:
170 * @sctx: libgsasl server handle.
171 * @input: input byte array.
172 * @input_len: size of input byte array.
173 * @output: output byte array.
174 * @output_len: size of output byte array.
176 * Perform one step of SASL authentication in server. This reads data
177 * from client (specified with input and input_len), processes it
178 * (potentially invoking callbacks to the application), and writes
179 * data to client (into variables output and output_len).
181 * The contents of the output buffer is unspecified if this functions
182 * returns anything other than GSASL_NEEDS_MORE.
184 * Return value: Returns GSASL_OK if authenticated terminated
185 * successfully, GSASL_NEEDS_MORE if more data is needed, or error
186 * code.
188 * Deprecated: Use gsasl_step() instead.
191 gsasl_server_step (Gsasl_session * sctx,
192 const char *input,
193 size_t input_len, char *output, size_t * output_len)
195 return _gsasl_step (sctx, input, input_len, output, output_len);
198 static int
199 _gsasl_step64 (Gsasl_session * sctx,
200 const char *b64input, char *b64output, size_t b64output_len)
202 char *tmp;
203 int rc;
205 rc = gsasl_step64 (sctx, b64input, &tmp);
207 if (rc == GSASL_OK || rc == GSASL_NEEDS_MORE)
209 if (b64output_len <= strlen (tmp))
211 free (tmp);
212 /* XXX We lose the step token here, don't we? */
213 return GSASL_TOO_SMALL_BUFFER;
216 if (b64output)
217 strcpy (b64output, tmp);
218 free (tmp);
221 return rc;
225 * gsasl_client_step_base64:
226 * @sctx: libgsasl client handle.
227 * @b64input: input base64 encoded byte array.
228 * @b64output: output base64 encoded byte array.
229 * @b64output_len: size of output base64 encoded byte array.
231 * This is a simple wrapper around gsasl_client_step() that base64
232 * decodes the input and base64 encodes the output.
234 * Return value: See gsasl_client_step().
236 * Deprecated: Use gsasl_step64() instead.
239 gsasl_client_step_base64 (Gsasl_session * sctx,
240 const char *b64input,
241 char *b64output, size_t b64output_len)
243 return _gsasl_step64 (sctx, b64input, b64output, b64output_len);
247 * gsasl_server_step_base64:
248 * @sctx: libgsasl server handle.
249 * @b64input: input base64 encoded byte array.
250 * @b64output: output base64 encoded byte array.
251 * @b64output_len: size of output base64 encoded byte array.
253 * This is a simple wrapper around gsasl_server_step() that base64
254 * decodes the input and base64 encodes the output.
256 * Return value: See gsasl_server_step().
258 * Deprecated: Use gsasl_step64() instead.
261 gsasl_server_step_base64 (Gsasl_session * sctx,
262 const char *b64input,
263 char *b64output, size_t b64output_len)
265 return _gsasl_step64 (sctx, b64input, b64output, b64output_len);
269 * gsasl_client_finish:
270 * @sctx: libgsasl client handle.
272 * Destroy a libgsasl client handle. The handle must not be used with
273 * other libgsasl functions after this call.
275 * Deprecated: Use gsasl_finish() instead.
277 void
278 gsasl_client_finish (Gsasl_session * sctx)
280 gsasl_finish (sctx);
284 * gsasl_server_finish:
285 * @sctx: libgsasl server handle.
287 * Destroy a libgsasl server handle. The handle must not be used with
288 * other libgsasl functions after this call.
290 * Deprecated: Use gsasl_finish() instead.
292 void
293 gsasl_server_finish (Gsasl_session * sctx)
295 gsasl_finish (sctx);
299 * gsasl_client_ctx_get:
300 * @sctx: libgsasl client handle
302 * Return value: Returns the libgsasl handle given a libgsasl client handle.
304 * Deprecated: This function is not useful with the new 0.2.0 API.
306 Gsasl *
307 gsasl_client_ctx_get (Gsasl_session * sctx)
309 return sctx->ctx;
313 * gsasl_client_application_data_set:
314 * @sctx: libgsasl client handle.
315 * @application_data: opaque pointer to application specific data.
317 * Store application specific data in the libgsasl client handle. The
318 * application data can be later (for instance, inside a callback) be
319 * retrieved by calling gsasl_client_application_data_get(). It is
320 * normally used by the application to maintain state between the main
321 * program and the callback.
323 * Deprecated: Use gsasl_callback_hook_set() or
324 * gsasl_session_hook_set() instead.
326 void
327 gsasl_client_application_data_set (Gsasl_session * sctx,
328 void *application_data)
330 gsasl_appinfo_set (sctx, application_data);
334 * gsasl_client_application_data_get:
335 * @sctx: libgsasl client handle.
337 * Retrieve application specific data from libgsasl client handle. The
338 * application data is set using gsasl_client_application_data_set().
339 * It is normally used by the application to maintain state between
340 * the main program and the callback.
342 * Return value: Returns the application specific data, or NULL.
344 * Deprecated: Use gsasl_callback_hook_get() or
345 * gsasl_session_hook_get() instead.
347 void *
348 gsasl_client_application_data_get (Gsasl_session * sctx)
350 return gsasl_appinfo_get (sctx);
354 * gsasl_server_ctx_get:
355 * @sctx: libgsasl server handle
357 * Return value: Returns the libgsasl handle given a libgsasl server handle.
359 * Deprecated: This function is not useful with the new 0.2.0 API.
361 Gsasl *
362 gsasl_server_ctx_get (Gsasl_session * sctx)
364 return sctx->ctx;
368 * gsasl_server_application_data_set:
369 * @sctx: libgsasl server handle.
370 * @application_data: opaque pointer to application specific data.
372 * Store application specific data in the libgsasl server handle. The
373 * application data can be later (for instance, inside a callback) be
374 * retrieved by calling gsasl_server_application_data_get(). It is
375 * normally used by the application to maintain state between the main
376 * program and the callback.
378 * Deprecated: Use gsasl_callback_hook_set() or
379 * gsasl_session_hook_set() instead.
381 void
382 gsasl_server_application_data_set (Gsasl_session * sctx,
383 void *application_data)
385 gsasl_appinfo_set (sctx, application_data);
389 * gsasl_server_application_data_get:
390 * @sctx: libgsasl server handle.
392 * Retrieve application specific data from libgsasl server handle. The
393 * application data is set using gsasl_server_application_data_set().
394 * It is normally used by the application to maintain state between
395 * the main program and the callback.
397 * Return value: Returns the application specific data, or NULL.
399 * Deprecated: Use gsasl_callback_hook_get() or
400 * gsasl_session_hook_get() instead.
402 void *
403 gsasl_server_application_data_get (Gsasl_session * sctx)
405 return gsasl_appinfo_get (sctx);
409 * gsasl_randomize:
410 * @strong: 0 iff operation should not block, non-0 for very strong randomness.
411 * @data: output array to be filled with random data.
412 * @datalen: size of output array.
414 * Store cryptographically random data of given size in the provided
415 * buffer.
417 * Return value: Returns %GSASL_OK iff successful.
419 * Deprecated: Use gsasl_random() or gsasl_nonce() instead.
422 gsasl_randomize (int strong, char *data, size_t datalen)
424 if (strong)
425 return gsasl_random (data, datalen);
426 return gsasl_nonce (data, datalen);
430 * gsasl_ctx_get:
431 * @sctx: libgsasl session handle
433 * Return value: Returns the libgsasl handle given a libgsasl session handle.
435 * Deprecated: This function is not useful with the new 0.2.0 API.
437 Gsasl *
438 gsasl_ctx_get (Gsasl_session * sctx)
440 return sctx->ctx;
444 * gsasl_encode_inline:
445 * @sctx: libgsasl session handle.
446 * @input: input byte array.
447 * @input_len: size of input byte array.
448 * @output: output byte array.
449 * @output_len: size of output byte array.
451 * Encode data according to negotiated SASL mechanism. This might mean
452 * that data is integrity or privacy protected.
454 * Return value: Returns GSASL_OK if encoding was successful, otherwise
455 * an error code.
457 * Deprecated: Use gsasl_encode() instead.
459 * Since: 0.2.0
462 gsasl_encode_inline (Gsasl_session * sctx,
463 const char *input, size_t input_len,
464 char *output, size_t * output_len)
466 char *tmp;
467 size_t tmplen;
468 int res;
470 res = gsasl_encode (sctx, input, input_len, &tmp, &tmplen);
471 if (res == GSASL_OK)
473 if (*output_len < tmplen)
474 return GSASL_TOO_SMALL_BUFFER;
475 *output_len = tmplen;
476 memcpy (output, tmp, tmplen);
477 free (output);
480 return res;
484 * gsasl_decode_inline:
485 * @sctx: libgsasl session handle.
486 * @input: input byte array.
487 * @input_len: size of input byte array.
488 * @output: output byte array.
489 * @output_len: size of output byte array.
491 * Decode data according to negotiated SASL mechanism. This might mean
492 * that data is integrity or privacy protected.
494 * Return value: Returns GSASL_OK if encoding was successful, otherwise
495 * an error code.
497 * Deprecated: Use gsasl_decode() instead.
499 * Since: 0.2.0
502 gsasl_decode_inline (Gsasl_session * sctx,
503 const char *input, size_t input_len,
504 char *output, size_t * output_len)
506 char *tmp;
507 size_t tmplen;
508 int res;
510 res = gsasl_decode (sctx, input, input_len, &tmp, &tmplen);
511 if (res == GSASL_OK)
513 if (*output_len < tmplen)
514 return GSASL_TOO_SMALL_BUFFER;
515 *output_len = tmplen;
516 memcpy (output, tmp, tmplen);
517 free (output);
520 return res;
524 * gsasl_application_data_set:
525 * @ctx: libgsasl handle.
526 * @appdata: opaque pointer to application specific data.
528 * Store application specific data in the libgsasl handle. The
529 * application data can be later (for instance, inside a callback) be
530 * retrieved by calling gsasl_application_data_get(). It is normally
531 * used by the application to maintain state between the main program
532 * and the callback.
534 * Deprecated: Use gsasl_callback_hook_set() instead.
536 void
537 gsasl_application_data_set (Gsasl * ctx, void *appdata)
539 ctx->application_hook = appdata;
543 * gsasl_application_data_get:
544 * @ctx: libgsasl handle.
546 * Retrieve application specific data from libgsasl handle. The
547 * application data is set using gsasl_application_data_set(). It is
548 * normally used by the application to maintain state between the main
549 * program and the callback.
551 * Return value: Returns the application specific data, or NULL.
553 * Deprecated: Use gsasl_callback_hook_get() instead.
555 void *
556 gsasl_application_data_get (Gsasl * ctx)
558 return ctx->application_hook;
562 * gsasl_appinfo_set:
563 * @sctx: libgsasl session handle.
564 * @appdata: opaque pointer to application specific data.
566 * Store application specific data in the libgsasl session handle.
567 * The application data can be later (for instance, inside a callback)
568 * be retrieved by calling gsasl_appinfo_get(). It is normally used
569 * by the application to maintain state between the main program and
570 * the callback.
572 * Deprecated: Use gsasl_callback_hook_set() instead.
574 void
575 gsasl_appinfo_set (Gsasl_session * sctx, void *appdata)
577 sctx->application_data = appdata;
581 * gsasl_appinfo_get:
582 * @sctx: libgsasl session handle.
584 * Retrieve application specific data from libgsasl session
585 * handle. The application data is set using gsasl_appinfo_set(). It
586 * is normally used by the application to maintain state between the
587 * main program and the callback.
589 * Return value: Returns the application specific data, or NULL.
591 * Deprecated: Use gsasl_callback_hook_get() instead.
593 void *
594 gsasl_appinfo_get (Gsasl_session * sctx)
596 return sctx->application_data;
600 * gsasl_server_suggest_mechanism:
601 * @ctx: libgsasl handle.
602 * @mechlist: input character array with SASL mechanism names,
603 * separated by invalid characters (e.g. SPC).
605 * Return value: Returns name of "best" SASL mechanism supported by
606 * the libgsasl server which is present in the input string.
608 * Deprecated: This function was never useful, since it is the client
609 * that chose which mechanism to use.
611 const char *
612 gsasl_server_suggest_mechanism (Gsasl * ctx, const char *mechlist)
614 return NULL; /* This function is just silly. */
618 * gsasl_client_callback_authentication_id_set:
619 * @ctx: libgsasl handle.
620 * @cb: callback function
622 * Specify the callback function to use in the client to set the
623 * authentication identity. The function can be later retrieved using
624 * gsasl_client_callback_authentication_id_get().
626 * Deprecated: This function is part of the old callback interface.
627 * The new interface uses gsasl_callback_set() to set the application
628 * callback, and uses gsasl_callback() or gsasl_property_get() to
629 * invoke the callback for certain properties.
631 void
632 gsasl_client_callback_authentication_id_set (Gsasl * ctx,
633 Gsasl_client_callback_authentication_id
636 ctx->cbc_authentication_id = cb;
640 * gsasl_client_callback_authentication_id_get:
641 * @ctx: libgsasl handle.
643 * Return value: Returns the callback earlier set by calling
644 * gsasl_client_callback_authentication_id_set().
646 * Deprecated: This function is part of the old callback interface.
647 * The new interface uses gsasl_callback_set() to set the application
648 * callback, and uses gsasl_callback() or gsasl_property_get() to
649 * invoke the callback for certain properties.
651 Gsasl_client_callback_authentication_id
652 gsasl_client_callback_authentication_id_get (Gsasl * ctx)
654 return ctx ? ctx->cbc_authentication_id : NULL;
658 * gsasl_client_callback_authorization_id_set:
659 * @ctx: libgsasl handle.
660 * @cb: callback function
662 * Specify the callback function to use in the client to set the
663 * authorization identity. The function can be later retrieved using
664 * gsasl_client_callback_authorization_id_get().
666 * Deprecated: This function is part of the old callback interface.
667 * The new interface uses gsasl_callback_set() to set the application
668 * callback, and uses gsasl_callback() or gsasl_property_get() to
669 * invoke the callback for certain properties.
671 void
672 gsasl_client_callback_authorization_id_set (Gsasl * ctx,
673 Gsasl_client_callback_authorization_id
676 ctx->cbc_authorization_id = cb;
680 * gsasl_client_callback_authorization_id_get:
681 * @ctx: libgsasl handle.
683 * Return value: Returns the callback earlier set by calling
684 * gsasl_client_callback_authorization_id_set().
686 * Deprecated: This function is part of the old callback interface.
687 * The new interface uses gsasl_callback_set() to set the application
688 * callback, and uses gsasl_callback() or gsasl_property_get() to
689 * invoke the callback for certain properties.
691 Gsasl_client_callback_authorization_id
692 gsasl_client_callback_authorization_id_get (Gsasl * ctx)
694 return ctx ? ctx->cbc_authorization_id : NULL;
698 * gsasl_client_callback_password_set:
699 * @ctx: libgsasl handle.
700 * @cb: callback function
702 * Specify the callback function to use in the client to set the
703 * password. The function can be later retrieved using
704 * gsasl_client_callback_password_get().
706 * Deprecated: This function is part of the old callback interface.
707 * The new interface uses gsasl_callback_set() to set the application
708 * callback, and uses gsasl_callback() or gsasl_property_get() to
709 * invoke the callback for certain properties.
711 void
712 gsasl_client_callback_password_set (Gsasl * ctx,
713 Gsasl_client_callback_password cb)
715 ctx->cbc_password = cb;
720 * gsasl_client_callback_password_get:
721 * @ctx: libgsasl handle.
723 * Return value: Returns the callback earlier set by calling
724 * gsasl_client_callback_password_set().
726 * Deprecated: This function is part of the old callback interface.
727 * The new interface uses gsasl_callback_set() to set the application
728 * callback, and uses gsasl_callback() or gsasl_property_get() to
729 * invoke the callback for certain properties.
731 Gsasl_client_callback_password
732 gsasl_client_callback_password_get (Gsasl * ctx)
734 return ctx ? ctx->cbc_password : NULL;
738 * gsasl_client_callback_passcode_set:
739 * @ctx: libgsasl handle.
740 * @cb: callback function
742 * Specify the callback function to use in the client to set the
743 * passcode. The function can be later retrieved using
744 * gsasl_client_callback_passcode_get().
746 * Deprecated: This function is part of the old callback interface.
747 * The new interface uses gsasl_callback_set() to set the application
748 * callback, and uses gsasl_callback() or gsasl_property_get() to
749 * invoke the callback for certain properties.
751 void
752 gsasl_client_callback_passcode_set (Gsasl * ctx,
753 Gsasl_client_callback_passcode cb)
755 ctx->cbc_passcode = cb;
760 * gsasl_client_callback_passcode_get:
761 * @ctx: libgsasl handle.
763 * Return value: Returns the callback earlier set by calling
764 * gsasl_client_callback_passcode_set().
766 * Deprecated: This function is part of the old callback interface.
767 * The new interface uses gsasl_callback_set() to set the application
768 * callback, and uses gsasl_callback() or gsasl_property_get() to
769 * invoke the callback for certain properties.
771 Gsasl_client_callback_passcode
772 gsasl_client_callback_passcode_get (Gsasl * ctx)
774 return ctx ? ctx->cbc_passcode : NULL;
778 * gsasl_client_callback_pin_set:
779 * @ctx: libgsasl handle.
780 * @cb: callback function
782 * Specify the callback function to use in the client to chose a new
783 * pin, possibly suggested by the server, for the SECURID mechanism.
784 * This is not normally invoked, but only when the server requests it.
785 * The function can be later retrieved using
786 * gsasl_client_callback_pin_get().
788 * Deprecated: This function is part of the old callback interface.
789 * The new interface uses gsasl_callback_set() to set the application
790 * callback, and uses gsasl_callback() or gsasl_property_get() to
791 * invoke the callback for certain properties.
793 void
794 gsasl_client_callback_pin_set (Gsasl * ctx, Gsasl_client_callback_pin cb)
796 ctx->cbc_pin = cb;
801 * gsasl_client_callback_pin_get:
802 * @ctx: libgsasl handle.
804 * Return value: Returns the callback earlier set by calling
805 * gsasl_client_callback_pin_set().
807 * Deprecated: This function is part of the old callback interface.
808 * The new interface uses gsasl_callback_set() to set the application
809 * callback, and uses gsasl_callback() or gsasl_property_get() to
810 * invoke the callback for certain properties.
812 Gsasl_client_callback_pin
813 gsasl_client_callback_pin_get (Gsasl * ctx)
815 return ctx ? ctx->cbc_pin : NULL;
819 * gsasl_client_callback_service_set:
820 * @ctx: libgsasl handle.
821 * @cb: callback function
823 * Specify the callback function to use in the client to set the name
824 * of the service. The service buffer should be a registered GSSAPI
825 * host-based service name, hostname the name of the server.
826 * Servicename is used by DIGEST-MD5 and should be the name of generic
827 * server in case of a replicated service. The function can be later
828 * retrieved using gsasl_client_callback_service_get().
830 * Deprecated: This function is part of the old callback interface.
831 * The new interface uses gsasl_callback_set() to set the application
832 * callback, and uses gsasl_callback() or gsasl_property_get() to
833 * invoke the callback for certain properties.
835 void
836 gsasl_client_callback_service_set (Gsasl * ctx,
837 Gsasl_client_callback_service cb)
839 ctx->cbc_service = cb;
843 * gsasl_client_callback_service_get:
844 * @ctx: libgsasl handle.
846 * Return value: Returns the callback earlier set by calling
847 * gsasl_client_callback_service_set().
849 * Deprecated: This function is part of the old callback interface.
850 * The new interface uses gsasl_callback_set() to set the application
851 * callback, and uses gsasl_callback() or gsasl_property_get() to
852 * invoke the callback for certain properties.
854 Gsasl_client_callback_service
855 gsasl_client_callback_service_get (Gsasl * ctx)
857 return ctx ? ctx->cbc_service : NULL;
861 * gsasl_client_callback_anonymous_set:
862 * @ctx: libgsasl handle.
863 * @cb: callback function
865 * Specify the callback function to use in the client to set the
866 * anonymous token, which usually is the users email address. The
867 * function can be later retrieved using
868 * gsasl_client_callback_anonymous_get().
870 * Deprecated: This function is part of the old callback interface.
871 * The new interface uses gsasl_callback_set() to set the application
872 * callback, and uses gsasl_callback() or gsasl_property_get() to
873 * invoke the callback for certain properties.
875 void
876 gsasl_client_callback_anonymous_set (Gsasl * ctx,
877 Gsasl_client_callback_anonymous cb)
879 ctx->cbc_anonymous = cb;
883 * gsasl_client_callback_anonymous_get:
884 * @ctx: libgsasl handle.
886 * Return value: Returns the callback earlier set by calling
887 * gsasl_client_callback_anonymous_set().
889 * Deprecated: This function is part of the old callback interface.
890 * The new interface uses gsasl_callback_set() to set the application
891 * callback, and uses gsasl_callback() or gsasl_property_get() to
892 * invoke the callback for certain properties.
894 Gsasl_client_callback_anonymous
895 gsasl_client_callback_anonymous_get (Gsasl * ctx)
897 return ctx ? ctx->cbc_anonymous : NULL;
901 * gsasl_client_callback_qop_set:
902 * @ctx: libgsasl handle.
903 * @cb: callback function
905 * Specify the callback function to use in the client to determine the
906 * qop to use after looking at what the server offered. The function
907 * can be later retrieved using gsasl_client_callback_qop_get().
909 * Deprecated: This function is part of the old callback interface.
910 * The new interface uses gsasl_callback_set() to set the application
911 * callback, and uses gsasl_callback() or gsasl_property_get() to
912 * invoke the callback for certain properties.
914 void
915 gsasl_client_callback_qop_set (Gsasl * ctx, Gsasl_client_callback_qop cb)
917 ctx->cbc_qop = cb;
921 * gsasl_client_callback_qop_get:
922 * @ctx: libgsasl handle.
924 * Return value: Returns the callback earlier set by calling
925 * gsasl_client_callback_qop_set().
927 * Deprecated: This function is part of the old callback interface.
928 * The new interface uses gsasl_callback_set() to set the application
929 * callback, and uses gsasl_callback() or gsasl_property_get() to
930 * invoke the callback for certain properties.
932 Gsasl_client_callback_qop
933 gsasl_client_callback_qop_get (Gsasl * ctx)
935 return ctx ? ctx->cbc_qop : NULL;
939 * gsasl_client_callback_maxbuf_set:
940 * @ctx: libgsasl handle.
941 * @cb: callback function
943 * Specify the callback function to use in the client to inform the
944 * server of the largest buffer the client is able to receive when
945 * using the DIGEST-MD5 "auth-int" or "auth-conf" Quality of
946 * Protection (qop). If this directive is missing, the default value
947 * 65536 will be assumed. The function can be later retrieved using
948 * gsasl_client_callback_maxbuf_get().
950 * Deprecated: This function is part of the old callback interface.
951 * The new interface uses gsasl_callback_set() to set the application
952 * callback, and uses gsasl_callback() or gsasl_property_get() to
953 * invoke the callback for certain properties.
955 void
956 gsasl_client_callback_maxbuf_set (Gsasl * ctx,
957 Gsasl_client_callback_maxbuf cb)
959 ctx->cbc_maxbuf = cb;
963 * gsasl_client_callback_maxbuf_get:
964 * @ctx: libgsasl handle.
966 * Return value: Returns the callback earlier set by calling
967 * gsasl_client_callback_maxbuf_set().
969 * Deprecated: This function is part of the old callback interface.
970 * The new interface uses gsasl_callback_set() to set the application
971 * callback, and uses gsasl_callback() or gsasl_property_get() to
972 * invoke the callback for certain properties.
974 Gsasl_client_callback_maxbuf
975 gsasl_client_callback_maxbuf_get (Gsasl * ctx)
977 return ctx ? ctx->cbc_maxbuf : NULL;
981 * gsasl_client_callback_realm_set:
982 * @ctx: libgsasl handle.
983 * @cb: callback function
985 * Specify the callback function to use in the client to know which
986 * realm it belongs to. The realm is used by the server to determine
987 * which username and password to use. The function can be later
988 * retrieved using gsasl_client_callback_realm_get().
990 * Deprecated: This function is part of the old callback interface.
991 * The new interface uses gsasl_callback_set() to set the application
992 * callback, and uses gsasl_callback() or gsasl_property_get() to
993 * invoke the callback for certain properties.
995 void
996 gsasl_client_callback_realm_set (Gsasl * ctx, Gsasl_client_callback_realm cb)
998 ctx->cbc_realm = cb;
1002 * gsasl_client_callback_realm_get:
1003 * @ctx: libgsasl handle.
1005 * Return value: Returns the callback earlier set by calling
1006 * gsasl_client_callback_realm_set().
1008 * Deprecated: This function is part of the old callback interface.
1009 * The new interface uses gsasl_callback_set() to set the application
1010 * callback, and uses gsasl_callback() or gsasl_property_get() to
1011 * invoke the callback for certain properties.
1013 Gsasl_client_callback_realm
1014 gsasl_client_callback_realm_get (Gsasl * ctx)
1016 return ctx ? ctx->cbc_realm : NULL;
1020 * gsasl_server_callback_validate_set:
1021 * @ctx: libgsasl handle.
1022 * @cb: callback function
1024 * Specify the callback function to use in the server for deciding if
1025 * user is authenticated using authentication identity, authorization
1026 * identity and password. The function can be later retrieved using
1027 * gsasl_server_callback_validate_get().
1029 * Deprecated: This function is part of the old callback interface.
1030 * The new interface uses gsasl_callback_set() to set the application
1031 * callback, and uses gsasl_callback() or gsasl_property_get() to
1032 * invoke the callback for certain properties.
1034 void
1035 gsasl_server_callback_validate_set (Gsasl * ctx,
1036 Gsasl_server_callback_validate cb)
1038 ctx->cbs_validate = cb;
1042 * gsasl_server_callback_validate_get:
1043 * @ctx: libgsasl handle.
1045 * Return value: Returns the callback earlier set by calling
1046 * gsasl_server_callback_validate_set().
1048 * Deprecated: This function is part of the old callback interface.
1049 * The new interface uses gsasl_callback_set() to set the application
1050 * callback, and uses gsasl_callback() or gsasl_property_get() to
1051 * invoke the callback for certain properties.
1053 Gsasl_server_callback_validate
1054 gsasl_server_callback_validate_get (Gsasl * ctx)
1056 return ctx ? ctx->cbs_validate : NULL;
1060 * gsasl_server_callback_retrieve_set:
1061 * @ctx: libgsasl handle.
1062 * @cb: callback function
1064 * Specify the callback function to use in the server for deciding if
1065 * user is authenticated using authentication identity, authorization
1066 * identity and password. The function can be later retrieved using
1067 * gsasl_server_callback_retrieve_get().
1069 * Deprecated: This function is part of the old callback interface.
1070 * The new interface uses gsasl_callback_set() to set the application
1071 * callback, and uses gsasl_callback() or gsasl_property_get() to
1072 * invoke the callback for certain properties.
1074 void
1075 gsasl_server_callback_retrieve_set (Gsasl * ctx,
1076 Gsasl_server_callback_retrieve cb)
1078 ctx->cbs_retrieve = cb;
1082 * gsasl_server_callback_retrieve_get:
1083 * @ctx: libgsasl handle.
1085 * Return value: Returns the callback earlier set by calling
1086 * gsasl_server_callback_retrieve_set().
1088 * Deprecated: This function is part of the old callback interface.
1089 * The new interface uses gsasl_callback_set() to set the application
1090 * callback, and uses gsasl_callback() or gsasl_property_get() to
1091 * invoke the callback for certain properties.
1093 Gsasl_server_callback_retrieve
1094 gsasl_server_callback_retrieve_get (Gsasl * ctx)
1096 return ctx ? ctx->cbs_retrieve : NULL;
1100 * gsasl_server_callback_cram_md5_set:
1101 * @ctx: libgsasl handle.
1102 * @cb: callback function
1104 * Specify the callback function to use in the server for deciding if
1105 * user is authenticated using CRAM-MD5 challenge and response. The
1106 * function can be later retrieved using
1107 * gsasl_server_callback_cram_md5_get().
1109 * Deprecated: This function is part of the old callback interface.
1110 * The new interface uses gsasl_callback_set() to set the application
1111 * callback, and uses gsasl_callback() or gsasl_property_get() to
1112 * invoke the callback for certain properties.
1114 void
1115 gsasl_server_callback_cram_md5_set (Gsasl * ctx,
1116 Gsasl_server_callback_cram_md5 cb)
1118 ctx->cbs_cram_md5 = cb;
1122 * gsasl_server_callback_cram_md5_get:
1123 * @ctx: libgsasl handle.
1125 * Return value: Returns the callback earlier set by calling
1126 * gsasl_server_callback_cram_md5_set().
1128 * Deprecated: This function is part of the old callback interface.
1129 * The new interface uses gsasl_callback_set() to set the application
1130 * callback, and uses gsasl_callback() or gsasl_property_get() to
1131 * invoke the callback for certain properties.
1133 Gsasl_server_callback_cram_md5
1134 gsasl_server_callback_cram_md5_get (Gsasl * ctx)
1136 return ctx ? ctx->cbs_cram_md5 : NULL;
1140 * gsasl_server_callback_digest_md5_set:
1141 * @ctx: libgsasl handle.
1142 * @cb: callback function
1144 * Specify the callback function to use in the server for retrieving
1145 * the secret hash of the username, realm and password for use in the
1146 * DIGEST-MD5 mechanism. The function can be later retrieved using
1147 * gsasl_server_callback_digest_md5_get().
1149 * Deprecated: This function is part of the old callback interface.
1150 * The new interface uses gsasl_callback_set() to set the application
1151 * callback, and uses gsasl_callback() or gsasl_property_get() to
1152 * invoke the callback for certain properties.
1154 void
1155 gsasl_server_callback_digest_md5_set (Gsasl * ctx,
1156 Gsasl_server_callback_digest_md5 cb)
1158 ctx->cbs_digest_md5 = cb;
1162 * gsasl_server_callback_digest_md5_get:
1163 * @ctx: libgsasl handle.
1165 * Return value: Return the callback earlier set by calling
1166 * gsasl_server_callback_digest_md5_set().
1168 * Deprecated: This function is part of the old callback interface.
1169 * The new interface uses gsasl_callback_set() to set the application
1170 * callback, and uses gsasl_callback() or gsasl_property_get() to
1171 * invoke the callback for certain properties.
1173 Gsasl_server_callback_digest_md5
1174 gsasl_server_callback_digest_md5_get (Gsasl * ctx)
1176 return ctx->cbs_digest_md5;
1180 * gsasl_server_callback_external_set:
1181 * @ctx: libgsasl handle.
1182 * @cb: callback function
1184 * Specify the callback function to use in the server for deciding if
1185 * user is authenticated out of band. The function can be later
1186 * retrieved using gsasl_server_callback_external_get().
1188 * Deprecated: This function is part of the old callback interface.
1189 * The new interface uses gsasl_callback_set() to set the application
1190 * callback, and uses gsasl_callback() or gsasl_property_get() to
1191 * invoke the callback for certain properties.
1193 void
1194 gsasl_server_callback_external_set (Gsasl * ctx,
1195 Gsasl_server_callback_external cb)
1197 ctx->cbs_external = cb;
1201 * gsasl_server_callback_external_get:
1202 * @ctx: libgsasl handle.
1204 * Return value: Returns the callback earlier set by calling
1205 * gsasl_server_callback_external_set().
1207 * Deprecated: This function is part of the old callback interface.
1208 * The new interface uses gsasl_callback_set() to set the application
1209 * callback, and uses gsasl_callback() or gsasl_property_get() to
1210 * invoke the callback for certain properties.
1212 Gsasl_server_callback_external
1213 gsasl_server_callback_external_get (Gsasl * ctx)
1215 return ctx ? ctx->cbs_external : NULL;
1219 * gsasl_server_callback_anonymous_set:
1220 * @ctx: libgsasl handle.
1221 * @cb: callback function
1223 * Specify the callback function to use in the server for deciding if
1224 * user is permitted anonymous access. The function can be later
1225 * retrieved using gsasl_server_callback_anonymous_get().
1227 * Deprecated: This function is part of the old callback interface.
1228 * The new interface uses gsasl_callback_set() to set the application
1229 * callback, and uses gsasl_callback() or gsasl_property_get() to
1230 * invoke the callback for certain properties.
1232 void
1233 gsasl_server_callback_anonymous_set (Gsasl * ctx,
1234 Gsasl_server_callback_anonymous cb)
1236 ctx->cbs_anonymous = cb;
1240 * gsasl_server_callback_anonymous_get:
1241 * @ctx: libgsasl handle.
1243 * Return value: Returns the callback earlier set by calling
1244 * gsasl_server_callback_anonymous_set().
1246 * Deprecated: This function is part of the old callback interface.
1247 * The new interface uses gsasl_callback_set() to set the application
1248 * callback, and uses gsasl_callback() or gsasl_property_get() to
1249 * invoke the callback for certain properties.
1251 Gsasl_server_callback_anonymous
1252 gsasl_server_callback_anonymous_get (Gsasl * ctx)
1254 return ctx ? ctx->cbs_anonymous : NULL;
1258 * gsasl_server_callback_realm_set:
1259 * @ctx: libgsasl handle.
1260 * @cb: callback function
1262 * Specify the callback function to use in the server to know which
1263 * realm it serves. The realm is used by the user to determine which
1264 * username and password to use. The function can be later retrieved
1265 * using gsasl_server_callback_realm_get().
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.
1272 void
1273 gsasl_server_callback_realm_set (Gsasl * ctx, Gsasl_server_callback_realm cb)
1275 ctx->cbs_realm = cb;
1279 * gsasl_server_callback_realm_get:
1280 * @ctx: libgsasl handle.
1282 * Return value: Returns the callback earlier set by calling
1283 * gsasl_server_callback_realm_set().
1285 * Deprecated: This function is part of the old callback interface.
1286 * The new interface uses gsasl_callback_set() to set the application
1287 * callback, and uses gsasl_callback() or gsasl_property_get() to
1288 * invoke the callback for certain properties.
1290 Gsasl_server_callback_realm
1291 gsasl_server_callback_realm_get (Gsasl * ctx)
1293 return ctx ? ctx->cbs_realm : NULL;
1297 * gsasl_server_callback_qop_set:
1298 * @ctx: libgsasl handle.
1299 * @cb: callback function
1301 * Specify the callback function to use in the server to know which
1302 * quality of protection it accepts. The quality of protection
1303 * eventually used is selected by the client though. It is currently
1304 * used by the DIGEST-MD5 mechanism. The function can be later
1305 * retrieved using gsasl_server_callback_qop_get().
1307 * Deprecated: This function is part of the old callback interface.
1308 * The new interface uses gsasl_callback_set() to set the application
1309 * callback, and uses gsasl_callback() or gsasl_property_get() to
1310 * invoke the callback for certain properties.
1312 void
1313 gsasl_server_callback_qop_set (Gsasl * ctx, Gsasl_server_callback_qop cb)
1315 ctx->cbs_qop = cb;
1319 * gsasl_server_callback_qop_get:
1320 * @ctx: libgsasl handle.
1322 * Return value: Returns the callback earlier set by calling
1323 * gsasl_server_callback_qop_set().
1325 * Deprecated: This function is part of the old callback interface.
1326 * The new interface uses gsasl_callback_set() to set the application
1327 * callback, and uses gsasl_callback() or gsasl_property_get() to
1328 * invoke the callback for certain properties.
1330 Gsasl_server_callback_qop
1331 gsasl_server_callback_qop_get (Gsasl * ctx)
1333 return ctx ? ctx->cbs_qop : NULL;
1337 * gsasl_server_callback_maxbuf_set:
1338 * @ctx: libgsasl handle.
1339 * @cb: callback function
1341 * Specify the callback function to use in the server to inform the
1342 * client of the largest buffer the server is able to receive when
1343 * using the DIGEST-MD5 "auth-int" or "auth-conf" Quality of
1344 * Protection (qop). If this directive is missing, the default value
1345 * 65536 will be assumed. The function can be later retrieved using
1346 * gsasl_server_callback_maxbuf_get().
1348 * Deprecated: This function is part of the old callback interface.
1349 * The new interface uses gsasl_callback_set() to set the application
1350 * callback, and uses gsasl_callback() or gsasl_property_get() to
1351 * invoke the callback for certain properties.
1353 void
1354 gsasl_server_callback_maxbuf_set (Gsasl * ctx,
1355 Gsasl_server_callback_maxbuf cb)
1357 ctx->cbs_maxbuf = cb;
1361 * gsasl_server_callback_maxbuf_get:
1362 * @ctx: libgsasl handle.
1364 * Return value: Returns the callback earlier set by calling
1365 * gsasl_server_callback_maxbuf_set().
1367 * Deprecated: This function is part of the old callback interface.
1368 * The new interface uses gsasl_callback_set() to set the application
1369 * callback, and uses gsasl_callback() or gsasl_property_get() to
1370 * invoke the callback for certain properties.
1372 Gsasl_server_callback_maxbuf
1373 gsasl_server_callback_maxbuf_get (Gsasl * ctx)
1375 return ctx ? ctx->cbs_maxbuf : NULL;
1379 * gsasl_server_callback_cipher_set:
1380 * @ctx: libgsasl handle.
1381 * @cb: callback function
1383 * Specify the callback function to use in the server to inform the
1384 * client of the cipher suites supported. The DES and 3DES ciphers
1385 * must be supported for interoperability. It is currently used by
1386 * the DIGEST-MD5 mechanism. The function can be later retrieved
1387 * using gsasl_server_callback_cipher_get().
1389 * Deprecated: This function is part of the old callback interface.
1390 * The new interface uses gsasl_callback_set() to set the application
1391 * callback, and uses gsasl_callback() or gsasl_property_get() to
1392 * invoke the callback for certain properties.
1394 void
1395 gsasl_server_callback_cipher_set (Gsasl * ctx,
1396 Gsasl_server_callback_cipher cb)
1398 ctx->cbs_cipher = cb;
1402 * gsasl_server_callback_cipher_get:
1403 * @ctx: libgsasl handle.
1405 * Return value: Returns the callback earlier set by calling
1406 * gsasl_server_callback_cipher_set().
1408 * Deprecated: This function is part of the old callback interface.
1409 * The new interface uses gsasl_callback_set() to set the application
1410 * callback, and uses gsasl_callback() or gsasl_property_get() to
1411 * invoke the callback for certain properties.
1413 Gsasl_server_callback_cipher
1414 gsasl_server_callback_cipher_get (Gsasl * ctx)
1416 return ctx ? ctx->cbs_cipher : NULL;
1420 * gsasl_server_callback_securid_set:
1421 * @ctx: libgsasl handle.
1422 * @cb: callback function
1424 * Specify the callback function to use in the server for validating a
1425 * user via the SECURID mechanism. The function should return
1426 * GSASL_OK if user authenticated successfully,
1427 * GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODE if it wants another
1428 * passcode, GSASL_SECURID_SERVER_NEED_NEW_PIN if it wants a PIN
1429 * change, or an error. When (and only when)
1430 * GSASL_SECURID_SERVER_NEED_NEW_PIN is returned, suggestpin can be
1431 * populated with a PIN code the server suggests, and suggestpinlen
1432 * set to the length of the PIN. The function can be later retrieved
1433 * using gsasl_server_callback_securid_get().
1435 * Deprecated: This function is part of the old callback interface.
1436 * The new interface uses gsasl_callback_set() to set the application
1437 * callback, and uses gsasl_callback() or gsasl_property_get() to
1438 * invoke the callback for certain properties.
1440 void
1441 gsasl_server_callback_securid_set (Gsasl * ctx,
1442 Gsasl_server_callback_securid cb)
1444 ctx->cbs_securid = cb;
1448 * gsasl_server_callback_securid_get:
1449 * @ctx: libgsasl handle.
1451 * Return value: Returns the callback earlier set by calling
1452 * gsasl_server_callback_securid_set().
1454 * Deprecated: This function is part of the old callback interface.
1455 * The new interface uses gsasl_callback_set() to set the application
1456 * callback, and uses gsasl_callback() or gsasl_property_get() to
1457 * invoke the callback for certain properties.
1459 Gsasl_server_callback_securid
1460 gsasl_server_callback_securid_get (Gsasl * ctx)
1462 return ctx ? ctx->cbs_securid : NULL;
1466 * gsasl_server_callback_gssapi_set:
1467 * @ctx: libgsasl handle.
1468 * @cb: callback function
1470 * Specify the callback function to use in the server for checking if
1471 * a GSSAPI user is authorized for username (by, e.g., calling
1472 * krb5_userok()). The function should return GSASL_OK if the user
1473 * should be permitted access, or an error code such as
1474 * GSASL_AUTHENTICATION_ERROR on failure. The function can be later
1475 * retrieved using gsasl_server_callback_gssapi_get().
1477 * Deprecated: This function is part of the old callback interface.
1478 * The new interface uses gsasl_callback_set() to set the application
1479 * callback, and uses gsasl_callback() or gsasl_property_get() to
1480 * invoke the callback for certain properties.
1482 void
1483 gsasl_server_callback_gssapi_set (Gsasl * ctx,
1484 Gsasl_server_callback_gssapi cb)
1486 ctx->cbs_gssapi = cb;
1490 * gsasl_server_callback_gssapi_get:
1491 * @ctx: libgsasl handle.
1493 * Return value: Returns the callback earlier set by calling
1494 * gsasl_server_callback_gssapi_set().
1496 * Deprecated: This function is part of the old callback interface.
1497 * The new interface uses gsasl_callback_set() to set the application
1498 * callback, and uses gsasl_callback() or gsasl_property_get() to
1499 * invoke the callback for certain properties.
1501 Gsasl_server_callback_gssapi
1502 gsasl_server_callback_gssapi_get (Gsasl * ctx)
1504 return ctx ? ctx->cbs_gssapi : NULL;
1508 * gsasl_server_callback_service_set:
1509 * @ctx: libgsasl handle.
1510 * @cb: callback function
1512 * Specify the callback function to use in the server to set the name
1513 * of the service. The service buffer should be a registered GSSAPI
1514 * host-based service name, hostname the name of the server. The
1515 * function can be later retrieved using
1516 * gsasl_server_callback_service_get().
1518 * Deprecated: This function is part of the old callback interface.
1519 * The new interface uses gsasl_callback_set() to set the application
1520 * callback, and uses gsasl_callback() or gsasl_property_get() to
1521 * invoke the callback for certain properties.
1523 void
1524 gsasl_server_callback_service_set (Gsasl * ctx,
1525 Gsasl_server_callback_service cb)
1527 ctx->cbs_service = cb;
1531 * gsasl_server_callback_service_get:
1532 * @ctx: libgsasl handle.
1534 * Return value: Returns the callback earlier set by calling
1535 * gsasl_server_callback_service_set().
1537 * Deprecated: This function is part of the old callback interface.
1538 * The new interface uses gsasl_callback_set() to set the application
1539 * callback, and uses gsasl_callback() or gsasl_property_get() to
1540 * invoke the callback for certain properties.
1542 Gsasl_server_callback_service
1543 gsasl_server_callback_service_get (Gsasl * ctx)
1545 return ctx ? ctx->cbs_service : NULL;
1548 #if WITH_SASLPREP
1549 # include <stringprep.h>
1550 #endif
1553 * gsasl_stringprep_nfkc:
1554 * @in: a UTF-8 encoded string.
1555 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
1557 * Converts a string into canonical form, standardizing such issues as
1558 * whether a character with an accent is represented as a base
1559 * character and combining accent or as a single precomposed
1560 * character.
1562 * The normalization mode is NFKC (ALL COMPOSE). It standardizes
1563 * differences that do not affect the text content, such as the
1564 * above-mentioned accent representation. It standardizes the
1565 * "compatibility" characters in Unicode, such as SUPERSCRIPT THREE to
1566 * the standard forms (in this case DIGIT THREE). Formatting
1567 * information may be lost but for most text operations such
1568 * characters should be considered the same. It returns a result with
1569 * composed forms rather than a maximally decomposed form.
1571 * Return value: Return a newly allocated string, that is the NFKC
1572 * normalized form of @str, o %NULL on error.
1574 * Deprecated: No replacement functionality in GNU SASL, use GNU
1575 * Libidn instead. Note that in SASL, you most likely want to use
1576 * SASLprep and not bare NFKC, see gsasl_saslprep().
1578 char *
1579 gsasl_stringprep_nfkc (const char *in, ssize_t len)
1581 char *out = NULL;
1583 #if WITH_SASLPREP
1584 out = stringprep_utf8_nfkc_normalize (in, len);
1585 #endif
1587 return out;
1591 * gsasl_stringprep_saslprep:
1592 * @in: input ASCII or UTF-8 string with data to prepare according to SASLprep.
1593 * @stringprep_rc: pointer to output variable with stringprep error code,
1594 * or %NULL to indicate that you don't care about it.
1596 * Process a Unicode string for comparison, according to the
1597 * "SASLprep" stringprep profile. This function is intended to be
1598 * used by Simple Authentication and Security Layer (SASL) mechanisms
1599 * (such as PLAIN, CRAM-MD5, and DIGEST-MD5) as well as other
1600 * protocols exchanging user names and/or passwords.
1602 * Return value: Return a newly allocated string that is the
1603 * "SASLprep" processed form of the input string, or %NULL on error,
1604 * in which case @stringprep_rc contain the stringprep library error
1605 * code.
1607 * Deprecated: Use gsasl_saslprep() instead.
1609 char *
1610 gsasl_stringprep_saslprep (const char *in, int *stringprep_rc)
1612 char *out = NULL;
1613 #if WITH_SASLPREP
1614 int rc;
1616 rc = stringprep_profile (in, &out, "SASLprep", 0);
1617 if (stringprep_rc)
1618 *stringprep_rc = rc;
1619 if (rc != STRINGPREP_OK)
1620 out = NULL;
1621 #endif
1623 return out;
1627 * gsasl_stringprep_trace:
1628 * @in: input ASCII or UTF-8 string with data to prepare according to "trace".
1629 * @stringprep_rc: pointer to output variable with stringprep error code,
1630 * or %NULL to indicate that you don't care about it.
1632 * Process a Unicode string for use as trace information, according to
1633 * the "trace" stringprep profile. The profile is designed for use
1634 * with the SASL ANONYMOUS Mechanism.
1636 * Return value: Return a newly allocated string that is the "trace"
1637 * processed form of the input string, or %NULL on error, in which
1638 * case @stringprep_rc contain the stringprep library error code.
1640 * Deprecated: No replacement functionality in GNU SASL, use GNU
1641 * Libidn instead.
1643 char *
1644 gsasl_stringprep_trace (const char *in, int *stringprep_rc)
1646 char *out = NULL;
1647 #if WITH_SASLPREP
1648 int rc;
1650 rc = stringprep_profile (in, &out, "trace", 0);
1651 if (stringprep_rc)
1652 *stringprep_rc = rc;
1653 if (rc != STRINGPREP_OK)
1654 out = NULL;
1655 #endif
1657 return out;
1661 * gsasl_md5pwd_get_password:
1662 * @filename: filename of file containing passwords.
1663 * @username: username string.
1664 * @key: output character array.
1665 * @keylen: input maximum size of output character array, on output
1666 * contains actual length of output array.
1668 * Retrieve password for user from specified file. To find out how
1669 * large the output array must be, call this function with out=NULL.
1671 * The file should be on the UoW "MD5 Based Authentication" format,
1672 * which means it is in text format with comments denoted by # first
1673 * on the line, with user entries looking as "usernameTABpassword".
1674 * This function removes CR and LF at the end of lines before
1675 * processing. TAB, CR, and LF denote ASCII values 9, 13, and 10,
1676 * respectively.
1678 * Return value: Return GSASL_OK if output buffer contains the
1679 * password, GSASL_AUTHENTICATION_ERROR if the user could not be
1680 * found, or other error code.
1682 * Deprecated: Use gsasl_simple_getpass() instead.
1685 gsasl_md5pwd_get_password (const char *filename,
1686 const char *username, char *key, size_t * keylen)
1688 char matchbuf[BUFSIZ];
1689 char line[BUFSIZ];
1690 FILE *fh;
1692 fh = fopen (filename, "r");
1693 if (fh == NULL)
1694 return GSASL_FOPEN_ERROR;
1696 sprintf (matchbuf, "%s\t", username);
1698 while (!feof (fh))
1700 if (fgets (line, BUFSIZ, fh) == NULL)
1701 break;
1703 if (line[0] == '#')
1704 continue;
1706 while (strlen (line) > 0 && (line[strlen (line) - 1] == '\n' ||
1707 line[strlen (line) - 1] == '\r'))
1708 line[strlen (line) - 1] = '\0';
1710 if (strlen (line) <= strlen (matchbuf))
1711 continue;
1713 if (strncmp (matchbuf, line, strlen (matchbuf)) == 0)
1715 if (*keylen < strlen (line) - strlen (matchbuf))
1717 fclose (fh);
1718 return GSASL_TOO_SMALL_BUFFER;
1721 *keylen = strlen (line) - strlen (matchbuf);
1723 if (key)
1724 memcpy (key, &line[strlen (matchbuf)], *keylen);
1726 fclose (fh);
1728 return GSASL_OK;
1732 if (fclose (fh) != 0)
1733 return GSASL_FCLOSE_ERROR;
1735 return GSASL_AUTHENTICATION_ERROR;
1740 * Copyright (c) 1996-1999 by Internet Software Consortium.
1742 * Permission to use, copy, modify, and distribute this software for any
1743 * purpose with or without fee is hereby granted, provided that the above
1744 * copyright notice and this permission notice appear in all copies.
1746 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
1747 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
1748 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
1749 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
1750 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
1751 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
1752 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
1753 * SOFTWARE.
1757 * Portions Copyright (c) 1995 by International Business Machines, Inc.
1759 * International Business Machines, Inc. (hereinafter called IBM) grants
1760 * permission under its copyrights to use, copy, modify, and distribute this
1761 * Software with or without fee, provided that the above copyright notice and
1762 * all paragraphs of this notice appear in all copies, and that the name of IBM
1763 * not be used in connection with the marketing of any product incorporating
1764 * the Software or modifications thereof, without specific, written prior
1765 * permission.
1767 * To the extent it has a right to do so, IBM grants an immunity from suit
1768 * under its patents, if any, for the use, sale or manufacture of products to
1769 * the extent that such products are used for performing Domain Name System
1770 * dynamic updates in TCP/IP networks by means of the Software. No immunity is
1771 * granted for any product per se or for any other function of any product.
1773 * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
1774 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
1775 * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
1776 * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
1777 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
1778 * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
1781 #include <ctype.h>
1782 #include <stdio.h>
1784 #define Assert(Cond) if (!(Cond)) abort()
1786 static const char Base64[] =
1787 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1788 static const char Pad64 = '=';
1791 * gsasl_base64_encode:
1792 * @src: input byte array
1793 * @srclength: size of input byte array
1794 * @target: output byte array
1795 * @targsize: size of output byte array
1797 * Encode data as base64. Converts characters, three at a time,
1798 * starting at src into four base64 characters in the target area
1799 * until the entire input buffer is encoded.
1801 * Return value: Returns the number of data bytes stored at the
1802 * target, or -1 on error.
1804 * Deprecated: Use gsasl_base64_to() instead.
1807 gsasl_base64_encode (char const *src,
1808 size_t srclength, char *target, size_t targsize)
1810 size_t datalength = 0;
1811 unsigned char input[3];
1812 unsigned char output[4];
1813 size_t i;
1815 while (2 < srclength)
1817 input[0] = *src++;
1818 input[1] = *src++;
1819 input[2] = *src++;
1820 srclength -= 3;
1822 output[0] = input[0] >> 2;
1823 output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
1824 output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
1825 output[3] = input[2] & 0x3f;
1826 Assert (output[0] < 64);
1827 Assert (output[1] < 64);
1828 Assert (output[2] < 64);
1829 Assert (output[3] < 64);
1831 if (datalength + 4 > targsize)
1832 return (-1);
1833 target[datalength++] = Base64[output[0]];
1834 target[datalength++] = Base64[output[1]];
1835 target[datalength++] = Base64[output[2]];
1836 target[datalength++] = Base64[output[3]];
1839 /* Now we worry about padding. */
1840 if (0 != srclength)
1842 /* Get what's left. */
1843 input[0] = input[1] = input[2] = '\0';
1844 for (i = 0; i < srclength; i++)
1845 input[i] = *src++;
1847 output[0] = input[0] >> 2;
1848 output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
1849 output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
1850 Assert (output[0] < 64);
1851 Assert (output[1] < 64);
1852 Assert (output[2] < 64);
1854 if (datalength + 4 > targsize)
1855 return (-1);
1856 target[datalength++] = Base64[output[0]];
1857 target[datalength++] = Base64[output[1]];
1858 if (srclength == 1)
1859 target[datalength++] = Pad64;
1860 else
1861 target[datalength++] = Base64[output[2]];
1862 target[datalength++] = Pad64;
1864 if (datalength >= targsize)
1865 return (-1);
1866 target[datalength] = '\0'; /* Returned value doesn't count \0. */
1867 return (datalength);
1871 * gsasl_base64_decode:
1872 * @src: input byte array
1873 * @target: output byte array
1874 * @targsize: size of output byte array
1876 * Decode Base64 data. Skips all whitespace anywhere. Converts
1877 * characters, four at a time, starting at (or after) src from Base64
1878 * numbers into three 8 bit bytes in the target area.
1880 * Return value: Returns the number of data bytes stored at the
1881 * target, or -1 on error.
1883 * Deprecated: Use gsasl_base64_from() instead.
1886 gsasl_base64_decode (char const *src, char *target, size_t targsize)
1888 int tarindex, state, ch;
1889 char *pos;
1891 state = 0;
1892 tarindex = 0;
1894 while ((ch = *src++) != '\0')
1896 if (isspace (ch)) /* Skip whitespace anywhere. */
1897 continue;
1899 if (ch == Pad64)
1900 break;
1902 pos = strchr (Base64, ch);
1903 if (pos == 0) /* A non-base64 character. */
1904 return (-1);
1906 switch (state)
1908 case 0:
1909 if (target)
1911 if ((size_t) tarindex >= targsize)
1912 return (-1);
1913 target[tarindex] = (pos - Base64) << 2;
1915 state = 1;
1916 break;
1917 case 1:
1918 if (target)
1920 if ((size_t) tarindex + 1 >= targsize)
1921 return (-1);
1922 target[tarindex] |= (pos - Base64) >> 4;
1923 target[tarindex + 1] = ((pos - Base64) & 0x0f) << 4;
1925 tarindex++;
1926 state = 2;
1927 break;
1928 case 2:
1929 if (target)
1931 if ((size_t) tarindex + 1 >= targsize)
1932 return (-1);
1933 target[tarindex] |= (pos - Base64) >> 2;
1934 target[tarindex + 1] = ((pos - Base64) & 0x03) << 6;
1936 tarindex++;
1937 state = 3;
1938 break;
1939 case 3:
1940 if (target)
1942 if ((size_t) tarindex >= targsize)
1943 return (-1);
1944 target[tarindex] |= (pos - Base64);
1946 tarindex++;
1947 state = 0;
1948 break;
1949 default:
1950 abort ();
1955 * We are done decoding Base-64 chars. Let's see if we ended
1956 * on a byte boundary, and/or with erroneous trailing characters.
1959 if (ch == Pad64)
1960 { /* We got a pad char. */
1961 ch = *src++; /* Skip it, get next. */
1962 switch (state)
1964 case 0: /* Invalid = in first position */
1965 case 1: /* Invalid = in second position */
1966 return (-1);
1968 case 2: /* Valid, means one byte of info */
1969 /* Skip any number of spaces. */
1970 for ((void) NULL; ch != '\0'; ch = *src++)
1971 if (!isspace (ch))
1972 break;
1973 /* Make sure there is another trailing = sign. */
1974 if (ch != Pad64)
1975 return (-1);
1976 ch = *src++; /* Skip the = */
1977 /* Fall through to "single trailing =" case. */
1978 /* FALLTHROUGH */
1980 case 3: /* Valid, means two bytes of info */
1982 * We know this char is an =. Is there anything but
1983 * whitespace after it?
1985 for ((void) NULL; ch != '\0'; ch = *src++)
1986 if (!isspace (ch))
1987 return (-1);
1990 * Now make sure for cases 2 and 3 that the "extra"
1991 * bits that slopped past the last full byte were
1992 * zeros. If we don't check them, they become a
1993 * subliminal channel.
1995 if (target && target[tarindex] != 0)
1996 return (-1);
1999 else
2002 * We ended by seeing the end of the string. Make sure we
2003 * have no partial bytes lying around.
2005 if (state != 0)
2006 return (-1);
2009 return (tarindex);