bfdec83caf2709c919e17a0ab2dd99cddcea0605
[strongswan.git] / src / libstrongswan / plugins / openssl / openssl_plugin.c
1 /*
2 * Copyright (C) 2008 Tobias Brunner
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 * $Id$
16 */
17
18 #include <openssl/evp.h>
19
20 #include "openssl_plugin.h"
21
22 #include <library.h>
23 #include "openssl_crypter.h"
24
25 typedef struct private_openssl_plugin_t private_openssl_plugin_t;
26
27 /**
28 * private data of openssl_plugin
29 */
30 struct private_openssl_plugin_t {
31
32 /**
33 * public functions
34 */
35 openssl_plugin_t public;
36 };
37
38 /**
39 * Implementation of openssl_plugin_t.destroy
40 */
41 static void destroy(private_openssl_plugin_t *this)
42 {
43 lib->crypto->remove_crypter(lib->crypto,
44 (crypter_constructor_t)openssl_crypter_create);
45
46 EVP_cleanup();
47
48 free(this);
49 }
50
51 /*
52 * see header file
53 */
54 plugin_t *plugin_create()
55 {
56 private_openssl_plugin_t *this = malloc_thing(private_openssl_plugin_t);
57
58 this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
59
60 OpenSSL_add_all_algorithms();
61
62 lib->crypto->add_crypter(lib->crypto, ENCR_DES,
63 (crypter_constructor_t)openssl_crypter_create);
64 lib->crypto->add_crypter(lib->crypto, ENCR_3DES,
65 (crypter_constructor_t)openssl_crypter_create);
66 lib->crypto->add_crypter(lib->crypto, ENCR_RC5,
67 (crypter_constructor_t)openssl_crypter_create);
68 lib->crypto->add_crypter(lib->crypto, ENCR_IDEA,
69 (crypter_constructor_t)openssl_crypter_create);
70 lib->crypto->add_crypter(lib->crypto, ENCR_CAST,
71 (crypter_constructor_t)openssl_crypter_create);
72 lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH,
73 (crypter_constructor_t)openssl_crypter_create);
74 lib->crypto->add_crypter(lib->crypto, ENCR_NULL,
75 (crypter_constructor_t)openssl_crypter_create);
76 lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
77 (crypter_constructor_t)openssl_crypter_create);
78
79 return &this->public.plugin;
80 }