]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libstrongswan/crypto/mac.h
50dc4c73a34aaea121d14e39e3d8203a4039265f
2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2005-2008 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
5 * HSR Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 typedef struct mac_t mac_t
;
31 * Generic interface for message authentication codes.
33 * Classes implementing this interface can use the PRF and signer wrappers.
38 * Generate message authentication code.
40 * If out is NULL, no result is given back. A next call will
41 * append the data to already supplied data. If out is not NULL,
42 * the mac of all apended data is calculated, written to out and the
43 * internal state is reset.
45 * @param data chunk of data to authenticate
46 * @param out pointer where the generated bytes will be written
47 * @return TRUE if mac generated successfully
49 bool (*get_mac
)(mac_t
*this, chunk_t data
,
50 uint8_t *out
) __attribute__((warn_unused_result
));
53 * Get the size of the resulting MAC.
55 * @return block size in bytes
57 size_t (*get_mac_size
)(mac_t
*this);
60 * Set the key to be used for the MAC.
62 * Any key length must be accepted.
64 * @param key key to set
65 * @return TRUE if key set successfully
67 bool (*set_key
)(mac_t
*this,
68 chunk_t key
) __attribute__((warn_unused_result
));
71 * Destroys a mac_t object.
73 void (*destroy
) (mac_t
*this);
76 #endif /** MAC_H_ @}*/