2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * @defgroup signer signer
25 typedef enum integrity_algorithm_t integrity_algorithm_t
;
26 typedef struct signer_t signer_t
;
31 * Integrity algorithm, as in IKEv2 RFC 3.3.2.
33 * Algorithms not specified in IKEv2 are allocated in private use space.
35 enum integrity_algorithm_t
{
36 AUTH_UNDEFINED
= 1024,
37 /** Implemented via hmac_signer_t */
39 /** Implemented via hmac_signer_t */
40 AUTH_HMAC_SHA1_96
= 2,
44 /** RFC4595, used for IKEv1 or RADIUS */
45 AUTH_HMAC_MD5_128
= 6,
46 /** RFC4595, used for IKEv1 */
47 AUTH_HMAC_SHA1_160
= 7,
48 /** Implemented via hmac_signer_t */
49 AUTH_HMAC_SHA2_256_128
= 12,
50 /** Implemented via hmac_signer_t */
51 AUTH_HMAC_SHA2_384_192
= 13,
52 /** Implemented via hmac_signer_t */
53 AUTH_HMAC_SHA2_512_256
= 14,
54 /** Implemented via hmac_signer_t */
55 AUTH_HMAC_SHA1_128
= 1025,
59 * enum names for integrity_algorithm_t.
61 extern enum_name_t
*integrity_algorithm_names
;
64 * Generic interface for a symmetric signature algorithm.
68 * Generate a signature.
70 * If buffer is NULL, data is processed and prepended to a next call until
71 * buffer is a valid pointer.
73 * @param data a chunk containing the data to sign
74 * @param buffer pointer where the signature will be written
76 void (*get_signature
) (signer_t
*this, chunk_t data
, u_int8_t
*buffer
);
79 * Generate a signature and allocate space for it.
81 * If chunk is NULL, data is processed and prepended to a next call until
82 * chunk is a valid chunk pointer.
84 * @param data a chunk containing the data to sign
85 * @param chunk chunk which will hold the allocated signature
87 void (*allocate_signature
) (signer_t
*this, chunk_t data
, chunk_t
*chunk
);
92 * @param data a chunk containing the data to verify
93 * @param signature a chunk containing the signature
94 * @return TRUE, if signature is valid, FALSE otherwise
96 bool (*verify_signature
) (signer_t
*this, chunk_t data
, chunk_t signature
);
99 * Get the block size of this signature algorithm.
101 * @return block size in bytes
103 size_t (*get_block_size
) (signer_t
*this);
106 * Get the key size of the signature algorithm.
108 * @return key size in bytes
110 size_t (*get_key_size
) (signer_t
*this);
113 * Set the key for this object.
115 * @param key key to set
117 void (*set_key
) (signer_t
*this, chunk_t key
);
120 * Destroys a signer_t object.
122 void (*destroy
) (signer_t
*this);
125 #endif /** SIGNER_H_ @}*/