2 * Copyright (C) 2007-2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * @{ @ingroup certificates
24 #include <collections/enumerator.h>
25 #include <credentials/certificates/certificate.h>
27 /* constraints are currently restricted to the range 0..127 */
28 #define X509_NO_CONSTRAINT 255
30 typedef struct x509_t x509_t
;
31 typedef struct x509_cert_policy_t x509_cert_policy_t
;
32 typedef struct x509_policy_mapping_t x509_policy_mapping_t
;
33 typedef struct x509_cdp_t x509_cdp_t
;
34 typedef enum x509_flag_t x509_flag_t
;
35 typedef enum x509_constraint_t x509_constraint_t
;
38 * X.509 certificate flags.
41 /** cert has no constraints */
43 /** cert has CA constraint */
45 /** cert has AA constraint */
47 /** cert has OCSP signer constraint */
48 X509_OCSP_SIGNER
= (1<<2),
49 /** cert has serverAuth key usage */
50 X509_SERVER_AUTH
= (1<<3),
51 /** cert has clientAuth key usage */
52 X509_CLIENT_AUTH
= (1<<4),
53 /** cert is self-signed */
54 X509_SELF_SIGNED
= (1<<5),
55 /** cert has an ipAddrBlocks extension */
56 X509_IP_ADDR_BLOCKS
= (1<<6),
57 /** cert has CRL sign key usage */
58 X509_CRL_SIGN
= (1<<7),
59 /** cert has iKEIntermediate key usage */
60 X509_IKE_INTERMEDIATE
= (1<<8),
61 /** cert has Microsoft Smartcard Logon usage */
62 X509_MS_SMARTCARD_LOGON
= (1<<9),
66 * Different numerical X.509 constraints.
68 enum x509_constraint_t
{
69 /** pathLenConstraint basicConstraints */
71 /** inhibitPolicyMapping policyConstraint */
72 X509_INHIBIT_POLICY_MAPPING
,
73 /** requireExplicitPolicy policyConstraint */
74 X509_REQUIRE_EXPLICIT_POLICY
,
75 /** inhibitAnyPolicy constraint */
76 X509_INHIBIT_ANY_POLICY
,
80 * X.509 certPolicy extension.
82 struct x509_cert_policy_t
{
83 /** Certification Practice Statement URI qualifier */
85 /** UserNotice Text qualifier */
87 /** OID of certPolicy */
92 * X.509 policyMapping extension
94 struct x509_policy_mapping_t
{
95 /** OID of issuerDomainPolicy */
97 /** OID of subjectDomainPolicy */
102 * X.509 CRL distributionPoint
105 /** CDP URI, as string */
108 identification_t
*issuer
;
112 * X.509 certificate interface.
114 * This interface adds additional methods to the certificate_t type to
115 * allow further operations on these certificates.
120 * Implements certificate_t.
122 certificate_t interface
;
125 * Get the flags set for this certificate.
127 * @return set of flags
129 x509_flag_t (*get_flags
)(x509_t
*this);
132 * Get the certificate serial number.
134 * @return chunk pointing to internal serial number
136 chunk_t (*get_serial
)(x509_t
*this);
139 * Get the the subjectKeyIdentifier.
141 * @return subjectKeyIdentifier as chunk_t, internal data
143 chunk_t (*get_subjectKeyIdentifier
)(x509_t
*this);
146 * Get the the authorityKeyIdentifier.
148 * @return authKeyIdentifier as chunk_t, internal data
150 chunk_t (*get_authKeyIdentifier
)(x509_t
*this);
153 * Get a numerical X.509 constraint.
155 * @param type type of constraint to get
156 * @return constraint, X509_NO_CONSTRAINT if none found
158 u_int (*get_constraint
)(x509_t
*this, x509_constraint_t type
);
161 * Create an enumerator over all subjectAltNames.
163 * @return enumerator over subjectAltNames as identification_t*
165 enumerator_t
* (*create_subjectAltName_enumerator
)(x509_t
*this);
168 * Create an enumerator over all CRL URIs and CRL Issuers.
170 * @return enumerator over x509_cdp_t
172 enumerator_t
* (*create_crl_uri_enumerator
)(x509_t
*this);
175 * Create an enumerator over all OCSP URIs.
177 * @return enumerator over URIs as char*
179 enumerator_t
* (*create_ocsp_uri_enumerator
)(x509_t
*this);
182 * Create an enumerator over all ipAddrBlocks.
184 * @return enumerator over ipAddrBlocks as traffic_selector_t*
186 enumerator_t
* (*create_ipAddrBlock_enumerator
)(x509_t
*this);
189 * Create an enumerator over name constraints.
191 * @param perm TRUE for permitted, FALSE for excluded subtrees
192 * @return enumerator over subtrees as identification_t
194 enumerator_t
* (*create_name_constraint_enumerator
)(x509_t
*this, bool perm
);
197 * Create an enumerator over certificate policies.
199 * @return enumerator over x509_cert_policy_t
201 enumerator_t
* (*create_cert_policy_enumerator
)(x509_t
*this);
204 * Create an enumerator over policy mappings.
206 * @return enumerator over x509_policy_mapping
208 enumerator_t
* (*create_policy_mapping_enumerator
)(x509_t
*this);
213 #endif /** X509_H_ @}*/