xref: /titanic_52/usr/src/lib/libkmf/include/rdn_parser.h (revision 30a5e8fa1253cb33980ee4514743cf683f584b4e)
199ebb4caSwyllys /*
2*9a767088Shaimay  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
399ebb4caSwyllys  * Use is subject to license terms.
499ebb4caSwyllys  */
599ebb4caSwyllys 
699ebb4caSwyllys #ifndef _RDN_PARSER_H
799ebb4caSwyllys #define	_RDN_PARSER_H
899ebb4caSwyllys 
999ebb4caSwyllys #pragma ident	"%Z%%M%	%I%	%E% SMI"
1099ebb4caSwyllys 
1199ebb4caSwyllys #ifdef __cplusplus
1299ebb4caSwyllys extern "C" {
1399ebb4caSwyllys #endif
1499ebb4caSwyllys 
1599ebb4caSwyllys /*
1699ebb4caSwyllys  * The contents of this file are subject to the Mozilla Public
1799ebb4caSwyllys  * License Version 1.1 (the "License"); you may not use this file
1899ebb4caSwyllys  * except in compliance with the License. You may obtain a copy of
1999ebb4caSwyllys  * the License at http://www.mozilla.org/MPL/
2099ebb4caSwyllys  *
2199ebb4caSwyllys  * Software distributed under the License is distributed on an "AS
2299ebb4caSwyllys  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
2399ebb4caSwyllys  * implied. See the License for the specific language governing
2499ebb4caSwyllys  * rights and limitations under the License.
2599ebb4caSwyllys  *
2699ebb4caSwyllys  * The Original Code is the Netscape security libraries.
2799ebb4caSwyllys  *
2899ebb4caSwyllys  * The Initial Developer of the Original Code is Netscape
2999ebb4caSwyllys  * Communications Corporation.  Portions created by Netscape are
3099ebb4caSwyllys  * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
3199ebb4caSwyllys  * Rights Reserved.
3299ebb4caSwyllys  *
3399ebb4caSwyllys  * Contributor(s):
3499ebb4caSwyllys  *
3599ebb4caSwyllys  * Alternatively, the contents of this file may be used under the
3699ebb4caSwyllys  * terms of the GNU General Public License Version 2 or later (the
3799ebb4caSwyllys  * "GPL"), in which case the provisions of the GPL are applicable
3899ebb4caSwyllys  * instead of those above.  If you wish to allow use of your
3999ebb4caSwyllys  * version of this file only under the terms of the GPL and not to
4099ebb4caSwyllys  * allow others to use your version of this file under the MPL,
4199ebb4caSwyllys  * indicate your decision by deleting the provisions above and
4299ebb4caSwyllys  * replace them with the notice and other provisions required by
4399ebb4caSwyllys  * the GPL.  If you do not delete the provisions above, a recipient
4499ebb4caSwyllys  * may use your version of this file under either the MPL or the
4599ebb4caSwyllys  * GPL.
4699ebb4caSwyllys  */
4799ebb4caSwyllys 
4899ebb4caSwyllys typedef enum {
4999ebb4caSwyllys 	OID_AVA_COMMON_NAME = 0,
5099ebb4caSwyllys 	OID_AVA_SURNAME,
5199ebb4caSwyllys 	OID_AVA_GIVEN_NAME,
5299ebb4caSwyllys 	OID_AVA_LOCALITY,
5399ebb4caSwyllys 	OID_AVA_STATE_OR_PROVINCE,
5499ebb4caSwyllys 	OID_AVA_ORGANIZATION_NAME,
5599ebb4caSwyllys 	OID_AVA_ORGANIZATIONAL_UNIT_NAME,
5699ebb4caSwyllys 	OID_AVA_COUNTRY_NAME,
5799ebb4caSwyllys 	OID_AVA_STREET_ADDRESS,
5899ebb4caSwyllys 	OID_AVA_DC,
5999ebb4caSwyllys 	OID_RFC1274_UID,
6099ebb4caSwyllys 	OID_PKCS9_EMAIL_ADDRESS,
6199ebb4caSwyllys 	OID_RFC1274_MAIL,
6299ebb4caSwyllys 	OID_UNKNOWN
6399ebb4caSwyllys } OidAvaTag;
6499ebb4caSwyllys 
6599ebb4caSwyllys struct NameToKind {
6699ebb4caSwyllys     const char  *name;
6799ebb4caSwyllys     OidAvaTag    kind;
6899ebb4caSwyllys     KMF_OID	 *OID;
6999ebb4caSwyllys };
7099ebb4caSwyllys 
7199ebb4caSwyllys #define	C_DOUBLE_QUOTE '\042'
7299ebb4caSwyllys 
7399ebb4caSwyllys #define	C_BACKSLASH '\134'
7499ebb4caSwyllys 
7599ebb4caSwyllys #define	C_EQUAL '='
7699ebb4caSwyllys 
7799ebb4caSwyllys #define	OPTIONAL_SPACE(c) \
7899ebb4caSwyllys 	(((c) == ' ') || ((c) == '\r') || ((c) == '\n'))
7999ebb4caSwyllys 
8099ebb4caSwyllys #define	SPECIAL_CHAR(c)							\
8199ebb4caSwyllys 	(((c) == ',') || ((c) == '=') || ((c) == C_DOUBLE_QUOTE) ||	\
8299ebb4caSwyllys 	((c) == '\r') || ((c) == '\n') || ((c) == '+') ||		\
8399ebb4caSwyllys 	((c) == '<') || ((c) == '>') || ((c) == '#') ||			\
8499ebb4caSwyllys 	((c) == ';') || ((c) == C_BACKSLASH))
8599ebb4caSwyllys 
8699ebb4caSwyllys 
8799ebb4caSwyllys #define	IS_PRINTABLE(c)							\
8899ebb4caSwyllys 	((((c) >= 'a') && ((c) <= 'z')) ||				\
8999ebb4caSwyllys 	(((c) >= 'A') && ((c) <= 'Z')) ||				\
9099ebb4caSwyllys 	(((c) >= '0') && ((c) <= '9')) ||				\
9199ebb4caSwyllys 	((c) == ' ') ||							\
9299ebb4caSwyllys 	((c) == '\'') ||						\
9399ebb4caSwyllys 	((c) == '\050') ||				/* ( */		\
9499ebb4caSwyllys 	((c) == '\051') ||				/* ) */		\
9599ebb4caSwyllys 	(((c) >= '+') && ((c) <= '/')) ||		/* + , - . / */	\
9699ebb4caSwyllys 	((c) == ':') ||							\
9799ebb4caSwyllys 	((c) == '=') ||							\
9899ebb4caSwyllys 	((c) == '?'))
9999ebb4caSwyllys 
10099ebb4caSwyllys 
10199ebb4caSwyllys #ifdef __cplusplus
10299ebb4caSwyllys }
10399ebb4caSwyllys #endif
10499ebb4caSwyllys #endif /* _RDN_PARSER_H */
105