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