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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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,03. */
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   /* NB, since start == 0, we must have that end != 0 for the
00178      end-of-table logic to work. */
00179   {0x0000, 1},                  /* [ASCII CONTROL CHARACTERS and SPACE through ,] */
00180   {0x0001},
00181   {0x0002},
00182   {0x0003},
00183   {0x0004},
00184   {0x0005},
00185   {0x0006},
00186   {0x0007},
00187   {0x0008},
00188   {0x0009},
00189   {0x000A},
00190   {0x000B},
00191   {0x000C},
00192   {0x000D},
00193   {0x000E},
00194   {0x000F},
00195   {0x0010},
00196   {0x0011},
00197   {0x0012},
00198   {0x0013},
00199   {0x0014},
00200   {0x0015},
00201   {0x0016},
00202   {0x0017},
00203   {0x0018},
00204   {0x0019},
00205   {0x001A},
00206   {0x001B},
00207   {0x001C},
00208   {0x001D},
00209   {0x001E},
00210   {0x001F},
00211   {0x0020},
00212   {0x0021},
00213   {0x0022},
00214   {0x0023},
00215   {0x0024},
00216   {0x0025},
00217   {0x0026},
00218   {0x0027},
00219   {0x0028},
00220   {0x0029},
00221   {0x002A},
00222   {0x002B},
00223   {0x002C},
00224   {0x002F},                     /* [ASCII /] */
00225   {0x003B},                     /* [ASCII ; through @] */
00226   {0x003C},
00227   {0x003D},
00228   {0x003E},
00229   {0x003F},
00230   {0x0040},
00231   {0x005B},                     /* [ASCII [ through `] */
00232   {0x005C},
00233   {0x005D},
00234   {0x005E},
00235   {0x005F},
00236   {0x0060},
00237   {0x007B},                     /* [ASCII { through DEL] */
00238   {0x007C},
00239   {0x007D},
00240   {0x007E},
00241   {0x007F},
00242   {0x3002},                     /* ideographic full stop */
00243   {0}
00244 };
00245 
00246 const Stringprep_profile stringprep_iscsi[] = {
00247   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_1},
00248   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_2},
00249   {STRINGPREP_NFKC, 0, 0},
00250   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_1},
00251   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_2},
00252   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00253   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00254   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00255   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00256   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00257   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00258   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_7},
00259   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00260   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00261   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_iscsi_prohibit},
00262   {STRINGPREP_BIDI, 0, 0},
00263   {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00264   {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_1},
00265   {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_2},
00266   {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
00267    stringprep_rfc3454_A_1},
00268   {0}
00269 };
00270 
00271 const Stringprep_table_element stringprep_saslprep_space_map[] = {
00272   {0x0000A0, 0, {0x0020}},      /* 00A0; NO-BREAK SPACE */
00273   {0x001680, 0, {0x0020}},      /* 1680; OGHAM SPACE MARK */
00274   {0x002000, 0, {0x0020}},      /* 2000; EN QUAD */
00275   {0x002001, 0, {0x0020}},      /* 2001; EM QUAD */
00276   {0x002002, 0, {0x0020}},      /* 2002; EN SPACE */
00277   {0x002003, 0, {0x0020}},      /* 2003; EM SPACE */
00278   {0x002004, 0, {0x0020}},      /* 2004; THREE-PER-EM SPACE */
00279   {0x002005, 0, {0x0020}},      /* 2005; FOUR-PER-EM SPACE */
00280   {0x002006, 0, {0x0020}},      /* 2006; SIX-PER-EM SPACE */
00281   {0x002007, 0, {0x0020}},      /* 2007; FIGURE SPACE */
00282   {0x002008, 0, {0x0020}},      /* 2008; PUNCTUATION SPACE */
00283   {0x002009, 0, {0x0020}},      /* 2009; THIN SPACE */
00284   {0x00200A, 0, {0x0020}},      /* 200A; HAIR SPACE */
00285   {0x00200B, 0, {0x0020}},      /* 200B; ZERO WIDTH SPACE */
00286   {0x00202F, 0, {0x0020}},      /* 202F; NARROW NO-BREAK SPACE */
00287   {0x00205F, 0, {0x0020}},      /* 205F; MEDIUM MATHEMATICAL SPACE */
00288   {0x003000, 0, {0x0020}},      /* 3000; IDEOGRAPHIC SPACE */
00289   {0}
00290 };
00291 
00292 const Stringprep_profile stringprep_saslprep[] = {
00293   {STRINGPREP_MAP_TABLE, 0, stringprep_saslprep_space_map},
00294   {STRINGPREP_MAP_TABLE, 0, stringprep_rfc3454_B_1},
00295   {STRINGPREP_NFKC, 0, 0},
00296   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_1_2},
00297   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_1},
00298   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_2_2},
00299   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_3},
00300   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_4},
00301   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_5},
00302   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_6},
00303   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_7},
00304   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00305   {STRINGPREP_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_9},
00306   {STRINGPREP_BIDI, 0, 0},
00307   {STRINGPREP_BIDI_PROHIBIT_TABLE, 0, stringprep_rfc3454_C_8},
00308   {STRINGPREP_BIDI_RAL_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_1},
00309   {STRINGPREP_BIDI_L_TABLE, ~STRINGPREP_NO_BIDI, stringprep_rfc3454_D_2},
00310   {STRINGPREP_UNASSIGNED_TABLE, ~STRINGPREP_NO_UNASSIGNED,
00311    stringprep_rfc3454_A_1},
00312   {0}
00313 };

Generated on Wed Sep 13 10:20:31 2006 for libidn by  doxygen 1.4.7