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
28 #include <definitions.h>
30 typedef enum integrity_algorithm_t integrity_algorithm_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 * String mappings for integrity_algorithm_t.
55 extern mapping_t integrity_algorithm_m
[];
58 typedef struct signer_t signer_t
;
61 * @brief Generig interface for a symmetric signature algorithm.
65 * - hmac_signer_create()
67 * @todo Implement more integrity algorithms
73 * @brief Generate a signature.
75 * @param this calling object
76 * @param data a chunk containing the data to sign
77 * @param[out] buffer pointer where the signature will be written
79 void (*get_signature
) (signer_t
*this, chunk_t data
, u_int8_t
*buffer
);
82 * @brief Generate a signature and allocate space for it.
84 * @param this calling object
85 * @param data a chunk containing the data to sign
86 * @param[out] chunk chunk which will hold the allocated signature
88 void (*allocate_signature
) (signer_t
*this, chunk_t data
, chunk_t
*chunk
);
91 * @brief Verify a signature.
93 * @param this calling object
94 * @param data a chunk containing the data to verify
95 * @param signature a chunk containing the signature
96 * @return TRUE, if signature is valid, FALSE otherwise
98 bool (*verify_signature
) (signer_t
*this, chunk_t data
, chunk_t signature
);
101 * @brief Get the block size of this signature algorithm.
103 * @param this calling object
104 * @return block size in bytes
106 size_t (*get_block_size
) (signer_t
*this);
109 * @brief Get the key size of the signature algorithm.
111 * @param this calling object
112 * @return key size in bytes
114 size_t (*get_key_size
) (signer_t
*this);
117 * @brief Set the key for this object.
119 * @param this calling object
120 * @param key key to set
122 void (*set_key
) (signer_t
*this, chunk_t key
);
125 * @brief Destroys a signer_t object.
127 * @param this calling object
129 void (*destroy
) (signer_t
*this);
133 * @brief Creates a new signer_t object.
135 * @param integrity_algorithm Algorithm to use for signing and verifying.
138 * - NULL if signer not supported
142 signer_t
*signer_create(integrity_algorithm_t integrity_algorithm
);