4 * @brief Interface of crypter_t
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 typedef enum encryption_algorithm_t encryption_algorithm_t
;
31 * @brief Encryption algorithm, as in IKEv2 draft 3.3.2
33 enum encryption_algorithm_t
{
34 ENCR_UNDEFINED
= 1024,
51 * string mappings for encryption_algorithm_t
53 extern mapping_t encryption_algorithm_m
[];
55 typedef struct crypter_t crypter_t
;
58 * @brief Generic interface for symmetric encryption algorithms.
64 * @brief Encrypt a chunk of data and allocate space for
65 * the encrypted value.
67 * @param this calling crypter
68 * @param data data to encrypt
69 * @param [out]encrypted pointer where the encrypted bytes will be written
71 * - SUCCESS in any case
73 status_t (*encrypt
) (crypter_t
*this, chunk_t data
, chunk_t
*encrypted
);
76 * @brief Decrypt a chunk of data and allocate space for
77 * the decrypted value.
79 * @param this calling crypter
80 * @param data data to decrypt
81 * @param [out]encrypted pointer where the decrypted bytes will be written
83 * - SUCCESS in any case
85 status_t (*decrypt
) (crypter_t
*this, chunk_t data
, chunk_t
*decrypted
);
88 * @brief get the block size of this crypter
90 * @param this calling crypter
91 * @return block size in bytes
93 size_t (*get_block_size
) (crypter_t
*this);
96 * @brief Set the key for this crypter
98 * @param this calling crypter
99 * @param key key to set
101 * - SUCCESS in any case
103 status_t (*set_key
) (crypter_t
*this, chunk_t key
);
106 * @brief Destroys a crypter_t object.
108 * @param this crypter_t object to destroy
110 * - SUCCESS in any case
112 status_t (*destroy
) (crypter_t
*this);
116 * @brief Generic constructor for crypter_t objects.
118 * @param encryption_algorithm Algorithm to use for crypter
120 * - crypter_t if successfully
121 * - NULL if out of ressources or crypter not supported
123 crypter_t
*crypter_create(encryption_algorithm_t encryption_algorithm
);
125 #endif /*CRYPTER_H_*/