]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/libstrongswan/crypto/mac.h
Fixed some typos, courtesy of codespell
[thirdparty/strongswan.git] / src / libstrongswan / crypto / mac.h
CommitLineData
57ff4be8
TB
1/*
2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2005-2008 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
1b671669 5 * HSR Hochschule fuer Technik Rapperswil
57ff4be8
TB
6 *
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>.
11 *
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
15 * for more details.
16 */
17
18/**
c4a3c967 19 * @defgroup mac mac
57ff4be8
TB
20 * @{ @ingroup crypto
21 */
22
c4a3c967
TB
23#ifndef MAC_H_
24#define MAC_H_
57ff4be8 25
c4a3c967 26typedef struct mac_t mac_t;
57ff4be8
TB
27
28#include <library.h>
29
30/**
c4a3c967 31 * Generic interface for message authentication codes.
57ff4be8
TB
32 *
33 * Classes implementing this interface can use the PRF and signer wrappers.
34 */
c4a3c967 35struct mac_t {
57ff4be8
TB
36
37 /**
38 * Generate message authentication code.
39 *
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,
db82c0f5 42 * the MAC of all appended data is calculated, written to out and the
57ff4be8
TB
43 * internal state is reset.
44 *
45 * @param data chunk of data to authenticate
46 * @param out pointer where the generated bytes will be written
db82c0f5 47 * @return TRUE if MAC generated successfully
57ff4be8 48 */
3b891b9e 49 bool (*get_mac)(mac_t *this, chunk_t data,
b12c53ce 50 uint8_t *out) __attribute__((warn_unused_result));
57ff4be8
TB
51
52 /**
c4a3c967 53 * Get the size of the resulting MAC.
57ff4be8
TB
54 *
55 * @return block size in bytes
56 */
c4a3c967 57 size_t (*get_mac_size)(mac_t *this);
57ff4be8
TB
58
59 /**
c4a3c967 60 * Set the key to be used for the MAC.
57ff4be8
TB
61 *
62 * Any key length must be accepted.
63 *
64 * @param key key to set
6ac8d861 65 * @return TRUE if key set successfully
57ff4be8 66 */
3b891b9e
TB
67 bool (*set_key)(mac_t *this,
68 chunk_t key) __attribute__((warn_unused_result));
57ff4be8
TB
69
70 /**
c4a3c967 71 * Destroys a mac_t object.
57ff4be8 72 */
c4a3c967 73 void (*destroy) (mac_t *this);
57ff4be8
TB
74};
75
c4a3c967 76#endif /** MAC_H_ @}*/