2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
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>.
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
20 * @defgroup crypter crypter
27 typedef enum encryption_algorithm_t encryption_algorithm_t
;
28 typedef struct crypter_t crypter_t
;
33 * Encryption algorithm, as in IKEv2 RFC 3.3.2.
35 enum encryption_algorithm_t
{
36 ENCR_UNDEFINED
= 1024,
49 ENCR_AES_CCM_ICV8
= 14,
50 ENCR_AES_CCM_ICV12
= 15,
51 ENCR_AES_CCM_ICV16
= 16,
52 ENCR_AES_GCM_ICV8
= 18,
53 ENCR_AES_GCM_ICV12
= 19,
54 ENCR_AES_GCM_ICV16
= 20,
55 ENCR_NULL_AUTH_AES_GMAC
= 21,
56 ENCR_CAMELLIA_CBC
= 23,
57 ENCR_CAMELLIA_CTR
= 24,
58 ENCR_CAMELLIA_CCM_ICV8
= 25,
59 ENCR_CAMELLIA_CCM_ICV12
= 26,
60 ENCR_CAMELLIA_CCM_ICV16
= 27,
65 * enum name for encryption_algorithm_t.
67 extern enum_name_t
*encryption_algorithm_names
;
70 * Generic interface for symmetric encryption algorithms.
75 * Encrypt a chunk of data and allocate space for the encrypted value.
77 * The length of the iv must equal to get_block_size(), while the length
78 * of data must be a multiple it.
79 * If encrypted is NULL, the encryption is done in-place (overwriting data).
81 * @param data data to encrypt
82 * @param iv initializing vector
83 * @param encrypted chunk to allocate encrypted data, or NULL
85 void (*encrypt
) (crypter_t
*this, chunk_t data
, chunk_t iv
,
89 * Decrypt a chunk of data and allocate space for the decrypted value.
91 * The length of the iv must equal to get_block_size(), while the length
92 * of data must be a multiple it.
93 * If decrpyted is NULL, the encryption is done in-place (overwriting data).
95 * @param data data to decrypt
96 * @param iv initializing vector
97 * @param encrypted chunk to allocate decrypted data, or NULL
99 void (*decrypt
) (crypter_t
*this, chunk_t data
, chunk_t iv
,
103 * Get the block size of the crypto algorithm.
105 * @return block size in bytes
107 size_t (*get_block_size
) (crypter_t
*this);
110 * Get the key size of the crypto algorithm.
112 * @return key size in bytes
114 size_t (*get_key_size
) (crypter_t
*this);
119 * The length of the key must match get_key_size().
121 * @param key key to set
123 void (*set_key
) (crypter_t
*this, chunk_t key
);
126 * Destroys a crypter_t object.
128 void (*destroy
) (crypter_t
*this);
131 #endif /** CRYPTER_H_ @}*/