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.
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.
41 gsasl_client_listmech (Gsasl
* ctx
, char *out
, size_t * outlen
)
46 rc
= gsasl_client_mechlist (ctx
, &tmp
);
50 size_t tmplen
= strlen (tmp
);
52 if (tmplen
>= *outlen
)
55 return GSASL_TOO_SMALL_BUFFER
;
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.
83 gsasl_server_listmech (Gsasl
* ctx
, char *out
, size_t * outlen
)
88 rc
= gsasl_server_mechlist (ctx
, &tmp
);
92 size_t tmplen
= strlen (tmp
);
94 if (tmplen
>= *outlen
)
97 return GSASL_TOO_SMALL_BUFFER
;
102 *outlen
= tmplen
+ 1;
110 _gsasl_step (Gsasl_session
* sctx
,
111 const char *input
, size_t input_len
,
112 char *output
, size_t * output_len
)
118 rc
= gsasl_step (sctx
, input
, input_len
, &tmp
, &tmplen
);
120 if (rc
== GSASL_OK
|| rc
== GSASL_NEEDS_MORE
)
122 if (tmplen
>= *output_len
)
125 /* XXX We lose the step token here, don't we? */
126 return GSASL_TOO_SMALL_BUFFER
;
130 memcpy (output
, tmp
, tmplen
);
131 *output_len
= tmplen
;
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
158 * Deprecated: Use gsasl_step() instead.
161 gsasl_client_step (Gsasl_session
* sctx
,
163 size_t input_len
, char *output
, size_t * output_len
)
165 return _gsasl_step (sctx
, input
, input_len
, output
, output_len
);
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
188 * Deprecated: Use gsasl_step() instead.
191 gsasl_server_step (Gsasl_session
* sctx
,
193 size_t input_len
, char *output
, size_t * output_len
)
195 return _gsasl_step (sctx
, input
, input_len
, output
, output_len
);
199 _gsasl_step64 (Gsasl_session
* sctx
,
200 const char *b64input
, char *b64output
, size_t b64output_len
)
205 rc
= gsasl_step64 (sctx
, b64input
, &tmp
);
207 if (rc
== GSASL_OK
|| rc
== GSASL_NEEDS_MORE
)
209 if (b64output_len
<= strlen (tmp
))
212 /* XXX We lose the step token here, don't we? */
213 return GSASL_TOO_SMALL_BUFFER
;
217 strcpy (b64output
, tmp
);
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.
278 gsasl_client_finish (Gsasl_session
* 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.
293 gsasl_server_finish (Gsasl_session
* 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.
307 gsasl_client_ctx_get (Gsasl_session
* sctx
)
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.
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.
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.
362 gsasl_server_ctx_get (Gsasl_session
* sctx
)
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.
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.
403 gsasl_server_application_data_get (Gsasl_session
* sctx
)
405 return gsasl_appinfo_get (sctx
);
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
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
)
425 return gsasl_random (data
, datalen
);
426 return gsasl_nonce (data
, datalen
);
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.
438 gsasl_ctx_get (Gsasl_session
* sctx
)
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
457 * Deprecated: Use gsasl_encode() instead.
462 gsasl_encode_inline (Gsasl_session
* sctx
,
463 const char *input
, size_t input_len
,
464 char *output
, size_t * output_len
)
470 res
= gsasl_encode (sctx
, input
, input_len
, &tmp
, &tmplen
);
473 if (*output_len
< tmplen
)
474 return GSASL_TOO_SMALL_BUFFER
;
475 *output_len
= tmplen
;
476 memcpy (output
, tmp
, tmplen
);
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
497 * Deprecated: Use gsasl_decode() instead.
502 gsasl_decode_inline (Gsasl_session
* sctx
,
503 const char *input
, size_t input_len
,
504 char *output
, size_t * output_len
)
510 res
= gsasl_decode (sctx
, input
, input_len
, &tmp
, &tmplen
);
513 if (*output_len
< tmplen
)
514 return GSASL_TOO_SMALL_BUFFER
;
515 *output_len
= tmplen
;
516 memcpy (output
, tmp
, tmplen
);
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
534 * Deprecated: Use gsasl_callback_hook_set() instead.
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.
556 gsasl_application_data_get (Gsasl
* ctx
)
558 return ctx
->application_hook
;
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
572 * Deprecated: Use gsasl_callback_hook_set() instead.
575 gsasl_appinfo_set (Gsasl_session
* sctx
, void *appdata
)
577 sctx
->application_data
= appdata
;
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.
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.
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.
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.
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.
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.
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.
794 gsasl_client_callback_pin_set (Gsasl
* ctx
, Gsasl_client_callback_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.
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.
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.
915 gsasl_client_callback_qop_set (Gsasl
* ctx
, Gsasl_client_callback_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.
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.
996 gsasl_client_callback_realm_set (Gsasl
* ctx
, Gsasl_client_callback_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.
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.
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.
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.
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.
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.
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.
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.
1313 gsasl_server_callback_qop_set (Gsasl
* ctx
, Gsasl_server_callback_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.
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.
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.
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.
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.
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
;
1549 # include <stringprep.h>
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
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().
1579 gsasl_stringprep_nfkc (const char *in
, ssize_t len
)
1584 out
= stringprep_utf8_nfkc_normalize (in
, len
);
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
1607 * Deprecated: Use gsasl_saslprep() instead.
1610 gsasl_stringprep_saslprep (const char *in
, int *stringprep_rc
)
1616 rc
= stringprep_profile (in
, &out
, "SASLprep", 0);
1618 *stringprep_rc
= rc
;
1619 if (rc
!= STRINGPREP_OK
)
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
1644 gsasl_stringprep_trace (const char *in
, int *stringprep_rc
)
1650 rc
= stringprep_profile (in
, &out
, "trace", 0);
1652 *stringprep_rc
= rc
;
1653 if (rc
!= STRINGPREP_OK
)
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,
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
];
1692 fh
= fopen (filename
, "r");
1694 return GSASL_FOPEN_ERROR
;
1696 sprintf (matchbuf
, "%s\t", username
);
1700 if (fgets (line
, BUFSIZ
, fh
) == NULL
)
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
))
1713 if (strncmp (matchbuf
, line
, strlen (matchbuf
)) == 0)
1715 if (*keylen
< strlen (line
) - strlen (matchbuf
))
1718 return GSASL_TOO_SMALL_BUFFER
;
1721 *keylen
= strlen (line
) - strlen (matchbuf
);
1724 memcpy (key
, &line
[strlen (matchbuf
)], *keylen
);
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
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
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.
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];
1815 while (2 < srclength
)
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
)
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. */
1842 /* Get what's left. */
1843 input
[0] = input
[1] = input
[2] = '\0';
1844 for (i
= 0; i
< srclength
; i
++)
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
)
1856 target
[datalength
++] = Base64
[output
[0]];
1857 target
[datalength
++] = Base64
[output
[1]];
1859 target
[datalength
++] = Pad64
;
1861 target
[datalength
++] = Base64
[output
[2]];
1862 target
[datalength
++] = Pad64
;
1864 if (datalength
>= targsize
)
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
;
1894 while ((ch
= *src
++) != '\0')
1896 if (isspace (ch
)) /* Skip whitespace anywhere. */
1902 pos
= strchr (Base64
, ch
);
1903 if (pos
== 0) /* A non-base64 character. */
1911 if ((size_t) tarindex
>= targsize
)
1913 target
[tarindex
] = (pos
- Base64
) << 2;
1920 if ((size_t) tarindex
+ 1 >= targsize
)
1922 target
[tarindex
] |= (pos
- Base64
) >> 4;
1923 target
[tarindex
+ 1] = ((pos
- Base64
) & 0x0f) << 4;
1931 if ((size_t) tarindex
+ 1 >= targsize
)
1933 target
[tarindex
] |= (pos
- Base64
) >> 2;
1934 target
[tarindex
+ 1] = ((pos
- Base64
) & 0x03) << 6;
1942 if ((size_t) tarindex
>= targsize
)
1944 target
[tarindex
] |= (pos
- Base64
);
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.
1960 { /* We got a pad char. */
1961 ch
= *src
++; /* Skip it, get next. */
1964 case 0: /* Invalid = in first position */
1965 case 1: /* Invalid = in second position */
1968 case 2: /* Valid, means one byte of info */
1969 /* Skip any number of spaces. */
1970 for ((void) NULL
; ch
!= '\0'; ch
= *src
++)
1973 /* Make sure there is another trailing = sign. */
1976 ch
= *src
++; /* Skip the = */
1977 /* Fall through to "single trailing =" case. */
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
++)
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)
2002 * We ended by seeing the end of the string. Make sure we
2003 * have no partial bytes lying around.