1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) The Exim Maintainers 2022 */
6 /* Copyright (c) University of Cambridge 1995 - 2018 */
7 /* See the file NOTICE for conditions of use and distribution. */
8 /* SPDX-License-Identifier: GPL-2.0-or-later */
13 /*************************************************
14 * Encode byte-string in xtext *
15 *************************************************/
17 /* This function encodes a string of bytes, containing any values whatsoever,
18 as "xtext", as defined in RFC 1891 and required by the SMTP AUTH extension (RFC
22 clear points to the clear text bytes
23 len the number of bytes to encode
25 Returns: a pointer to the zero-terminated xtext string, which
30 auth_xtextencode(uschar *clear, int len)
33 for(uschar ch; len > 0; len--, clear++)
34 g = (ch = *clear) < 33 || ch > 126 || ch == '+' || ch == '='
35 ? string_fmt_append(g, "+%.02X", ch)
36 : string_catn(g, clear, 1);
37 gstring_release_unused(g);
38 return string_from_gstring(g);
42 /* End of xtextencode.c */