]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libstrongswan/plugins/x509/x509_plugin.c
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libstrongswan / plugins / x509 / x509_plugin.c
1 /*
2 * Copyright (C) 2008-2009 Martin Willi
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 #include "x509_plugin.h"
18
19 #include <library.h>
20 #include "x509_cert.h"
21 #include "x509_ac.h"
22 #include "x509_crl.h"
23 #include "x509_ocsp_request.h"
24 #include "x509_ocsp_response.h"
25 #include "x509_pkcs10.h"
26
27 typedef struct private_x509_plugin_t private_x509_plugin_t;
28
29 /**
30 * private data of x509_plugin
31 */
32 struct private_x509_plugin_t {
33
34 /**
35 * public functions
36 */
37 x509_plugin_t public;
38 };
39
40 METHOD(plugin_t, get_name, char*,
41 private_x509_plugin_t *this)
42 {
43 return "x509";
44 }
45
46 METHOD(plugin_t, get_features, int,
47 private_x509_plugin_t *this, plugin_feature_t *features[])
48 {
49 static plugin_feature_t f[] = {
50 PLUGIN_REGISTER(CERT_ENCODE, x509_cert_gen, FALSE),
51 PLUGIN_PROVIDE(CERT_ENCODE, CERT_X509),
52 PLUGIN_DEPENDS(HASHER, HASH_SHA1),
53 PLUGIN_REGISTER(CERT_DECODE, x509_cert_load, TRUE),
54 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509),
55 PLUGIN_DEPENDS(HASHER, HASH_SHA1),
56 PLUGIN_DEPENDS(PUBKEY, KEY_ANY),
57
58 PLUGIN_REGISTER(CERT_ENCODE, x509_ac_gen, FALSE),
59 PLUGIN_PROVIDE(CERT_ENCODE, CERT_X509_AC),
60 PLUGIN_REGISTER(CERT_DECODE, x509_ac_load, TRUE),
61 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_AC),
62
63 PLUGIN_REGISTER(CERT_ENCODE, x509_crl_gen, FALSE),
64 PLUGIN_PROVIDE(CERT_ENCODE, CERT_X509_CRL),
65 PLUGIN_REGISTER(CERT_DECODE, x509_crl_load, TRUE),
66 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_CRL),
67
68 PLUGIN_REGISTER(CERT_ENCODE, x509_ocsp_request_gen, FALSE),
69 PLUGIN_PROVIDE(CERT_ENCODE, CERT_X509_OCSP_REQUEST),
70 PLUGIN_DEPENDS(HASHER, HASH_SHA1),
71 PLUGIN_DEPENDS(RNG, RNG_WEAK),
72 PLUGIN_REGISTER(CERT_DECODE, x509_ocsp_response_load, TRUE),
73 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_OCSP_RESPONSE),
74
75 PLUGIN_REGISTER(CERT_ENCODE, x509_pkcs10_gen, FALSE),
76 PLUGIN_PROVIDE(CERT_ENCODE, CERT_PKCS10_REQUEST),
77 PLUGIN_REGISTER(CERT_DECODE, x509_pkcs10_load, TRUE),
78 PLUGIN_PROVIDE(CERT_DECODE, CERT_PKCS10_REQUEST),
79 };
80 *features = f;
81 return countof(f);
82 }
83
84 METHOD(plugin_t, destroy, void,
85 private_x509_plugin_t *this)
86 {
87 free(this);
88 }
89
90 /*
91 * see header file
92 */
93 plugin_t *x509_plugin_create()
94 {
95 private_x509_plugin_t *this;
96
97 INIT(this,
98 .public = {
99 .plugin = {
100 .get_name = _get_name,
101 .get_features = _get_features,
102 .destroy = _destroy,
103 },
104 },
105 );
106
107 return &this->public.plugin;
108 }
109