]>
Commit | Line | Data |
---|---|---|
a4549e55 | 1 | /* |
f6083d35 | 2 | * Copyright (C) 2015 Tobias Brunner |
a4549e55 | 3 | * Copyright (C) 2015 Martin Willi |
19ef2aec TB |
4 | * |
5 | * Copyright (C) secunet Security Networks AG | |
a4549e55 MW |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2 of the License, or (at your | |
10 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | * for more details. | |
16 | */ | |
17 | ||
18 | #include "iv_gen.h" | |
19 | #include "iv_gen_rand.h" | |
20 | #include "iv_gen_seq.h" | |
f6083d35 | 21 | #include "iv_gen_null.h" |
a4549e55 MW |
22 | |
23 | /** | |
24 | * See header. | |
25 | */ | |
26 | iv_gen_t* iv_gen_create_for_alg(encryption_algorithm_t alg) | |
27 | { | |
28 | switch (alg) | |
29 | { | |
30 | case ENCR_DES: | |
31 | case ENCR_3DES: | |
32 | case ENCR_RC5: | |
33 | case ENCR_IDEA: | |
34 | case ENCR_CAST: | |
35 | case ENCR_BLOWFISH: | |
36 | case ENCR_3IDEA: | |
37 | case ENCR_AES_CBC: | |
38 | case ENCR_CAMELLIA_CBC: | |
39 | case ENCR_SERPENT_CBC: | |
40 | case ENCR_TWOFISH_CBC: | |
41 | case ENCR_RC2_CBC: | |
695a04d1 | 42 | case ENCR_AES_CFB: |
a4549e55 MW |
43 | return iv_gen_rand_create(); |
44 | case ENCR_AES_CTR: | |
45 | case ENCR_AES_CCM_ICV8: | |
46 | case ENCR_AES_CCM_ICV12: | |
47 | case ENCR_AES_CCM_ICV16: | |
48 | case ENCR_AES_GCM_ICV8: | |
49 | case ENCR_AES_GCM_ICV12: | |
50 | case ENCR_AES_GCM_ICV16: | |
51 | case ENCR_CAMELLIA_CTR: | |
52 | case ENCR_CAMELLIA_CCM_ICV8: | |
53 | case ENCR_CAMELLIA_CCM_ICV12: | |
54 | case ENCR_CAMELLIA_CCM_ICV16: | |
9e110cc5 | 55 | case ENCR_CHACHA20_POLY1305: |
a4549e55 MW |
56 | case ENCR_NULL_AUTH_AES_GMAC: |
57 | return iv_gen_seq_create(); | |
58 | case ENCR_NULL: | |
f6083d35 | 59 | return iv_gen_null_create(); |
a4549e55 MW |
60 | case ENCR_UNDEFINED: |
61 | case ENCR_DES_ECB: | |
62 | case ENCR_DES_IV32: | |
63 | case ENCR_DES_IV64: | |
20f3d04b | 64 | case ENCR_AES_ECB: |
a4549e55 MW |
65 | break; |
66 | } | |
67 | return NULL; | |
68 | } |