Implemented AES-CMAC based PRF and signer.
[strongswan.git] / src / libstrongswan / plugins / cmac / cmac.h
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup cmac cmac
18 * @{ @ingroup cmac_p
19 */
20
21 #ifndef CMAC_H_
22 #define CMAC_H_
23
24 #include <crypto/crypters/crypter.h>
25
26 typedef struct cmac_t cmac_t;
27
28 /**
29 * Cipher-based Message Authentication Code (CMAC).
30 *
31 * This class implements the message authentication algorithm
32 * described in RFC 4493.
33 */
34 struct cmac_t {
35
36 /**
37 * Generate message authentication code.
38 *
39 * If buffer is NULL, no result is given back. A next call will
40 * append the data to already supplied data. If buffer is not NULL,
41 * the mac of all apended data is calculated, returned and the internal
42 * state is reset.
43 *
44 * @param data chunk of data to authenticate
45 * @param buffer pointer where the generated bytes will be written
46 */
47 void (*get_mac) (cmac_t *this, chunk_t data, u_int8_t *buffer);
48
49 /**
50 * Get the block size of this cmac_t object.
51 *
52 * @return block size in bytes
53 */
54 size_t (*get_block_size) (cmac_t *this);
55
56 /**
57 * Set the key for this cmac_t object.
58 *
59 * @param key key to set
60 */
61 void (*set_key) (cmac_t *this, chunk_t key);
62
63 /**
64 * Destroys a cmac_t object.
65 */
66 void (*destroy) (cmac_t *this);
67 };
68
69 /**
70 * Creates a new cmac_t object.
71 *
72 * @param algo underlying crypto algorithm
73 * @param key_size key size to use, if required for algorithm
74 * @return cmac_t object, NULL if not supported
75 */
76 cmac_t *cmac_create(encryption_algorithm_t algo, size_t key_size);
77
78 #endif /** CMAC_H_ @}*/