ipsec pki --self|issue supports --pathlen option setting a path length constraint
[strongswan.git] / src / libstrongswan / credentials / builder.h
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 /**
17 * @defgroup builder builder
18 * @{ @ingroup credentials
19 */
20
21 #ifndef BUILDER_H_
22 #define BUILDER_H_
23
24 #include <stdarg.h>
25
26 typedef enum builder_part_t builder_part_t;
27
28 /**
29 * Constructor function to build credentials.
30 *
31 * Any added parts are cloned/refcounted by the builder implementation, a
32 * caller may need to free the passed ressources themself.
33 *
34 * @param subtype constructor specific subtype, e.g. a certificate_type_t
35 * @param args list of builder part types, followed by parts, BUILD_END
36 * @return builder specific credential, NULL on error
37 */
38 typedef void* (*builder_function_t)(int subtype, va_list args);
39
40 #include <library.h>
41
42 /**
43 * Parts to build credentials from.
44 */
45 enum builder_part_t {
46 /** path to a file encoded in any format, char* */
47 BUILD_FROM_FILE,
48 /** file descriptor to read data, encoded in any format, int */
49 BUILD_FROM_FD,
50 /** unix socket of a ssh/pgp agent, char* */
51 BUILD_AGENT_SOCKET,
52 /** DER encoded ASN.1 blob, chunk_t */
53 BUILD_BLOB_ASN1_DER,
54 /** PEM encoded ASN.1/PGP blob, chunk_t */
55 BUILD_BLOB_PEM,
56 /** OpenPGP key blob, chunk_t */
57 BUILD_BLOB_PGP,
58 /** DNS public key blob (RFC 4034, RSA specifc RFC 3110), chunk_t */
59 BUILD_BLOB_DNSKEY,
60 /** passphrase for e.g. PEM decryption, chunk_t */
61 BUILD_PASSPHRASE,
62 /** passphrase callback, chunk_t(*fn)(void *user, int try), void *user.
63 * The callback is invoked until the returned passphrase is accepted, or
64 * a zero-length passphrase is returned. Try starts at 1. */
65 BUILD_PASSPHRASE_CALLBACK,
66 /** key size in bits, as used for key generation, u_int */
67 BUILD_KEY_SIZE,
68 /** private key to use for signing, private_key_t* */
69 BUILD_SIGNING_KEY,
70 /** certificate used for signing, certificate_t* */
71 BUILD_SIGNING_CERT,
72 /** public key to include, public_key_t* */
73 BUILD_PUBLIC_KEY,
74 /** subject for e.g. certificates, identification_t* */
75 BUILD_SUBJECT,
76 /** additional subject names, linked_list_t* containing identification_t* */
77 BUILD_SUBJECT_ALTNAMES,
78 /** issuer for e.g. certificates, identification_t* */
79 BUILD_ISSUER,
80 /** additional issuer names, linked_list_t* containing identification_t* */
81 BUILD_ISSUER_ALTNAMES,
82 /** notBefore, time_t* */
83 BUILD_NOT_BEFORE_TIME,
84 /** notAfter, time_t* */
85 BUILD_NOT_AFTER_TIME,
86 /** a serial number in binary form, chunk_t */
87 BUILD_SERIAL,
88 /** digest algorithm to be used for signature, int */
89 BUILD_DIGEST_ALG,
90 /** a comma-separated list of ietf group attributes, char* */
91 BUILD_IETF_GROUP_ATTR,
92 /** a ca certificate, certificate_t* */
93 BUILD_CA_CERT,
94 /** a certificate, certificate_t* */
95 BUILD_CERT,
96 /** CRL distribution point URIs, linked_list_t* containing char* */
97 BUILD_CRL_DISTRIBUTION_POINTS,
98 /** OCSP AuthorityInfoAccess locations, linked_list_t* containing char* */
99 BUILD_OCSP_ACCESS_LOCATIONS,
100 /** certificate path length constraint */
101 BUILD_PATHLEN,
102 /** enforce an additional X509 flag, x509_flag_t */
103 BUILD_X509_FLAG,
104 /** key ID of a key on a smartcard, null terminated char* ([slot:]keyid) */
105 BUILD_SMARTCARD_KEYID,
106 /** pin to access a key on a smartcard, null terminated char* */
107 BUILD_SMARTCARD_PIN,
108 /** modulus (n) of a RSA key, chunk_t */
109 BUILD_RSA_MODULUS,
110 /** public exponent (e) of a RSA key, chunk_t */
111 BUILD_RSA_PUB_EXP,
112 /** private exponent (d) of a RSA key, chunk_t */
113 BUILD_RSA_PRIV_EXP,
114 /** prime 1 (p) of a RSA key (p < q), chunk_t */
115 BUILD_RSA_PRIME1,
116 /** prime 2 (q) of a RSA key (p < q), chunk_t */
117 BUILD_RSA_PRIME2,
118 /** exponent 1 (exp1) of a RSA key, chunk_t */
119 BUILD_RSA_EXP1,
120 /** exponent 2 (exp1) of a RSA key, chunk_t */
121 BUILD_RSA_EXP2,
122 /** coefficient (coeff) of a RSA key, chunk_t */
123 BUILD_RSA_COEFF,
124 /** end of variable argument builder list */
125 BUILD_END,
126 };
127
128 /**
129 * enum names for build_part_t
130 */
131 extern enum_name_t *builder_part_names;
132
133 #endif /** BUILDER_H_ @}*/