- definition of interface for singer and crypter
[strongswan.git] / Source / charon / transforms / crypters / crypter.h
1 /**
2 * @file crypter.h
3 *
4 * @brief Generic interface for encryption algorithms
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
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>.
16 *
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
20 * for more details.
21 */
22
23 #ifndef CRYPTER_H_
24 #define CRYPTER_H_
25
26 #include "../../payloads/transform_substructure.h"
27
28
29 /**
30 * Object representing a crypter object
31 */
32 typedef struct crypter_s crypter_t;
33
34 struct crypter_s {
35 /**
36 * @brief Encrypt a chunk of data and allocate space for
37 * the encrypted value.
38 *
39 * @param this calling crypter
40 * @param data data to encrypt
41 * @param [out]encrypted pointer where the encrypted bytes will be written
42 * @return
43 * - SUCCESS in any case
44 */
45 status_t (*encrypt) (crypter_t *this, chunk_t data, chunk_t *encrypted);
46
47 /**
48 * @brief Decrypt a chunk of data and allocate space for
49 * the decrypted value.
50 *
51 * @param this calling crypter
52 * @param data data to decrypt
53 * @param [out]encrypted pointer where the decrypted bytes will be written
54 * @return
55 * - SUCCESS in any case
56 */
57 status_t (*decrypt) (crypter_t *this, chunk_t data, chunk_t *decrypted);
58
59 /**
60 * @brief get the block size of this crypter
61 *
62 * @param this calling crypter
63 * @return block size in bytes
64 */
65 size_t (*get_block_size) (crypter_t *this);
66
67 /**
68 * @brief Set the key for this crypter
69 *
70 * @param this calling crypter
71 * @return block size in bytes
72 */
73 status_t (*set_key) (crypter_t *this, chunk_t key);
74
75 /**
76 * @brief Destroys a crypter object.
77 *
78 * @param this crypter_t object to destroy
79 * @return
80 * SUCCESS in any case
81 */
82 status_t (*destroy) (crypter_t *this);
83 };
84
85 /**
86 * Creates a new crypter_t object
87 *
88 * @param pseudo_random_function Algorithm to use
89 * @return
90 * - crypter_t if successfully
91 * - NULL if out of ressources or crypter not supported
92 */
93 crypter_t *crypter_create(encryption_algorithm_t encryption_algorithm);
94
95 #endif /*CRYPTER_H_*/