199ebb4caSwyllys /* 299ebb4caSwyllys * CDDL HEADER START 399ebb4caSwyllys * 499ebb4caSwyllys * The contents of this file are subject to the terms of the 599ebb4caSwyllys * Common Development and Distribution License (the "License"). 699ebb4caSwyllys * You may not use this file except in compliance with the License. 799ebb4caSwyllys * 899ebb4caSwyllys * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 999ebb4caSwyllys * or http://www.opensolaris.org/os/licensing. 1099ebb4caSwyllys * See the License for the specific language governing permissions 1199ebb4caSwyllys * and limitations under the License. 1299ebb4caSwyllys * 1399ebb4caSwyllys * When distributing Covered Code, include this CDDL HEADER in each 1499ebb4caSwyllys * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1599ebb4caSwyllys * If applicable, add the following below this CDDL HEADER, with the 1699ebb4caSwyllys * fields enclosed by brackets "[]" replaced with your own identifying 1799ebb4caSwyllys * information: Portions Copyright [yyyy] [name of copyright owner] 1899ebb4caSwyllys * 1999ebb4caSwyllys * CDDL HEADER END 2099ebb4caSwyllys * 21*269e59f9SJan Pechanec * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 2299ebb4caSwyllys */ 2399ebb4caSwyllys #ifndef _KMFPOLICY_H 2499ebb4caSwyllys #define _KMFPOLICY_H 2599ebb4caSwyllys 2699ebb4caSwyllys #include <kmfapi.h> 27*269e59f9SJan Pechanec #include <kmfmapper.h> 2899ebb4caSwyllys #include <libxml/tree.h> 2999ebb4caSwyllys #include <libxml/parser.h> 3099ebb4caSwyllys 3199ebb4caSwyllys #ifdef __cplusplus 3299ebb4caSwyllys extern "C" { 3399ebb4caSwyllys #endif 3499ebb4caSwyllys 3599ebb4caSwyllys typedef struct { 3699ebb4caSwyllys char *name; 3799ebb4caSwyllys char *serial; 3899ebb4caSwyllys }KMF_RESP_CERT_POLICY; 3999ebb4caSwyllys 4099ebb4caSwyllys typedef struct { 4199ebb4caSwyllys char *responderURI; 4299ebb4caSwyllys char *proxy; 4399ebb4caSwyllys boolean_t uri_from_cert; 4499ebb4caSwyllys char *response_lifetime; 4599ebb4caSwyllys boolean_t ignore_response_sign; 4699ebb4caSwyllys }KMF_OCSP_BASIC_POLICY; 4799ebb4caSwyllys 4899ebb4caSwyllys typedef struct { 4999ebb4caSwyllys KMF_OCSP_BASIC_POLICY basic; 5099ebb4caSwyllys KMF_RESP_CERT_POLICY resp_cert; 5199ebb4caSwyllys boolean_t has_resp_cert; 5299ebb4caSwyllys }KMF_OCSP_POLICY; 5399ebb4caSwyllys 5499ebb4caSwyllys typedef struct { 5599ebb4caSwyllys char *basefilename; 5699ebb4caSwyllys char *directory; 5799ebb4caSwyllys char *proxy; 5899ebb4caSwyllys boolean_t get_crl_uri; 5999ebb4caSwyllys boolean_t ignore_crl_sign; 6099ebb4caSwyllys boolean_t ignore_crl_date; 6199ebb4caSwyllys }KMF_CRL_POLICY; 6299ebb4caSwyllys 6399ebb4caSwyllys typedef struct { 6499ebb4caSwyllys KMF_OCSP_POLICY ocsp_info; 6599ebb4caSwyllys KMF_CRL_POLICY crl_info; 6699ebb4caSwyllys }KMF_VALIDATION_POLICY; 6799ebb4caSwyllys 6899ebb4caSwyllys typedef struct { 6999ebb4caSwyllys int eku_count; 7099ebb4caSwyllys KMF_OID *ekulist; 7199ebb4caSwyllys }KMF_EKU_POLICY; 7299ebb4caSwyllys 7399ebb4caSwyllys #define KMF_REVOCATION_METHOD_CRL 0x1 7499ebb4caSwyllys #define KMF_REVOCATION_METHOD_OCSP 0x2 7599ebb4caSwyllys 7699ebb4caSwyllys typedef struct { 7799ebb4caSwyllys char *name; 7899ebb4caSwyllys KMF_VALIDATION_POLICY validation_info; 7999ebb4caSwyllys KMF_EKU_POLICY eku_set; 80*269e59f9SJan Pechanec KMF_MAPPER_RECORD mapper; /* kmfmapper.h */ 8199ebb4caSwyllys uint32_t ku_bits; 8299ebb4caSwyllys boolean_t ignore_date; 8399ebb4caSwyllys boolean_t ignore_unknown_ekus; 8499ebb4caSwyllys boolean_t ignore_trust_anchor; 8599ebb4caSwyllys char *validity_adjusttime; 8699ebb4caSwyllys char *ta_name; 8799ebb4caSwyllys char *ta_serial; 8899ebb4caSwyllys uint32_t revocation; 8999ebb4caSwyllys } KMF_POLICY_RECORD; 9099ebb4caSwyllys 9199ebb4caSwyllys 9299ebb4caSwyllys /* 9399ebb4caSwyllys * Short cut for ocsp_info and etc. 9499ebb4caSwyllys */ 9599ebb4caSwyllys #define VAL_OCSP validation_info.ocsp_info 9699ebb4caSwyllys 9799ebb4caSwyllys #define VAL_OCSP_BASIC VAL_OCSP.basic 9899ebb4caSwyllys #define VAL_OCSP_RESPONDER_URI VAL_OCSP_BASIC.responderURI 9999ebb4caSwyllys #define VAL_OCSP_PROXY VAL_OCSP_BASIC.proxy 10099ebb4caSwyllys #define VAL_OCSP_URI_FROM_CERT VAL_OCSP_BASIC.uri_from_cert 10199ebb4caSwyllys #define VAL_OCSP_RESP_LIFETIME VAL_OCSP_BASIC.response_lifetime 10299ebb4caSwyllys #define VAL_OCSP_IGNORE_RESP_SIGN VAL_OCSP_BASIC.ignore_response_sign 10399ebb4caSwyllys 10499ebb4caSwyllys #define VAL_OCSP_RESP_CERT VAL_OCSP.resp_cert 10599ebb4caSwyllys #define VAL_OCSP_RESP_CERT_NAME VAL_OCSP_RESP_CERT.name 10699ebb4caSwyllys #define VAL_OCSP_RESP_CERT_SERIAL VAL_OCSP_RESP_CERT.serial 10799ebb4caSwyllys 10899ebb4caSwyllys /* 10999ebb4caSwyllys * Short cut for crl_info and etc. 11099ebb4caSwyllys */ 11199ebb4caSwyllys #define VAL_CRL validation_info.crl_info 11299ebb4caSwyllys #define VAL_CRL_BASEFILENAME validation_info.crl_info.basefilename 11399ebb4caSwyllys #define VAL_CRL_DIRECTORY validation_info.crl_info.directory 11499ebb4caSwyllys #define VAL_CRL_GET_URI validation_info.crl_info.get_crl_uri 11599ebb4caSwyllys #define VAL_CRL_PROXY validation_info.crl_info.proxy 11699ebb4caSwyllys #define VAL_CRL_IGNORE_SIGN validation_info.crl_info.ignore_crl_sign 11799ebb4caSwyllys #define VAL_CRL_IGNORE_DATE validation_info.crl_info.ignore_crl_date 11899ebb4caSwyllys 11999ebb4caSwyllys /* 12099ebb4caSwyllys * Policy related constant definitions. 12199ebb4caSwyllys */ 12299ebb4caSwyllys #define KMF_POLICY_DTD "/usr/share/lib/xml/dtd/kmfpolicy.dtd" 12399ebb4caSwyllys #define KMF_DEFAULT_POLICY_FILE "/etc/security/kmfpolicy.xml" 12499ebb4caSwyllys 12599ebb4caSwyllys #define KMF_DEFAULT_POLICY_NAME "default" 12699ebb4caSwyllys 12799ebb4caSwyllys #define KMF_POLICY_ROOT "kmf-policy-db" 12899ebb4caSwyllys 12999ebb4caSwyllys #define KULOWBIT 7 13099ebb4caSwyllys #define KUHIGHBIT 15 13199ebb4caSwyllys 13299ebb4caSwyllys #define KMF_POLICY_ELEMENT "kmf-policy" 13399ebb4caSwyllys #define KMF_POLICY_NAME_ATTR "name" 13499ebb4caSwyllys #define KMF_OPTIONS_IGNORE_DATE_ATTR "ignore-date" 13599ebb4caSwyllys #define KMF_OPTIONS_IGNORE_UNKNOWN_EKUS "ignore-unknown-eku" 13699ebb4caSwyllys #define KMF_OPTIONS_IGNORE_TRUST_ANCHOR "ignore-trust-anchor" 13799ebb4caSwyllys #define KMF_OPTIONS_VALIDITY_ADJUSTTIME "validity-adjusttime" 13899ebb4caSwyllys #define KMF_POLICY_TA_NAME_ATTR "ta-name" 13999ebb4caSwyllys #define KMF_POLICY_TA_SERIAL_ATTR "ta-serial" 14099ebb4caSwyllys 14199ebb4caSwyllys #define KMF_VALIDATION_METHODS_ELEMENT "validation-methods" 14299ebb4caSwyllys 14399ebb4caSwyllys #define KMF_OCSP_ELEMENT "ocsp" 14499ebb4caSwyllys #define KMF_OCSP_BASIC_ELEMENT "ocsp-basic" 14599ebb4caSwyllys #define KMF_OCSP_RESPONDER_ATTR "responder" 14699ebb4caSwyllys #define KMF_OCSP_PROXY_ATTR "proxy" 14799ebb4caSwyllys #define KMF_OCSP_URI_ATTR "uri-from-cert" 14899ebb4caSwyllys #define KMF_OCSP_RESPONSE_LIFETIME_ATTR "response-lifetime" 14999ebb4caSwyllys #define KMF_OCSP_IGNORE_SIGN_ATTR "ignore-response-sign" 15099ebb4caSwyllys #define KMF_OCSP_RESPONDER_CERT_ELEMENT "responder-cert" 15199ebb4caSwyllys 15299ebb4caSwyllys #define KMF_CERT_NAME_ATTR "name" 15399ebb4caSwyllys #define KMF_CERT_SERIAL_ATTR "serial" 15499ebb4caSwyllys 15599ebb4caSwyllys #define KMF_CRL_ELEMENT "crl" 15699ebb4caSwyllys #define KMF_CRL_BASENAME_ATTR "basefilename" 15799ebb4caSwyllys #define KMF_CRL_DIRECTORY_ATTR "directory" 15899ebb4caSwyllys #define KMF_CRL_GET_URI_ATTR "get-crl-uri" 15999ebb4caSwyllys #define KMF_CRL_PROXY_ATTR "proxy" 16099ebb4caSwyllys #define KMF_CRL_IGNORE_SIGN_ATTR "ignore-crl-sign" 16199ebb4caSwyllys #define KMF_CRL_IGNORE_DATE_ATTR "ignore-crl-date" 16299ebb4caSwyllys 16399ebb4caSwyllys #define KMF_KEY_USAGE_SET_ELEMENT "key-usage-set" 16499ebb4caSwyllys #define KMF_KEY_USAGE_ELEMENT "key-usage" 16599ebb4caSwyllys #define KMF_KEY_USAGE_USE_ATTR "use" 16699ebb4caSwyllys 16799ebb4caSwyllys #define KMF_EKU_ELEMENT "ext-key-usage" 16899ebb4caSwyllys #define KMF_EKU_NAME_ELEMENT "eku-name" 16999ebb4caSwyllys #define KMF_EKU_NAME_ATTR "name" 17099ebb4caSwyllys #define KMF_EKU_OID_ELEMENT "eku-oid" 17199ebb4caSwyllys #define KMF_EKU_OID_ATTR "oid" 17299ebb4caSwyllys 173*269e59f9SJan Pechanec #define KMF_CERT_MAPPER_ELEMENT "cert-to-name-mapping" 174*269e59f9SJan Pechanec #define KMF_CERT_MAPPER_NAME_ATTR "mapper-name" 175*269e59f9SJan Pechanec #define KMF_CERT_MAPPER_DIR_ATTR "mapper-directory" 176*269e59f9SJan Pechanec #define KMF_CERT_MAPPER_PATH_ATTR "mapper-pathname" 177*269e59f9SJan Pechanec #define KMF_CERT_MAPPER_OPTIONS_ATTR "mapper-options" 178*269e59f9SJan Pechanec 17999ebb4caSwyllys #define TMPFILE_TEMPLATE "policyXXXXXX" 18099ebb4caSwyllys 18199ebb4caSwyllys extern int parsePolicyElement(xmlNodePtr, KMF_POLICY_RECORD *); 18299ebb4caSwyllys 18330a5e8faSwyllys extern KMF_RETURN kmf_get_policy(char *, char *, KMF_POLICY_RECORD *); 18430a5e8faSwyllys extern KMF_RETURN kmf_add_policy_to_db(KMF_POLICY_RECORD *, char *, boolean_t); 18530a5e8faSwyllys extern KMF_RETURN kmf_delete_policy_from_db(char *, char *); 18630a5e8faSwyllys extern KMF_RETURN kmf_verify_policy(KMF_POLICY_RECORD *); 18799ebb4caSwyllys 18830a5e8faSwyllys extern void kmf_free_policy_record(KMF_POLICY_RECORD *); 18930a5e8faSwyllys extern void kmf_free_eku_policy(KMF_EKU_POLICY *); 19099ebb4caSwyllys 19199ebb4caSwyllys #ifdef __cplusplus 19299ebb4caSwyllys } 19399ebb4caSwyllys #endif 19499ebb4caSwyllys #endif /* _KMFPOLICY_H */ 195