added support for 3DES encryption algorithm in IKE
[strongswan.git] / src / libstrongswan / crypto / crypters / crypter.c
1 /**
2 * @file crypter.c
3 *
4 * @brief Generic constructor for crypter_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24
25 #include "crypter.h"
26
27 #include <crypto/crypters/aes_cbc_crypter.h>
28 #include <crypto/crypters/des_crypter.h>
29
30
31 /**
32 * String mappings for encryption_algorithm_t.
33 */
34 mapping_t encryption_algorithm_m[] = {
35 {ENCR_UNDEFINED, "UNDEFINED"},
36 {ENCR_DES_IV64, "DES_IV64"},
37 {ENCR_DES, "DES"},
38 {ENCR_3DES, "3DES"},
39 {ENCR_RC5, "RC5"},
40 {ENCR_IDEA, "IDEA"},
41 {ENCR_CAST, "CAST"},
42 {ENCR_BLOWFISH, "BLOWFISH"},
43 {ENCR_3IDEA, "3IDEA"},
44 {ENCR_DES_IV32, "DES_IV32"},
45 {ENCR_NULL, "NULL"},
46 {ENCR_AES_CBC, "AES_CBC"},
47 {ENCR_AES_CTR, "AES_CTR"},
48 {MAPPING_END, NULL}
49 };
50
51 /*
52 * Described in header.
53 */
54 crypter_t *crypter_create(encryption_algorithm_t encryption_algorithm, size_t key_size)
55 {
56 switch (encryption_algorithm)
57 {
58 case ENCR_AES_CBC:
59 {
60 return (crypter_t*)aes_cbc_crypter_create(key_size);
61 }
62 case ENCR_DES:
63 case ENCR_3DES:
64 {
65 return (crypter_t*)des_crypter_create(encryption_algorithm);
66 }
67 default:
68 return NULL;
69 }
70 }