xref: /onnv-gate/usr/src/lib/libkmf/include/kmfpolicy.h (revision 5051:cbbb7c8b40a9)
13089Swyllys /*
23089Swyllys  * CDDL HEADER START
33089Swyllys  *
43089Swyllys  * The contents of this file are subject to the terms of the
53089Swyllys  * Common Development and Distribution License (the "License").
63089Swyllys  * You may not use this file except in compliance with the License.
73089Swyllys  *
83089Swyllys  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93089Swyllys  * or http://www.opensolaris.org/os/licensing.
103089Swyllys  * See the License for the specific language governing permissions
113089Swyllys  * and limitations under the License.
123089Swyllys  *
133089Swyllys  * When distributing Covered Code, include this CDDL HEADER in each
143089Swyllys  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153089Swyllys  * If applicable, add the following below this CDDL HEADER, with the
163089Swyllys  * fields enclosed by brackets "[]" replaced with your own identifying
173089Swyllys  * information: Portions Copyright [yyyy] [name of copyright owner]
183089Swyllys  *
193089Swyllys  * CDDL HEADER END
203089Swyllys  *
21*5051Swyllys  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
223089Swyllys  * Use is subject to license terms.
233089Swyllys  */
243089Swyllys #ifndef _KMFPOLICY_H
253089Swyllys #define	_KMFPOLICY_H
263089Swyllys 
273089Swyllys #pragma ident	"%Z%%M%	%I%	%E% SMI"
283089Swyllys 
293089Swyllys #include <kmfapi.h>
303089Swyllys #include <libxml/tree.h>
313089Swyllys #include <libxml/parser.h>
323089Swyllys 
333089Swyllys #ifdef __cplusplus
343089Swyllys extern "C" {
353089Swyllys #endif
363089Swyllys 
373089Swyllys typedef struct {
383089Swyllys 	char		*name;
393089Swyllys 	char		*serial;
403089Swyllys }KMF_RESP_CERT_POLICY;
413089Swyllys 
423089Swyllys typedef struct {
433089Swyllys 	char		*responderURI;
443089Swyllys 	char		*proxy;
453089Swyllys 	boolean_t 	uri_from_cert;
463089Swyllys 	char		*response_lifetime;
473089Swyllys 	boolean_t	ignore_response_sign;
483089Swyllys }KMF_OCSP_BASIC_POLICY;
493089Swyllys 
503089Swyllys typedef struct {
513089Swyllys 	KMF_OCSP_BASIC_POLICY	basic;
523089Swyllys 	KMF_RESP_CERT_POLICY	resp_cert;
533089Swyllys 	boolean_t		has_resp_cert;
543089Swyllys }KMF_OCSP_POLICY;
553089Swyllys 
563089Swyllys typedef struct {
573089Swyllys 	char *basefilename;
583089Swyllys 	char *directory;
593089Swyllys 	char *proxy;
603089Swyllys 	boolean_t get_crl_uri;
613089Swyllys 	boolean_t ignore_crl_sign;
623089Swyllys 	boolean_t ignore_crl_date;
633089Swyllys }KMF_CRL_POLICY;
643089Swyllys 
653089Swyllys typedef struct {
663089Swyllys 	KMF_OCSP_POLICY	ocsp_info;
673089Swyllys 	KMF_CRL_POLICY	crl_info;
683089Swyllys }KMF_VALIDATION_POLICY;
693089Swyllys 
703089Swyllys typedef struct {
713089Swyllys 	int		eku_count;
723089Swyllys 	KMF_OID		*ekulist;
733089Swyllys }KMF_EKU_POLICY;
743089Swyllys 
753089Swyllys 
763089Swyllys #define	KMF_REVOCATION_METHOD_CRL		0x1
773089Swyllys #define	KMF_REVOCATION_METHOD_OCSP		0x2
783089Swyllys 
793089Swyllys 
803089Swyllys typedef struct {
813089Swyllys 	char			*name;
823089Swyllys 	KMF_VALIDATION_POLICY	validation_info;
833089Swyllys 	KMF_EKU_POLICY		eku_set;
843089Swyllys 	uint32_t		ku_bits;
853089Swyllys 	boolean_t		ignore_date;
863089Swyllys 	boolean_t		ignore_unknown_ekus;
873089Swyllys 	boolean_t		ignore_trust_anchor;
883089Swyllys 	char			*validity_adjusttime;
893089Swyllys 	char			*ta_name;
903089Swyllys 	char			*ta_serial;
913089Swyllys 	uint32_t		revocation;
923089Swyllys } KMF_POLICY_RECORD;
933089Swyllys 
943089Swyllys 
953089Swyllys /*
963089Swyllys  * Short cut for ocsp_info and etc.
973089Swyllys  */
983089Swyllys #define	VAL_OCSP			validation_info.ocsp_info
993089Swyllys 
1003089Swyllys #define	VAL_OCSP_BASIC			VAL_OCSP.basic
1013089Swyllys #define	VAL_OCSP_RESPONDER_URI		VAL_OCSP_BASIC.responderURI
1023089Swyllys #define	VAL_OCSP_PROXY			VAL_OCSP_BASIC.proxy
1033089Swyllys #define	VAL_OCSP_URI_FROM_CERT		VAL_OCSP_BASIC.uri_from_cert
1043089Swyllys #define	VAL_OCSP_RESP_LIFETIME		VAL_OCSP_BASIC.response_lifetime
1053089Swyllys #define	VAL_OCSP_IGNORE_RESP_SIGN	VAL_OCSP_BASIC.ignore_response_sign
1063089Swyllys 
1073089Swyllys #define	VAL_OCSP_RESP_CERT		VAL_OCSP.resp_cert
1083089Swyllys #define	VAL_OCSP_RESP_CERT_NAME		VAL_OCSP_RESP_CERT.name
1093089Swyllys #define	VAL_OCSP_RESP_CERT_SERIAL	VAL_OCSP_RESP_CERT.serial
1103089Swyllys 
1113089Swyllys /*
1123089Swyllys  * Short cut for crl_info and etc.
1133089Swyllys  */
1143089Swyllys #define	VAL_CRL			validation_info.crl_info
1153089Swyllys #define	VAL_CRL_BASEFILENAME	validation_info.crl_info.basefilename
1163089Swyllys #define	VAL_CRL_DIRECTORY	validation_info.crl_info.directory
1173089Swyllys #define	VAL_CRL_GET_URI		validation_info.crl_info.get_crl_uri
1183089Swyllys #define	VAL_CRL_PROXY		validation_info.crl_info.proxy
1193089Swyllys #define	VAL_CRL_IGNORE_SIGN	validation_info.crl_info.ignore_crl_sign
1203089Swyllys #define	VAL_CRL_IGNORE_DATE	validation_info.crl_info.ignore_crl_date
1213089Swyllys 
1223089Swyllys /*
1233089Swyllys  * Policy related constant definitions.
1243089Swyllys  */
1253089Swyllys #define	KMF_POLICY_DTD		"/usr/share/lib/xml/dtd/kmfpolicy.dtd"
1263089Swyllys #define	KMF_DEFAULT_POLICY_FILE	"/etc/security/kmfpolicy.xml"
1273089Swyllys 
1283089Swyllys #define	KMF_DEFAULT_POLICY_NAME	"default"
1293089Swyllys 
1303089Swyllys #define	KMF_POLICY_ROOT	"kmf-policy-db"
1313089Swyllys 
1323089Swyllys #define	KULOWBIT	7
1333089Swyllys #define	KUHIGHBIT	15
1343089Swyllys 
1353089Swyllys #define	KMF_POLICY_ELEMENT		"kmf-policy"
1363089Swyllys #define	KMF_POLICY_NAME_ATTR		"name"
1373089Swyllys #define	KMF_OPTIONS_IGNORE_DATE_ATTR	"ignore-date"
1383089Swyllys #define	KMF_OPTIONS_IGNORE_UNKNOWN_EKUS	"ignore-unknown-eku"
1393089Swyllys #define	KMF_OPTIONS_IGNORE_TRUST_ANCHOR	"ignore-trust-anchor"
1403089Swyllys #define	KMF_OPTIONS_VALIDITY_ADJUSTTIME	"validity-adjusttime"
1413089Swyllys #define	KMF_POLICY_TA_NAME_ATTR		"ta-name"
1423089Swyllys #define	KMF_POLICY_TA_SERIAL_ATTR	"ta-serial"
1433089Swyllys 
1443089Swyllys #define	KMF_VALIDATION_METHODS_ELEMENT	"validation-methods"
1453089Swyllys 
1463089Swyllys #define	KMF_OCSP_ELEMENT		"ocsp"
1473089Swyllys #define	KMF_OCSP_BASIC_ELEMENT		"ocsp-basic"
1483089Swyllys #define	KMF_OCSP_RESPONDER_ATTR		"responder"
1493089Swyllys #define	KMF_OCSP_PROXY_ATTR		"proxy"
1503089Swyllys #define	KMF_OCSP_URI_ATTR		"uri-from-cert"
1513089Swyllys #define	KMF_OCSP_RESPONSE_LIFETIME_ATTR	"response-lifetime"
1523089Swyllys #define	KMF_OCSP_IGNORE_SIGN_ATTR	"ignore-response-sign"
1533089Swyllys #define	KMF_OCSP_RESPONDER_CERT_ELEMENT	"responder-cert"
1543089Swyllys 
1553089Swyllys #define	KMF_CERT_NAME_ATTR		"name"
1563089Swyllys #define	KMF_CERT_SERIAL_ATTR		"serial"
1573089Swyllys 
1583089Swyllys #define	KMF_CRL_ELEMENT			"crl"
1593089Swyllys #define	KMF_CRL_BASENAME_ATTR		"basefilename"
1603089Swyllys #define	KMF_CRL_DIRECTORY_ATTR		"directory"
1613089Swyllys #define	KMF_CRL_GET_URI_ATTR		"get-crl-uri"
1623089Swyllys #define	KMF_CRL_PROXY_ATTR		"proxy"
1633089Swyllys #define	KMF_CRL_IGNORE_SIGN_ATTR	"ignore-crl-sign"
1643089Swyllys #define	KMF_CRL_IGNORE_DATE_ATTR	"ignore-crl-date"
1653089Swyllys 
1663089Swyllys #define	KMF_KEY_USAGE_SET_ELEMENT	"key-usage-set"
1673089Swyllys #define	KMF_KEY_USAGE_ELEMENT		"key-usage"
1683089Swyllys #define	KMF_KEY_USAGE_USE_ATTR		"use"
1693089Swyllys 
1703089Swyllys #define	KMF_EKU_ELEMENT		"ext-key-usage"
1713089Swyllys #define	KMF_EKU_NAME_ELEMENT	"eku-name"
1723089Swyllys #define	KMF_EKU_NAME_ATTR	"name"
1733089Swyllys #define	KMF_EKU_OID_ELEMENT	"eku-oid"
1743089Swyllys #define	KMF_EKU_OID_ATTR	"oid"
1753089Swyllys 
1763089Swyllys #define	TMPFILE_TEMPLATE	"policyXXXXXX"
1773089Swyllys 
1783089Swyllys extern int parsePolicyElement(xmlNodePtr, KMF_POLICY_RECORD *);
1793089Swyllys 
180*5051Swyllys extern char *kmf_oid_to_eku_string(KMF_OID *);
181*5051Swyllys extern KMF_OID *kmf_ekuname_to_oid(char *);
1823089Swyllys 
183*5051Swyllys extern KMF_RETURN kmf_get_policy(char *, char *, KMF_POLICY_RECORD *);
184*5051Swyllys extern KMF_RETURN kmf_add_policy_to_db(KMF_POLICY_RECORD *, char *, boolean_t);
185*5051Swyllys extern KMF_RETURN kmf_delete_policy_from_db(char *, char *);
186*5051Swyllys extern KMF_RETURN kmf_verify_policy(KMF_POLICY_RECORD *);
1873089Swyllys 
188*5051Swyllys extern void kmf_free_policy_record(KMF_POLICY_RECORD *);
189*5051Swyllys extern void kmf_free_eku_policy(KMF_EKU_POLICY *);
1903089Swyllys 
1913089Swyllys #ifdef __cplusplus
1923089Swyllys }
1933089Swyllys #endif
1943089Swyllys #endif /* _KMFPOLICY_H */
195