support of PKCS#10 certificate request parsing
[strongswan.git] / src / libstrongswan / plugins / x509 / x509_plugin.c
1 /*
2 * Copyright (C) 2008-2009 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 #include "x509_plugin.h"
17
18 #include <library.h>
19 #include "x509_cert.h"
20 #include "x509_ac.h"
21 #include "x509_crl.h"
22 #include "x509_ocsp_request.h"
23 #include "x509_ocsp_response.h"
24 #include "x509_pkcs10.h"
25
26 typedef struct private_x509_plugin_t private_x509_plugin_t;
27
28 /**
29 * private data of x509_plugin
30 */
31 struct private_x509_plugin_t {
32
33 /**
34 * public functions
35 */
36 x509_plugin_t public;
37 };
38
39 /**
40 * Implementation of x509_plugin_t.x509troy
41 */
42 static void destroy(private_x509_plugin_t *this)
43 {
44 lib->creds->remove_builder(lib->creds,
45 (builder_function_t)x509_cert_gen);
46 lib->creds->remove_builder(lib->creds,
47 (builder_function_t)x509_cert_load);
48 lib->creds->remove_builder(lib->creds,
49 (builder_function_t)x509_ac_gen);
50 lib->creds->remove_builder(lib->creds,
51 (builder_function_t)x509_ac_load);
52 lib->creds->remove_builder(lib->creds,
53 (builder_function_t)x509_crl_load);
54 lib->creds->remove_builder(lib->creds,
55 (builder_function_t)x509_ocsp_request_gen);
56 lib->creds->remove_builder(lib->creds,
57 (builder_function_t)x509_ocsp_response_load);
58 lib->creds->remove_builder(lib->creds,
59 (builder_function_t)x509_pkcs10_gen);
60 lib->creds->remove_builder(lib->creds,
61 (builder_function_t)x509_pkcs10_load);
62 free(this);
63 }
64
65 /*
66 * see header file
67 */
68 plugin_t *plugin_create()
69 {
70 private_x509_plugin_t *this = malloc_thing(private_x509_plugin_t);
71
72 this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
73
74 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509,
75 (builder_function_t)x509_cert_gen);
76 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509,
77 (builder_function_t)x509_cert_load);
78 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_AC,
79 (builder_function_t)x509_ac_gen);
80 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_AC,
81 (builder_function_t)x509_ac_load);
82 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_CRL,
83 (builder_function_t)x509_crl_load);
84 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_OCSP_REQUEST,
85 (builder_function_t)x509_ocsp_request_gen);
86 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_OCSP_RESPONSE,
87 (builder_function_t)x509_ocsp_response_load);
88 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_PKCS10_REQUEST,
89 (builder_function_t)x509_pkcs10_gen);
90 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_PKCS10_REQUEST,
91 (builder_function_t)x509_pkcs10_load);
92
93 return &this->public.plugin;
94 }
95