Back to index

glibc  2.9
profiles.c
Go to the documentation of this file.
00001 /* profiles.c Definitions of stringprep profiles.
00002  * Copyright (C) 2002, 2003, 2004  Simon Josefsson
00003  *
00004  * This file is part of GNU Libidn.
00005  *
00006  * GNU Libidn is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * GNU Libidn is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with GNU Libidn; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #include "stringprep.h"
00023 
00024 const Stringprep_profiles stringprep_profiles[] = {
00025   {"Nameprep", stringprep_nameprep},
00026   {"KRBprep", stringprep_kerberos5},      /* Deprecate? */
00027   {"Nodeprep", stringprep_xmpp_nodeprep},
00028   {"Resourceprep", stringprep_xmpp_resourceprep},
00029   {"plain", stringprep_plain},     /* sasl-anon-00. */
00030   {"trace", stringprep_trace},     /* sasl-anon-01,02. */
00031   {"SASLprep", stringprep_saslprep},
00032   {"ISCSIprep", stringprep_iscsi}, /* Obsolete. */
00033   {"iSCSI", stringprep_iscsi},     /* IANA. */
00034   {NULL, NULL}
00035 };
00036 
00037 const Stringprep_profile stringprep_nameprep[] = {
00038   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_1},
00039   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_2},
00040   {STRINGPREP_NFKC, 0, 0},
00041   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_2},
00042   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00043   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00044   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00045   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00046   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00047   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_7},
00048   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00049   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00050   {STRINGPREP_BIDI, 0, 0},
00051   {STRINGPREP_BIDI_PROHIBIT_TABLE, ~STRINGPREP_NO_BIDI,
00052    stringprep_rfc3454_C_8},
00053   {STRINGPREP_BIDI_RAL_TABLE, 0, stringprep_rfc3454_D_1},
00054   {STRINGPREP_BIDI_L_TABLE, 0, stringprep_rfc3454_D_2},
00055   {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
00056    stringprep_rfc3454_A_1},
00057   {0}
00058 };
00059 
00060 const Stringprep_profile stringprep_kerberos5[] = {
00061   /* XXX this is likely to be wrong as the specification is
00062      a rough draft. */
00063   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_1},
00064   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_3},
00065   {STRINGPREP_NFKC, 0, 0},
00066   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_2},
00067   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00068   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00069   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00070   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00071   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00072   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_7},
00073   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00074   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00075   {STRINGPREP_BIDI, 0, 0},
00076   {STRINGPREP_BIDI_PROHIBIT_TABLE, ~STRINGPREP_NO_BIDI,
00077    stringprep_rfc3454_C_8},
00078   {STRINGPREP_BIDI_RAL_TABLE, 0, stringprep_rfc3454_D_1},
00079   {STRINGPREP_BIDI_L_TABLE, 0, stringprep_rfc3454_D_2},
00080   {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
00081    stringprep_rfc3454_A_1},
00082   {0}
00083 };
00084 
00085 const Stringprep_table_element stringprep_xmpp_nodeprep_prohibit[] = {
00086   {0x000022},               /* #x22 (") */
00087   {0x000026},               /* #x26 (&) */
00088   {0x000027},               /* #x27 (') */
00089   {0x00002F},               /* #x2F (/) */
00090   {0x00003A},               /* #x3A (:) */
00091   {0x00003C},               /* #x3C (<) */
00092   {0x00003E},               /* #x3E (>) */
00093   {0x000040},               /* #x40 (@) */
00094   {0}
00095 };
00096 
00097 const Stringprep_profile stringprep_xmpp_nodeprep[] = {
00098   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_1},
00099   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_2},
00100   {STRINGPREP_NFKC, 0, 0},
00101   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_1},
00102   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_2},
00103   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00104   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00105   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00106   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00107   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00108   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00109   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_7},
00110   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00111   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00112   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_xmpp_nodeprep_prohibit},
00113   {STRINGPREP_BIDI, 0, 0},
00114   {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00115   {STRINGPREP_BIDI_RAL_TABLE, 0, stringprep_rfc3454_D_1},
00116   {STRINGPREP_BIDI_L_TABLE, 0, stringprep_rfc3454_D_2},
00117   {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
00118    stringprep_rfc3454_A_1},
00119   {0}
00120 };
00121 
00122 const Stringprep_profile stringprep_xmpp_resourceprep[] = {
00123   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_1},
00124   {STRINGPREP_NFKC, 0, 0},
00125   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_2},
00126   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00127   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00128   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00129   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00130   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00131   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00132   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_7},
00133   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00134   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00135   {STRINGPREP_BIDI, 0, 0},
00136   {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00137   {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_1},
00138   {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_2},
00139   {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
00140    stringprep_rfc3454_A_1},
00141   {0}
00142 };
00143 
00144 const Stringprep_profile stringprep_plain[] = {
00145   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00146   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00147   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00148   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00149   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00150   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00151   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00152   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00153   {STRINGPREP_BIDI, 0, 0},
00154   {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00155   {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_1},
00156   {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_2},
00157   {0}
00158 };
00159 
00160 const Stringprep_profile stringprep_trace[] = {
00161   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00162   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00163   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00164   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00165   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00166   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00167   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00168   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00169   {STRINGPREP_BIDI, 0, 0},
00170   {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00171   {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_1},
00172   {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_2},
00173   {0}
00174 };
00175 
00176 const Stringprep_table_element stringprep_iscsi_prohibit[] = {
00177   {0x0000},                 /* [ASCII CONTROL CHARACTERS and SPACE through ,] */
00178   {0x0001},
00179   {0x0002},
00180   {0x0003},
00181   {0x0004},
00182   {0x0005},
00183   {0x0006},
00184   {0x0007},
00185   {0x0008},
00186   {0x0009},
00187   {0x000A},
00188   {0x000B},
00189   {0x000C},
00190   {0x000D},
00191   {0x000E},
00192   {0x000F},
00193   {0x0010},
00194   {0x0011},
00195   {0x0012},
00196   {0x0013},
00197   {0x0014},
00198   {0x0015},
00199   {0x0016},
00200   {0x0017},
00201   {0x0018},
00202   {0x0019},
00203   {0x001A},
00204   {0x001B},
00205   {0x001C},
00206   {0x001D},
00207   {0x001E},
00208   {0x001F},
00209   {0x0020},
00210   {0x0021},
00211   {0x0022},
00212   {0x0023},
00213   {0x0024},
00214   {0x0025},
00215   {0x0026},
00216   {0x0027},
00217   {0x0028},
00218   {0x0029},
00219   {0x002A},
00220   {0x002B},
00221   {0x002C},
00222   {0x002F},                 /* [ASCII /] */
00223   {0x003B},                 /* [ASCII ; through @] */
00224   {0x003C},
00225   {0x003D},
00226   {0x003E},
00227   {0x003F},
00228   {0x0040},
00229   {0x005B},                 /* [ASCII [ through `] */
00230   {0x005C},
00231   {0x005D},
00232   {0x005E},
00233   {0x005F},
00234   {0x0060},
00235   {0x007B},                 /* [ASCII { through DEL] */
00236   {0x007C},
00237   {0x007D},
00238   {0x007E},
00239   {0x007F},
00240   {0x3002},                 /* ideographic full stop */
00241   {0}
00242 };
00243 
00244 const Stringprep_profile stringprep_iscsi[] = {
00245   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_1},
00246   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_2},
00247   {STRINGPREP_NFKC, 0, 0},
00248   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00249   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00250   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00251   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00252   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00253   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00254   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00255   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00256   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00257   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00258   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_iscsi_prohibit},
00259   {STRINGPREP_BIDI, 0, 0},
00260   {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00261   {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_1},
00262   {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_2},
00263   {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
00264    stringprep_rfc3454_A_1},
00265   {0}
00266 };
00267 
00268 const Stringprep_table_element stringprep_saslprep_space_map[] = {
00269   {0x0000A0, 0, {0x0020}},  /* 00A0; NO-BREAK SPACE */
00270   {0x001680, 0, {0x0020}},  /* 1680; OGHAM SPACE MARK */
00271   {0x002000, 0, {0x0020}},  /* 2000; EN QUAD */
00272   {0x002001, 0, {0x0020}},  /* 2001; EM QUAD */
00273   {0x002002, 0, {0x0020}},  /* 2002; EN SPACE */
00274   {0x002003, 0, {0x0020}},  /* 2003; EM SPACE */
00275   {0x002004, 0, {0x0020}},  /* 2004; THREE-PER-EM SPACE */
00276   {0x002005, 0, {0x0020}},  /* 2005; FOUR-PER-EM SPACE */
00277   {0x002006, 0, {0x0020}},  /* 2006; SIX-PER-EM SPACE */
00278   {0x002007, 0, {0x0020}},  /* 2007; FIGURE SPACE */
00279   {0x002008, 0, {0x0020}},  /* 2008; PUNCTUATION SPACE */
00280   {0x002009, 0, {0x0020}},  /* 2009; THIN SPACE */
00281   {0x00200A, 0, {0x0020}},  /* 200A; HAIR SPACE */
00282   {0x00200B, 0, {0x0020}},  /* 200B; ZERO WIDTH SPACE */
00283   {0x00202F, 0, {0x0020}},  /* 202F; NARROW NO-BREAK SPACE */
00284   {0x00205F, 0, {0x0020}},  /* 205F; MEDIUM MATHEMATICAL SPACE */
00285   {0x003000, 0, {0x0020}},  /* 3000; IDEOGRAPHIC SPACE */
00286   {0}
00287 };
00288 
00289 const Stringprep_profile stringprep_saslprep[] = {
00290   {STRINGPREP_MAP_TABLE, 0, stringprep_saslprep_space_map},
00291   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_1},
00292   {STRINGPREP_NFKC, 0, 0},
00293   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_2},
00294   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00295   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00296   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00297   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00298   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00299   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00300   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_7},
00301   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00302   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00303   {STRINGPREP_BIDI, 0, 0},
00304   {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00305   {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_1},
00306   {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_2},
00307   {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
00308    stringprep_rfc3454_A_1},
00309   {0}
00310 };