remove pem_encoder_encode
[strongswan.git] / src / libstrongswan / plugins / pem / pem_plugin.c
1 /*
2 * Copyright (C) 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 "pem_plugin.h"
17
18 #include <library.h>
19
20 #include "pem_builder.h"
21 #include "pem_encoder.h"
22
23 typedef struct private_pem_plugin_t private_pem_plugin_t;
24
25 /**
26 * private data of pem_plugin
27 */
28 struct private_pem_plugin_t {
29
30 /**
31 * public functions
32 */
33 pem_plugin_t public;
34 };
35
36 METHOD(plugin_t, get_name, char*,
37 private_pem_plugin_t *this)
38 {
39 return "pem";
40 }
41
42 METHOD(plugin_t, get_features, int,
43 private_pem_plugin_t *this, plugin_feature_t *features[])
44 {
45 static plugin_feature_t f[] = {
46 /* private key PEM decoding */
47 PLUGIN_REGISTER(PRIVKEY, pem_private_key_load, FALSE),
48 PLUGIN_PROVIDE(PRIVKEY, KEY_ANY),
49 PLUGIN_DEPENDS(HASHER, HASH_MD5),
50 PLUGIN_REGISTER(PRIVKEY, pem_private_key_load, FALSE),
51 PLUGIN_PROVIDE(PRIVKEY, KEY_RSA),
52 PLUGIN_DEPENDS(HASHER, HASH_MD5),
53 PLUGIN_REGISTER(PRIVKEY, pem_private_key_load, FALSE),
54 PLUGIN_PROVIDE(PRIVKEY, KEY_ECDSA),
55 PLUGIN_DEPENDS(HASHER, HASH_MD5),
56 PLUGIN_REGISTER(PRIVKEY, pem_private_key_load, FALSE),
57 PLUGIN_PROVIDE(PRIVKEY, KEY_DSA),
58 PLUGIN_DEPENDS(HASHER, HASH_MD5),
59
60 /* public key PEM decoding */
61 PLUGIN_REGISTER(PUBKEY, pem_public_key_load, FALSE),
62 PLUGIN_PROVIDE(PUBKEY, KEY_ANY),
63 PLUGIN_REGISTER(PUBKEY, pem_public_key_load, FALSE),
64 PLUGIN_PROVIDE(PUBKEY, KEY_RSA),
65 PLUGIN_REGISTER(PUBKEY, pem_public_key_load, FALSE),
66 PLUGIN_PROVIDE(PUBKEY, KEY_ECDSA),
67 PLUGIN_REGISTER(PUBKEY, pem_public_key_load, FALSE),
68 PLUGIN_PROVIDE(PUBKEY, KEY_DSA),
69
70 /* certificate PEM decoding */
71 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
72 PLUGIN_PROVIDE(CERT_DECODE, CERT_ANY),
73 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
74 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509),
75 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
76 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_CRL),
77 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
78 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_OCSP_REQUEST),
79 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
80 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_OCSP_RESPONSE),
81 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
82 PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_AC),
83 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
84 PLUGIN_PROVIDE(CERT_DECODE, CERT_PKCS10_REQUEST),
85 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
86 PLUGIN_PROVIDE(CERT_DECODE, CERT_TRUSTED_PUBKEY),
87 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
88 PLUGIN_PROVIDE(CERT_DECODE, CERT_GPG),
89
90 /* pluto specific certificate formats */
91 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
92 PLUGIN_PROVIDE(CERT_DECODE, CERT_PLUTO_CERT),
93 PLUGIN_REGISTER(CERT_DECODE, pem_certificate_load, FALSE),
94 PLUGIN_PROVIDE(CERT_DECODE, CERT_PLUTO_CRL),
95 };
96 *features = f;
97 return countof(f);
98 }
99 METHOD(plugin_t, destroy, void,
100 private_pem_plugin_t *this)
101 {
102 lib->encoding->remove_encoder(lib->encoding, pem_encoder_encode);
103
104 free(this);
105 }
106
107 /*
108 * see header file
109 */
110 plugin_t *pem_plugin_create()
111 {
112 private_pem_plugin_t *this;
113
114 INIT(this,
115 .public = {
116 .plugin = {
117 .get_name = _get_name,
118 .get_features = _get_features,
119 .destroy = _destroy,
120 },
121 },
122 );
123
124 /* register PEM encoder */
125 lib->encoding->add_encoder(lib->encoding, pem_encoder_encode);
126
127 return &this->public.plugin;
128 }
129