- definition of interface for singer and crypter
[strongswan.git] / Source / charon / transforms / signers / signer.h
1 /**
2 * @file signer.h
3 *
4 * @brief Generic interface for integrity 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 SIGNER_H_
24 #define SIGNER_H_
25
26 #include "../../payloads/transform_substructure.h"
27
28
29 /**
30 * Object representing a diffie hellman exchange
31 */
32 typedef struct signer_s signer_t;
33
34 struct signer_s {
35 /**
36 * @brief generates pseudo random bytes and writes them
37 * in the buffer
38 *
39 * @param this calling signer
40 * @param seed a chunk containing the seed for the next bytes
41 * @param [out]buffer pointer where the generated bytes will be written
42 * @return
43 * - SUCCESS in any case
44 */
45 status_t (*get_signature) (signer_t *this, chunk_t data, u_int8_t *buffer);
46
47 /**
48 * @brief generates pseudo random bytes and allocate space for them
49 *
50 * @param this calling signer
51 * @param seed a chunk containing the seed for the next bytes
52 * @param [out]chunk chunk which will hold generated bytes
53 * @return
54 * - SUCCESS in any case
55 * - OUT_OF_RES if space could not be allocated
56 */
57 status_t (*allocate_signature) (signer_t *this, chunk_t data, chunk_t *chunk);
58
59 /**
60 * @brief generates pseudo random bytes and writes them
61 * in the buffer
62 *
63 * @param this calling signer
64 * @param seed a chunk containing the seed for the next bytes
65 * @param [out]buffer pointer where the generated bytes will be written
66 * @return
67 * - SUCCESS in any case
68 */
69 status_t (*verify_signature) (signer_t *this, chunk_t data, chunk_t signature, bool *valid);
70
71 /**
72 * @brief get the block size of this signer
73 *
74 * @param this calling signer
75 * @return block size in bytes
76 */
77 size_t (*get_block_size) (signer_t *this);
78
79 /**
80 * @brief Set the key for this signer
81 *
82 * @param this calling signer
83 * @return block size in bytes
84 */
85 status_t (*set_key) (signer_t *this, chunk_t key);
86
87 /**
88 * @brief Destroys a signer object.
89 *
90 * @param this signer_t object to destroy
91 * @return
92 * SUCCESS in any case
93 */
94 status_t (*destroy) (signer_t *this);
95 };
96
97 /**
98 * Creates a new signer_t object
99 *
100 * @param pseudo_random_function Algorithm to use
101 * @return
102 * - signer_t if successfully
103 * - NULL if out of ressources or signer not supported
104 */
105 signer_t *signer_create(integrity_algorithm_t integrity_algorithm);
106
107 #endif /*SIGNER_H_*/