xref: /titanic_51/usr/src/lib/libkmf/include/rdn_parser.h (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
1 /*
2  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #ifndef _RDN_PARSER_H
7 #define	_RDN_PARSER_H
8 
9 #pragma ident	"%Z%%M%	%I%	%E% SMI"
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 /*
16  * The contents of this file are subject to the Mozilla Public
17  * License Version 1.1 (the "License"); you may not use this file
18  * except in compliance with the License. You may obtain a copy of
19  * the License at http://www.mozilla.org/MPL/
20  *
21  * Software distributed under the License is distributed on an "AS
22  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
23  * implied. See the License for the specific language governing
24  * rights and limitations under the License.
25  *
26  * The Original Code is the Netscape security libraries.
27  *
28  * The Initial Developer of the Original Code is Netscape
29  * Communications Corporation.  Portions created by Netscape are
30  * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
31  * Rights Reserved.
32  *
33  * Contributor(s):
34  *
35  * Alternatively, the contents of this file may be used under the
36  * terms of the GNU General Public License Version 2 or later (the
37  * "GPL"), in which case the provisions of the GPL are applicable
38  * instead of those above.  If you wish to allow use of your
39  * version of this file only under the terms of the GPL and not to
40  * allow others to use your version of this file under the MPL,
41  * indicate your decision by deleting the provisions above and
42  * replace them with the notice and other provisions required by
43  * the GPL.  If you do not delete the provisions above, a recipient
44  * may use your version of this file under either the MPL or the
45  * GPL.
46  */
47 
48 typedef enum {
49 	OID_AVA_COMMON_NAME = 0,
50 	OID_AVA_SURNAME,
51 	OID_AVA_GIVEN_NAME,
52 	OID_AVA_LOCALITY,
53 	OID_AVA_STATE_OR_PROVINCE,
54 	OID_AVA_ORGANIZATION_NAME,
55 	OID_AVA_ORGANIZATIONAL_UNIT_NAME,
56 	OID_AVA_COUNTRY_NAME,
57 	OID_AVA_STREET_ADDRESS,
58 	OID_AVA_DC,
59 	OID_RFC1274_UID,
60 	OID_PKCS9_EMAIL_ADDRESS,
61 	OID_RFC1274_MAIL,
62 	OID_UNKNOWN
63 } OidAvaTag;
64 
65 struct NameToKind {
66     const char  *name;
67     OidAvaTag    kind;
68     KMF_OID	 *OID;
69 };
70 
71 #define	C_DOUBLE_QUOTE '\042'
72 
73 #define	C_BACKSLASH '\134'
74 
75 #define	C_EQUAL '='
76 
77 #define	OPTIONAL_SPACE(c) \
78 	(((c) == ' ') || ((c) == '\r') || ((c) == '\n'))
79 
80 #define	SPECIAL_CHAR(c)							\
81 	(((c) == ',') || ((c) == '=') || ((c) == C_DOUBLE_QUOTE) ||	\
82 	((c) == '\r') || ((c) == '\n') || ((c) == '+') ||		\
83 	((c) == '<') || ((c) == '>') || ((c) == '#') ||			\
84 	((c) == ';') || ((c) == C_BACKSLASH))
85 
86 
87 #define	IS_PRINTABLE(c)							\
88 	((((c) >= 'a') && ((c) <= 'z')) ||				\
89 	(((c) >= 'A') && ((c) <= 'Z')) ||				\
90 	(((c) >= '0') && ((c) <= '9')) ||				\
91 	((c) == ' ') ||							\
92 	((c) == '\'') ||						\
93 	((c) == '\050') ||				/* ( */		\
94 	((c) == '\051') ||				/* ) */		\
95 	(((c) >= '+') && ((c) <= '/')) ||		/* + , - . / */	\
96 	((c) == ':') ||							\
97 	((c) == '=') ||							\
98 	((c) == '?'))
99 
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 #endif /* _RDN_PARSER_H */
105