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