xref: /onnv-gate/usr/src/lib/libkmf/include/rdn_parser.h (revision 5051:cbbb7c8b40a9)
13089Swyllys /*
2*3433Shaimay  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
33089Swyllys  * Use is subject to license terms.
43089Swyllys  */
53089Swyllys 
63089Swyllys #ifndef _RDN_PARSER_H
73089Swyllys #define	_RDN_PARSER_H
83089Swyllys 
93089Swyllys #pragma ident	"%Z%%M%	%I%	%E% SMI"
103089Swyllys 
113089Swyllys #ifdef __cplusplus
123089Swyllys extern "C" {
133089Swyllys #endif
143089Swyllys 
153089Swyllys /*
163089Swyllys  * The contents of this file are subject to the Mozilla Public
173089Swyllys  * License Version 1.1 (the "License"); you may not use this file
183089Swyllys  * except in compliance with the License. You may obtain a copy of
193089Swyllys  * the License at http://www.mozilla.org/MPL/
203089Swyllys  *
213089Swyllys  * Software distributed under the License is distributed on an "AS
223089Swyllys  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
233089Swyllys  * implied. See the License for the specific language governing
243089Swyllys  * rights and limitations under the License.
253089Swyllys  *
263089Swyllys  * The Original Code is the Netscape security libraries.
273089Swyllys  *
283089Swyllys  * The Initial Developer of the Original Code is Netscape
293089Swyllys  * Communications Corporation.  Portions created by Netscape are
303089Swyllys  * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
313089Swyllys  * Rights Reserved.
323089Swyllys  *
333089Swyllys  * Contributor(s):
343089Swyllys  *
353089Swyllys  * Alternatively, the contents of this file may be used under the
363089Swyllys  * terms of the GNU General Public License Version 2 or later (the
373089Swyllys  * "GPL"), in which case the provisions of the GPL are applicable
383089Swyllys  * instead of those above.  If you wish to allow use of your
393089Swyllys  * version of this file only under the terms of the GPL and not to
403089Swyllys  * allow others to use your version of this file under the MPL,
413089Swyllys  * indicate your decision by deleting the provisions above and
423089Swyllys  * replace them with the notice and other provisions required by
433089Swyllys  * the GPL.  If you do not delete the provisions above, a recipient
443089Swyllys  * may use your version of this file under either the MPL or the
453089Swyllys  * GPL.
463089Swyllys  */
473089Swyllys 
483089Swyllys typedef enum {
493089Swyllys 	OID_AVA_COMMON_NAME = 0,
503089Swyllys 	OID_AVA_SURNAME,
513089Swyllys 	OID_AVA_GIVEN_NAME,
523089Swyllys 	OID_AVA_LOCALITY,
533089Swyllys 	OID_AVA_STATE_OR_PROVINCE,
543089Swyllys 	OID_AVA_ORGANIZATION_NAME,
553089Swyllys 	OID_AVA_ORGANIZATIONAL_UNIT_NAME,
563089Swyllys 	OID_AVA_COUNTRY_NAME,
573089Swyllys 	OID_AVA_STREET_ADDRESS,
583089Swyllys 	OID_AVA_DC,
593089Swyllys 	OID_RFC1274_UID,
603089Swyllys 	OID_PKCS9_EMAIL_ADDRESS,
613089Swyllys 	OID_RFC1274_MAIL,
623089Swyllys 	OID_UNKNOWN
633089Swyllys } OidAvaTag;
643089Swyllys 
653089Swyllys struct NameToKind {
663089Swyllys     const char  *name;
673089Swyllys     OidAvaTag    kind;
683089Swyllys     KMF_OID	 *OID;
693089Swyllys };
703089Swyllys 
713089Swyllys #define	C_DOUBLE_QUOTE '\042'
723089Swyllys 
733089Swyllys #define	C_BACKSLASH '\134'
743089Swyllys 
753089Swyllys #define	C_EQUAL '='
763089Swyllys 
773089Swyllys #define	OPTIONAL_SPACE(c) \
783089Swyllys 	(((c) == ' ') || ((c) == '\r') || ((c) == '\n'))
793089Swyllys 
803089Swyllys #define	SPECIAL_CHAR(c)							\
813089Swyllys 	(((c) == ',') || ((c) == '=') || ((c) == C_DOUBLE_QUOTE) ||	\
823089Swyllys 	((c) == '\r') || ((c) == '\n') || ((c) == '+') ||		\
833089Swyllys 	((c) == '<') || ((c) == '>') || ((c) == '#') ||			\
843089Swyllys 	((c) == ';') || ((c) == C_BACKSLASH))
853089Swyllys 
863089Swyllys 
873089Swyllys #define	IS_PRINTABLE(c)							\
883089Swyllys 	((((c) >= 'a') && ((c) <= 'z')) ||				\
893089Swyllys 	(((c) >= 'A') && ((c) <= 'Z')) ||				\
903089Swyllys 	(((c) >= '0') && ((c) <= '9')) ||				\
913089Swyllys 	((c) == ' ') ||							\
923089Swyllys 	((c) == '\'') ||						\
933089Swyllys 	((c) == '\050') ||				/* ( */		\
943089Swyllys 	((c) == '\051') ||				/* ) */		\
953089Swyllys 	(((c) >= '+') && ((c) <= '/')) ||		/* + , - . / */	\
963089Swyllys 	((c) == ':') ||							\
973089Swyllys 	((c) == '=') ||							\
983089Swyllys 	((c) == '?'))
993089Swyllys 
1003089Swyllys 
1013089Swyllys #ifdef __cplusplus
1023089Swyllys }
1033089Swyllys #endif
1043089Swyllys #endif /* _RDN_PARSER_H */
105