diff options
Diffstat (limited to 'Source/charon/transforms/crypters')
-rw-r--r-- | Source/charon/transforms/crypters/crypter.c | 45 | ||||
-rw-r--r-- | Source/charon/transforms/crypters/crypter.h | 58 |
2 files changed, 89 insertions, 14 deletions
diff --git a/Source/charon/transforms/crypters/crypter.c b/Source/charon/transforms/crypters/crypter.c index e69de29bb..79a02cf02 100644 --- a/Source/charon/transforms/crypters/crypter.c +++ b/Source/charon/transforms/crypters/crypter.c @@ -0,0 +1,45 @@ +/** + * @file crypter.c + * + * @brief Generic constructor for crypter_t. + * + */ + +/* + * Copyright (C) 2005 Jan Hutter, Martin Willi + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + + +#include "crypter.h" + + +/** + * string mappings for encryption_algorithm_t + */ +mapping_t encryption_algorithm_m[] = { +{ENCR_UNDEFINED, "ENCR_UNDEFINED"}, +{ENCR_DES_IV64, "ENCR_DES_IV64"}, +{ENCR_DES, "ENCR_DES"}, +{ENCR_3DES, "ENCR_3DES"}, +{ENCR_RC5, "ENCR_RC5"}, +{ENCR_IDEA, "ENCR_IDEA"}, +{ENCR_CAST, "ENCR_CAST"}, +{ENCR_BLOWFISH, "ENCR_BLOWFISH"}, +{ENCR_3IDEA, "ENCR_3IDEA"}, +{ENCR_DES_IV32, "ENCR_DES_IV32"}, +{ENCR_NULL, "ENCR_NULL"}, +{ENCR_AES_CBC, "ENCR_AES_CBC"}, +{ENCR_AES_CTR, "ENCR_AES_CTR"}, +{MAPPING_END, NULL} +}; diff --git a/Source/charon/transforms/crypters/crypter.h b/Source/charon/transforms/crypters/crypter.h index 3d5a6869b..f9de213c4 100644 --- a/Source/charon/transforms/crypters/crypter.h +++ b/Source/charon/transforms/crypters/crypter.h @@ -1,7 +1,7 @@ /** * @file crypter.h * - * @brief Generic interface for encryption algorithms + * @brief Interface of crypter_t * */ @@ -23,13 +23,41 @@ #ifndef CRYPTER_H_ #define CRYPTER_H_ -#include <encoding/payloads/transform_substructure.h> +#include <types.h> +typedef enum encryption_algorithm_t encryption_algorithm_t; + +/** + * @brief Encryption algorithm, as in IKEv2 draft 3.3.2 + */ +enum encryption_algorithm_t { + ENCR_UNDEFINED = 1024, + ENCR_DES_IV64 = 1, + ENCR_DES = 2, + ENCR_3DES = 3, + ENCR_RC5 = 4, + ENCR_IDEA = 5, + ENCR_CAST = 6, + ENCR_BLOWFISH = 7, + ENCR_3IDEA = 8, + ENCR_DES_IV32 = 9, + RESERVED = 10, + ENCR_NULL = 11, + ENCR_AES_CBC = 12, + ENCR_AES_CTR = 13 +}; + +/** + * string mappings for encryption_algorithm_t + */ +extern mapping_t encryption_algorithm_m[]; typedef struct crypter_t crypter_t; /** - * Object representing a crypter object + * @brief Generic interface for symmetric encryption algorithms. + * + * @ingroup crypters */ struct crypter_t { /** @@ -59,36 +87,38 @@ struct crypter_t { /** * @brief get the block size of this crypter * - * @param this calling crypter - * @return block size in bytes + * @param this calling crypter + * @return block size in bytes */ size_t (*get_block_size) (crypter_t *this); /** * @brief Set the key for this crypter * - * @param this calling crypter - * @return block size in bytes + * @param this calling crypter + * @param key key to set + * @return + * - SUCCESS in any case */ status_t (*set_key) (crypter_t *this, chunk_t key); /** - * @brief Destroys a crypter object. + * @brief Destroys a crypter_t object. * - * @param this crypter_t object to destroy + * @param this crypter_t object to destroy * @return - * SUCCESS in any case + * - SUCCESS in any case */ status_t (*destroy) (crypter_t *this); }; /** - * Creates a new crypter_t object + * @brief Generic constructor for crypter_t objects. * - * @param pseudo_random_function Algorithm to use + * @param encryption_algorithm Algorithm to use for crypter * @return - * - crypter_t if successfully - * - NULL if out of ressources or crypter not supported + * - crypter_t if successfully + * - NULL if out of ressources or crypter not supported */ crypter_t *crypter_create(encryption_algorithm_t encryption_algorithm); |