From 9e6b0c28712ee77ce878809c8576826a3ba08d95 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 19 Mar 2008 10:17:42 +1100 Subject: Merge lorikeet-heimdal -r 787 into Samba4 tree. Andrew Bartlett (This used to be commit d88b530522d3cef67c24422bd5182fb875d87ee2) --- source4/heimdal/lib/wind/stringprep.c | 141 ++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 source4/heimdal/lib/wind/stringprep.c (limited to 'source4/heimdal/lib/wind/stringprep.c') diff --git a/source4/heimdal/lib/wind/stringprep.c b/source4/heimdal/lib/wind/stringprep.c new file mode 100644 index 0000000000..0beba76384 --- /dev/null +++ b/source4/heimdal/lib/wind/stringprep.c @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2004, 2006, 2008 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "windlocl.h" +#include +#include +#include + +RCSID("$Id: stringprep.c 22593 2008-02-12 11:58:01Z lha $"); + +/** + * Process a input UCS4 string according a string-prep profile. + * + * @param in input UCS4 string to process + * @param in_len length of the input string + * @param out output UCS4 string + * @param out_len length of the output string. + * @param flags stringprep profile. + * + * @return returns 0 on success, an wind error code otherwise + * @ingroup wind + */ + +int +wind_stringprep(const uint32_t *in, size_t in_len, + uint32_t *out, size_t *out_len, + wind_profile_flags flags) +{ + size_t tmp_len = in_len * 3; + uint32_t *tmp = malloc(tmp_len * sizeof(uint32_t)); + int ret; + size_t olen; + + if (tmp == NULL) + return ENOMEM; + + ret = _wind_stringprep_map(in, in_len, tmp, &tmp_len, flags); + if (ret) { + free(tmp); + return ret; + } + + olen = *out_len; + ret = _wind_stringprep_normalize(tmp, tmp_len, tmp, &olen); + if (ret) { + free(tmp); + return ret; + } + ret = _wind_stringprep_prohibited(tmp, olen, flags); + if (ret) { + free(tmp); + return ret; + } + ret = _wind_stringprep_testbidi(tmp, olen, flags); + if (ret) { + free(tmp); + return ret; + } + + /* Insignificant Character Handling for ldap-prep */ + if (flags & WIND_PROFILE_LDAP_CASE_EXACT_ATTRIBUTE) { + ret = _wind_ldap_case_exact_attribute(tmp, olen, out, out_len); +#if 0 + } else if (flags & WIND_PROFILE_LDAP_CASE_EXACT_ASSERTION) { + } else if (flags & WIND_PROFILE_LDAP_NUMERIC) { + } else if (flags & WIND_PROFILE_LDAP_TELEPHONE) { +#endif + } else { + memcpy(out, tmp, sizeof(out[0]) * olen); + *out_len = olen; + } + free(tmp); + + return ret; +} + +static struct { + const char *name; + wind_profile_flags flags; +} profiles[] = { + { "nameprep", WIND_PROFILE_NAME }, + { "saslprep", WIND_PROFILE_SASL }, + { "ldapprep", WIND_PROFILE_LDAP } +}; + +/** + * Try to find the profile given a name. + * + * @param name name of the profile. + * @param flags the resulting profile. + * + * @return returns 0 on success, an wind error code otherwise + * @ingroup wind + */ + +int +wind_profile(const char *name, wind_profile_flags *flags) +{ + unsigned int i; + + for (i = 0; i < sizeof(profiles)/sizeof(profiles[0]); i++) { + if (strcasecmp(profiles[i].name, name) == 0) { + *flags = profiles[i].flags; + return 0; + } + } + return WIND_ERR_NO_PROFILE; +} -- cgit From a925f039ee382df0f3be434108416bab0d17e8c0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Aug 2008 07:08:51 +0200 Subject: heimdal: update to lorikeet-heimdal rev 801 metze (This used to be commit d6c54a66fb23c784ef221a3c1cf766b72bdb5a0b) --- source4/heimdal/lib/wind/stringprep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/heimdal/lib/wind/stringprep.c') diff --git a/source4/heimdal/lib/wind/stringprep.c b/source4/heimdal/lib/wind/stringprep.c index 0beba76384..7c28fdae1f 100644 --- a/source4/heimdal/lib/wind/stringprep.c +++ b/source4/heimdal/lib/wind/stringprep.c @@ -36,10 +36,10 @@ #endif #include "windlocl.h" #include -#include +#include #include -RCSID("$Id: stringprep.c 22593 2008-02-12 11:58:01Z lha $"); +RCSID("$Id: stringprep.c 23063 2008-04-21 11:18:04Z lha $"); /** * Process a input UCS4 string according a string-prep profile. -- cgit From 243321b4bbe273cf3a9105ca132caa2b53e2f263 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 26 Aug 2008 19:35:52 +0200 Subject: heimdal: import heimdal's trunk svn rev 23697 + lorikeet-heimdal patches This is based on f56a3b1846c7d462542f2e9527f4d0ed8a34748d in my heimdal-wip repo. metze (This used to be commit 467a1f2163a63cdf1a4c83a69473db50e8794f53) --- source4/heimdal/lib/wind/stringprep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/heimdal/lib/wind/stringprep.c') diff --git a/source4/heimdal/lib/wind/stringprep.c b/source4/heimdal/lib/wind/stringprep.c index 7c28fdae1f..7be5b2c510 100644 --- a/source4/heimdal/lib/wind/stringprep.c +++ b/source4/heimdal/lib/wind/stringprep.c @@ -39,7 +39,7 @@ #include #include -RCSID("$Id: stringprep.c 23063 2008-04-21 11:18:04Z lha $"); +RCSID("$Id$"); /** * Process a input UCS4 string according a string-prep profile. -- cgit