Path: blob/main/crypto/heimdal/lib/wind/rfc4518.txt
34907 views
123456Network Working Group K. Zeilenga7Request for Comments: 4518 OpenLDAP Foundation8Category: Standards Track June 200691011Lightweight Directory Access Protocol (LDAP):12Internationalized String Preparation1314Status of This Memo1516This document specifies an Internet standards track protocol for the17Internet community, and requests discussion and suggestions for18improvements. Please refer to the current edition of the "Internet19Official Protocol Standards" (STD 1) for the standardization state20and status of this protocol. Distribution of this memo is unlimited.2122Copyright Notice2324Copyright (C) The Internet Society (2006).2526Abstract2728The previous Lightweight Directory Access Protocol (LDAP) technical29specifications did not precisely define how character string matching30is to be performed. This led to a number of usability and31interoperability problems. This document defines string preparation32algorithms for character-based matching rules defined for use in33LDAP.34351. Introduction36371.1. Background3839A Lightweight Directory Access Protocol (LDAP) [RFC4510] matching40rule [RFC4517] defines an algorithm for determining whether a41presented value matches an attribute value in accordance with the42criteria defined for the rule. The proposition may be evaluated to43True, False, or Undefined.4445True - the attribute contains a matching value,4647False - the attribute contains no matching value,4849Undefined - it cannot be determined whether the attribute contains50a matching value.51525354555657Zeilenga Standards Track [Page 1]5859RFC 4518 LDAP: Internationalized String Preparation June 2006606162For instance, the caseIgnoreMatch matching rule may be used to63compare whether the commonName attribute contains a particular value64without regard for case and insignificant spaces.65661.2. X.500 String Matching Rules6768"X.520: Selected attribute types" [X.520] provides (among other69things) value syntaxes and matching rules for comparing values70commonly used in the directory [X.500]. These specifications are71inadequate for strings composed of Unicode [Unicode] characters.7273The caseIgnoreMatch matching rule [X.520], for example, is simply74defined as being a case-insensitive comparison where insignificant75spaces are ignored. For printableString, there is only one space76character and case mapping is bijective, hence this definition is77sufficient. However, for Unicode string types such as78universalString, this is not sufficient. For example, a case-79insensitive matching implementation that folded lowercase characters80to uppercase would yield different results than an implementation81that used uppercase to lowercase folding. Or one implementation may82view space as referring to only SPACE (U+0020), a second83implementation may view any character with the space separator (Zs)84property as a space, and another implementation may view any85character with the whitespace (WS) category as a space.8687The lack of precise specification for character string matching has88led to significant interoperability problems. When used in89certificate chain validation, security vulnerabilities can arise. To90address these problems, this document defines precise algorithms for91preparing character strings for matching.92931.3. Relationship to "stringprep"9495The character string preparation algorithms described in this96document are based upon the "stringprep" approach [RFC3454]. In97"stringprep", presented and stored values are first prepared for98comparison so that a character-by-character comparison yields the99"correct" result.100101The approach used here is a refinement of the "stringprep" [RFC3454]102approach. Each algorithm involves two additional preparation steps.103104a) Prior to applying the Unicode string preparation steps outlined in105"stringprep", the string is transcoded to Unicode.106107b) After applying the Unicode string preparation steps outlined in108"stringprep", the string is modified to appropriately handle109characters insignificant to the matching rule.110111112113Zeilenga Standards Track [Page 2]114115RFC 4518 LDAP: Internationalized String Preparation June 2006116117118Hence, preparation of character strings for X.500 [X.500] matching119[X.501] involves the following steps:1201211) Transcode1222) Map1233) Normalize1244) Prohibit1255) Check Bidi (Bidirectional)1266) Insignificant Character Handling127128These steps are described in Section 2.129130It is noted that while various tables of Unicode characters included131or referenced by this specification are derived from Unicode132[Unicode] data, these tables are to be considered definitive for the133purpose of implementing this specification.1341351.4. Relationship to the LDAP Technical Specification136137This document is an integral part of the LDAP technical specification138[RFC4510], which obsoletes the previously defined LDAP technical139specification [RFC3377] in its entirety.140141This document details new LDAP internationalized character string142preparation algorithms used by [RFC4517] and possible other technical143specifications defining LDAP syntaxes and/or matching rules.1441451.5. Relationship to X.500146147LDAP is defined [RFC4510] in X.500 terms as an X.500 access148mechanism. As such, there is a strong desire for alignment between149LDAP and X.500 syntax and semantics. The character string150preparation algorithms described in this document are based upon151"Internationalized String Matching Rules for X.500" [XMATCH] proposal152to ITU/ISO Joint Study Group 2.1531541.6. Conventions and Terms155156The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",157"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this158document are to be interpreted as described in BCP 14 [RFC2119].159160Character names in this document use the notation for code points and161names from the Unicode Standard [Unicode]. For example, the letter162"a" may be represented as either <U+0061> or <LATIN SMALL LETTER A>.163In the lists of mappings and the prohibited characters, the "U+" is164165166167168169Zeilenga Standards Track [Page 3]170171RFC 4518 LDAP: Internationalized String Preparation June 2006172173174left off to make the lists easier to read. The comments for175character ranges are shown in square brackets (such as "[CONTROL176CHARACTERS]") and do not come from the standard.177178Note: a glossary of terms used in Unicode can be found in [Glossary].179Information on the Unicode character encoding model can be found in180[CharModel].181182The term "combining mark", as used in this specification, refers to183any Unicode [Unicode] code point that has a mark property (Mn, Mc,184Me). Appendix A provides a definitive list of combining marks.1851862. String Preparation187188The following six-step process SHALL be applied to each presented and189attribute value in preparation for character string matching rule190evaluation.1911921) Transcode1932) Map1943) Normalize1954) Prohibit1965) Check bidi1976) Insignificant Character Handling198199Failure in any step causes the assertion to evaluate to Undefined.200201The character repertoire of this process is Unicode 3.2 [Unicode].202203Note that this six-step process specification is intended to describe204expected matching behavior. Implementations are free to use205alternative processes so long as the matching rule evaluation206behavior provided is consistent with the behavior described by this207specification.2082092.1. Transcode210211Each non-Unicode string value is transcoded to Unicode.212213PrintableString [X.680] values are transcoded directly to Unicode.214215UniversalString, UTF8String, and bmpString [X.680] values need not be216transcoded as they are Unicode-based strings (in the case of217bmpString, a subset of Unicode).218219TeletexString [X.680] values are transcoded to Unicode. As there is220no standard for mapping TeletexString values to Unicode, the mapping221is left a local matter.222223224225Zeilenga Standards Track [Page 4]226227RFC 4518 LDAP: Internationalized String Preparation June 2006228229230For these and other reasons, use of TeletexString is NOT RECOMMENDED.231232The output is the transcoded string.2332342.2. Map235236SOFT HYPHEN (U+00AD) and MONGOLIAN TODO SOFT HYPHEN (U+1806) code237points are mapped to nothing. COMBINING GRAPHEME JOINER (U+034F) and238VARIATION SELECTORs (U+180B-180D, FF00-FE0F) code points are also239mapped to nothing. The OBJECT REPLACEMENT CHARACTER (U+FFFC) is240mapped to nothing.241242CHARACTER TABULATION (U+0009), LINE FEED (LF) (U+000A), LINE243TABULATION (U+000B), FORM FEED (FF) (U+000C), CARRIAGE RETURN (CR)244(U+000D), and NEXT LINE (NEL) (U+0085) are mapped to SPACE (U+0020).245246All other control code (e.g., Cc) points or code points with a247control function (e.g., Cf) are mapped to nothing. The following is248a complete list of these code points: U+0000-0008, 000E-001F, 007F-2490084, 0086-009F, 06DD, 070F, 180E, 200C-200F, 202A-202E, 2060-2063,250206A-206F, FEFF, FFF9-FFFB, 1D173-1D17A, E0001, E0020-E007F.251252ZERO WIDTH SPACE (U+200B) is mapped to nothing. All other code253points with Separator (space, line, or paragraph) property (e.g., Zs,254Zl, or Zp) are mapped to SPACE (U+0020). The following is a complete255list of these code points: U+0020, 00A0, 1680, 2000-200A, 2028-2029,256202F, 205F, 3000.257258For case ignore, numeric, and stored prefix string matching rules,259characters are case folded per B.2 of [RFC3454].260261The output is the mapped string.2622632.3. Normalize264265The input string is to be normalized to Unicode Form KC266(compatibility composed) as described in [UAX15]. The output is the267normalized string.2682692.4. Prohibit270271All Unassigned code points are prohibited. Unassigned code points272are listed in Table A.1 of [RFC3454].273274Characters that, per Section 5.8 of [RFC3454], change display275properties or are deprecated are prohibited. These characters are276listed in Table C.8 of [RFC3454].277278279280281Zeilenga Standards Track [Page 5]282283RFC 4518 LDAP: Internationalized String Preparation June 2006284285286Private Use code points are prohibited. These characters are listed287in Table C.3 of [RFC3454].288289All non-character code points are prohibited. These code points are290listed in Table C.4 of [RFC3454].291292Surrogate codes are prohibited. These characters are listed in Table293C.5 of [RFC3454].294295The REPLACEMENT CHARACTER (U+FFFD) code point is prohibited.296297The step fails if the input string contains any prohibited code298point. Otherwise, the output is the input string.2993002.5. Check bidi301302Bidirectional characters are ignored.3033042.6. Insignificant Character Handling305306In this step, the string is modified to ensure proper handling of307characters insignificant to the matching rule. This modification308differs from matching rule to matching rule.309310Section 2.6.1 applies to case ignore and exact string matching.311Section 2.6.2 applies to numericString matching.312Section 2.6.3 applies to telephoneNumber matching.3133142.6.1. Insignificant Space Handling315316For the purposes of this section, a space is defined to be the SPACE317(U+0020) code point followed by no combining marks.318319NOTE - The previous steps ensure that the string cannot contain320any code points in the separator class, other than SPACE321(U+0020).322323For input strings that are attribute values or non-substring324assertion values: If the input string contains no non-space325character, then the output is exactly two SPACEs. Otherwise (the326input string contains at least one non-space character), the string327is modified such that the string starts with exactly one space328character, ends with exactly one SPACE character, and any inner329(non-empty) sequence of space characters is replaced with exactly two330SPACE characters. For instance, the input strings331"foo<SPACE>bar<SPACE><SPACE>", result in the output332"<SPACE>foo<SPACE><SPACE>bar<SPACE>".333334335336337Zeilenga Standards Track [Page 6]338339RFC 4518 LDAP: Internationalized String Preparation June 2006340341342For input strings that are substring assertion values: If the string343being prepared contains no non-space characters, then the output344string is exactly one SPACE. Otherwise, the following steps are345taken:346347- If the input string is an initial substring, it is modified to348start with exactly one SPACE character;349350- If the input string is an initial or an any substring that ends in351one or more space characters, it is modified to end with exactly352one SPACE character;353354- If the input string is an any or a final substring that starts in355one or more space characters, it is modified to start with exactly356one SPACE character; and357358- If the input string is a final substring, it is modified to end359with exactly one SPACE character.360361For instance, for the input string "foo<SPACE>bar<SPACE><SPACE>" as362an initial substring, the output would be363"<SPACE>foo<SPACE><SPACE>bar<SPACE>". As an any or final substring,364the same input would result in "foo<SPACE>bar<SPACE>".365366Appendix B discusses the rationale for the behavior.3673682.6.2. numericString Insignificant Character Handling369370For the purposes of this section, a space is defined to be the SPACE371(U+0020) code point followed by no combining marks.372373All spaces are regarded as insignificant and are to be removed.374375For example, removal of spaces from the Form KC string:376"<SPACE><SPACE>123<SPACE><SPACE>456<SPACE><SPACE>"377would result in the output string:378"123456"379and the Form KC string:380"<SPACE><SPACE><SPACE>"381would result in the output string:382"" (an empty string).3833842.6.3. telephoneNumber Insignificant Character Handling385386For the purposes of this section, a hyphen is defined to be a387HYPHEN-MINUS (U+002D), ARMENIAN HYPHEN (U+058A), HYPHEN (U+2010),388NON-BREAKING HYPHEN (U+2011), MINUS SIGN (U+2212), SMALL HYPHEN-MINUS389(U+FE63), or FULLWIDTH HYPHEN-MINUS (U+FF0D) code point followed by390391392393Zeilenga Standards Track [Page 7]394395RFC 4518 LDAP: Internationalized String Preparation June 2006396397398no combining marks and a space is defined to be the SPACE (U+0020)399code point followed by no combining marks.400401All hyphens and spaces are considered insignificant and are to be402removed.403404For example, removal of hyphens and spaces from the Form KC string:405"<SPACE><HYPHEN>123<SPACE><SPACE>456<SPACE><HYPHEN>"406would result in the output string:407"123456"408and the Form KC string:409"<HYPHEN><HYPHEN><HYPHEN>"410would result in the (empty) output string:411"".4124133. Security Considerations414415"Preparation of Internationalized Strings ("stringprep")" [RFC3454]416security considerations generally apply to the algorithms described417here.4184194. Acknowledgements420421The approach used in this document is based upon design principles422and algorithms described in "Preparation of Internationalized Strings423('stringprep')" [RFC3454] by Paul Hoffman and Marc Blanchet. Some424additional guidance was drawn from Unicode Technical Standards,425Technical Reports, and Notes.426427This document is a product of the IETF LDAP Revision (LDAPBIS)428Working Group.4294305. References4314325.1. Normative References433434[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate435Requirement Levels", BCP 14, RFC 2119, March 1997.436437[RFC3454] Hoffman, P. and M. Blanchet, "Preparation of438Internationalized Strings ("stringprep")", RFC 3454,439December 2002.440441[RFC4510] Zeilenga, K., "Lightweight Directory Access Protocol442(LDAP): Technical Specification Road Map", RFC 4510,443June 2006.444445446447448449Zeilenga Standards Track [Page 8]450451RFC 4518 LDAP: Internationalized String Preparation June 2006452453454[RFC4517] Legg, S., Ed., "Lightweight Directory Access Protocol455(LDAP): Syntaxes and Matching Rules", RFC 4517, June4562006.457458[Unicode] The Unicode Consortium, "The Unicode Standard, Version4593.2.0" is defined by "The Unicode Standard, Version4603.0" (Reading, MA, Addison-Wesley, 2000. ISBN 0-201-46161633-5), as amended by the "Unicode Standard Annex462#27: Unicode 3.1"463(http://www.unicode.org/reports/tr27/) and by the464"Unicode Standard Annex #28: Unicode 3.2"465(http://www.unicode.org/reports/tr28/).466467[UAX15] Davis, M. and M. Duerst, "Unicode Standard Annex #15:468Unicode Normalization Forms, Version 3.2.0".469<http://www.unicode.org/unicode/reports/tr15/tr15-47022.html>, March 2002.471472[X.680] International Telecommunication Union -473Telecommunication Standardization Sector, "Abstract474Syntax Notation One (ASN.1) - Specification of Basic475Notation", X.680(2002) (also ISO/IEC 8824-1:2002).4764775.2. Informative References478479[X.500] International Telecommunication Union -480Telecommunication Standardization Sector, "The481Directory -- Overview of concepts, models and482services," X.500(1993) (also ISO/IEC 9594-1:1994).483484[X.501] International Telecommunication Union -485Telecommunication Standardization Sector, "The486Directory -- Models," X.501(1993) (also ISO/IEC 9594-4872:1994).488489[X.520] International Telecommunication Union -490Telecommunication Standardization Sector, "The491Directory: Selected Attribute Types", X.520(1993) (also492ISO/IEC 9594-6:1994).493494[Glossary] The Unicode Consortium, "Unicode Glossary",495<http://www.unicode.org/glossary/>.496497[CharModel] Whistler, K. and M. Davis, "Unicode Technical Report498#17, Character Encoding Model", UTR17,499<http://www.unicode.org/unicode/reports/tr17/>, August5002000.501502503504505Zeilenga Standards Track [Page 9]506507RFC 4518 LDAP: Internationalized String Preparation June 2006508509510[RFC3377] Hodges, J. and R. Morgan, "Lightweight Directory Access511Protocol (v3): Technical Specification", RFC 3377,512September 2002.513514[RFC4515] Smith, M., Ed. and T. Howes, "Lightweight Directory515Access Protocol (LDAP): String Representation of Search516Filters", RFC 4515, June 2006.517518[XMATCH] Zeilenga, K., "Internationalized String Matching Rules519for X.500", Work in Progress.520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561Zeilenga Standards Track [Page 10]562563RFC 4518 LDAP: Internationalized String Preparation June 2006564565566Appendix A. Combining Marks567568This appendix is normative.569570This table was derived from Unicode [Unicode] data files; it lists571all code points with the Mn, Mc, or Me properties. This table is to572be considered definitive for the purposes of implementation of this573specification.5745750300-034F 0360-036F 0483-0486 0488-0489 0591-05A157605A3-05B9 05BB-05BC 05BF 05C1-05C2 05C4 064B-0655 067057706D6-06DC 06DE-06E4 06E7-06E8 06EA-06ED 0711 0730-074A57807A6-07B0 0901-0903 093C 093E-094F 0951-0954 0962-09635790981-0983 09BC 09BE-09C4 09C7-09C8 09CB-09CD 09D758009E2-09E3 0A02 0A3C 0A3E-0A42 0A47-0A48 0A4B-0A4D5810A70-0A71 0A81-0A83 0ABC 0ABE-0AC5 0AC7-0AC9 0ACB-0ACD5820B01-0B03 0B3C 0B3E-0B43 0B47-0B48 0B4B-0B4D 0B56-0B575830B82 0BBE-0BC2 0BC6-0BC8 0BCA-0BCD 0BD7 0C01-0C035840C3E-0C44 0C46-0C48 0C4A-0C4D 0C55-0C56 0C82-0C835850CBE-0CC4 0CC6-0CC8 0CCA-0CCD 0CD5-0CD6 0D02-0D035860D3E-0D43 0D46-0D48 0D4A-0D4D 0D57 0D82-0D83 0DCA5870DCF-0DD4 0DD6 0DD8-0DDF 0DF2-0DF3 0E31 0E34-0E3A5880E47-0E4E 0EB1 0EB4-0EB9 0EBB-0EBC 0EC8-0ECD 0F18-0F195890F35 0F37 0F39 0F3E-0F3F 0F71-0F84 0F86-0F87 0F90-0F975900F99-0FBC 0FC6 102C-1032 1036-1039 1056-1059 1712-17145911732-1734 1752-1753 1772-1773 17B4-17D3 180B-180D 18A959220D0-20EA 302A-302F 3099-309A FB1E FE00-FE0F FE20-FE235931D165-1D169 1D16D-1D172 1D17B-1D182 1D185-1D18B5941D1AA-1D1AD595596Appendix B. Substrings Matching597598This appendix is non-normative.599600In the absence of substrings matching, the insignificant space601handling for case ignore/exact matching could be simplified.602Specifically, the handling could be to require that all sequences of603one or more spaces be replaced with one space and, if the string604contains non-space characters, removal of all leading spaces and605trailing spaces.606607In the presence of substrings matching, this simplified space608handling would lead to unexpected and undesirable matching behavior.609For instance:6106111) (CN=foo\20*\20bar) would match the CN value "foobar";612613614615616617Zeilenga Standards Track [Page 11]618619RFC 4518 LDAP: Internationalized String Preparation June 20066206216222) (CN=*\20foobar\20*) would match "foobar", but623(CN=*\20*foobar*\20*) would not.624625Note to readers not familiar with LDAP substrings matching: the LDAP626filter [RFC4515] assertion (CN=A*B*C) says to "match any value (of627the attribute CN) that begins with A, contains B after A, ends with C628where C is also after B."629630The first case illustrates that this simplified space handling would631cause leading and trailing spaces in substrings of the string to be632regarded as insignificant. However, only leading and trailing (as633well as multiple consecutive spaces) of the string (as a whole) are634insignificant.635636The second case illustrates that this simplified space handling would637cause sub-partitioning failures. That is, if a prepared any638substring matches a partition of the attribute value, then an639assertion constructed by subdividing that substring into multiple640substrings should also match.641642In designing an appropriate approach for space handling for643substrings matching, one must study key aspects of X.500 case644exact/ignore matching. X.520 [X.520] says:645646The [substrings] rule returns TRUE if there is a partitioning of647the attribute value (into portions) such that:648649- the specified substrings (initial, any, final) match650different portions of the value in the order of the strings651sequence;652653- initial, if present, matches the first portion of the value;654655- final, if present, matches the last portion of the value;656657- any, if present, matches some arbitrary portion of the658value.659660That is, the substrings assertion (CN=foo\20*\20bar) matches the661attribute value "foo<SPACE><SPACE>bar" as the value can be662partitioned into the portions "foo<SPACE>" and "<SPACE>bar" meeting663the above requirements.664665666667668669670671672673Zeilenga Standards Track [Page 12]674675RFC 4518 LDAP: Internationalized String Preparation June 2006676677678X.520 also says:679680[T]he following spaces are regarded as not significant:681682- leading spaces (i.e., those preceding the first character683that is not a space);684685- trailing spaces (i.e., those following the last character686that is not a space);687688- multiple consecutive spaces (these are taken as equivalent689to a single space character).690691This statement applies to the assertion values and attribute values692as whole strings, and not individually to substrings of an assertion693value. In particular, the statements should be taken to mean that if694an assertion value and attribute value match without any695consideration to insignificant characters, then that assertion value696should also match any attribute value that differs only by inclusion697nor removal of insignificant characters.698699Hence the assertion (CN=foo\20*\20bar) matches700"foo<SPACE><SPACE><SPACE>bar" and "foo<SPACE>bar" as these values701only differ from "foo<SPACE><SPACE>bar" by the inclusion or removal702of insignificant spaces.703704Astute readers of this text will also note that there are special705cases where the specified space handling does not ignore spaces that706could be considered insignificant. For instance, the assertion707(CN=\20*\20*\20) does not match "<SPACE><SPACE><SPACE>"708(insignificant spaces present in value) or " " (insignificant spaces709not present in value). However, as these cases have no practical710application that cannot be met by simple assertions, e.g., (cn=\20),711and this minor anomaly can only be fully addressed by a preparation712algorithm to be used in conjunction with character-by-character713partitioning and matching, the anomaly is considered acceptable.714715Author's Address716717Kurt D. Zeilenga718OpenLDAP Foundation719720EMail: [email protected]721722723724725726727728729Zeilenga Standards Track [Page 13]730731RFC 4518 LDAP: Internationalized String Preparation June 2006732733734Full Copyright Statement735736Copyright (C) The Internet Society (2006).737738This document is subject to the rights, licenses and restrictions739contained in BCP 78, and except as set forth therein, the authors740retain all their rights.741742This document and the information contained herein are provided on an743"AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS744OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET745ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,746INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE747INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED748WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.749750Intellectual Property751752The IETF takes no position regarding the validity or scope of any753Intellectual Property Rights or other rights that might be claimed to754pertain to the implementation or use of the technology described in755this document or the extent to which any license under such rights756might or might not be available; nor does it represent that it has757made any independent effort to identify any such rights. Information758on the procedures with respect to rights in RFC documents can be759found in BCP 78 and BCP 79.760761Copies of IPR disclosures made to the IETF Secretariat and any762assurances of licenses to be made available, or the result of an763attempt made to obtain a general license or permission for the use of764such proprietary rights by implementers or users of this765specification can be obtained from the IETF on-line IPR repository at766http://www.ietf.org/ipr.767768The IETF invites any interested party to bring to its attention any769copyrights, patents or patent applications, or other proprietary770rights that may cover technology that may be required to implement771this standard. Please address the information to the IETF at772[email protected].773774Acknowledgement775776Funding for the RFC Editor function is provided by the IETF777Administrative Support Activity (IASA).778779780781782783784785Zeilenga Standards Track [Page 14]786787788789