4 * @brief Interface for signer_t.
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 typedef enum integrity_algorithm_t integrity_algorithm_t
;
28 typedef struct signer_t signer_t
;
33 * @brief Integrity algorithm, as in IKEv2 RFC 3.3.2.
35 * Currently only the following algorithms are implemented and therefore supported:
41 enum integrity_algorithm_t
{
42 AUTH_UNDEFINED
= 1024,
43 /** Implemented via hmac_signer_t */
45 /** Implemented via hmac_signer_t */
46 AUTH_HMAC_SHA1_96
= 2,
53 * enum names for integrity_algorithm_t.
55 extern enum_name_t
*integrity_algorithm_names
;
58 * @brief Generig interface for a symmetric signature algorithm.
62 * - hmac_signer_create()
64 * @todo Implement more integrity algorithms
70 * @brief Generate a signature.
72 * @param this calling object
73 * @param data a chunk containing the data to sign
74 * @param[out] buffer pointer where the signature will be written
76 void (*get_signature
) (signer_t
*this, chunk_t data
, u_int8_t
*buffer
);
79 * @brief Generate a signature and allocate space for it.
81 * @param this calling object
82 * @param data a chunk containing the data to sign
83 * @param[out] chunk chunk which will hold the allocated signature
85 void (*allocate_signature
) (signer_t
*this, chunk_t data
, chunk_t
*chunk
);
88 * @brief Verify a signature.
90 * @param this calling object
91 * @param data a chunk containing the data to verify
92 * @param signature a chunk containing the signature
93 * @return TRUE, if signature is valid, FALSE otherwise
95 bool (*verify_signature
) (signer_t
*this, chunk_t data
, chunk_t signature
);
98 * @brief Get the block size of this signature algorithm.
100 * @param this calling object
101 * @return block size in bytes
103 size_t (*get_block_size
) (signer_t
*this);
106 * @brief Get the key size of the signature algorithm.
108 * @param this calling object
109 * @return key size in bytes
111 size_t (*get_key_size
) (signer_t
*this);
114 * @brief Set the key for this object.
116 * @param this calling object
117 * @param key key to set
119 void (*set_key
) (signer_t
*this, chunk_t key
);
122 * @brief Destroys a signer_t object.
124 * @param this calling object
126 void (*destroy
) (signer_t
*this);
130 * @brief Creates a new signer_t object.
132 * @param integrity_algorithm Algorithm to use for signing and verifying.
135 * - NULL if signer not supported
139 signer_t
*signer_create(integrity_algorithm_t integrity_algorithm
);