4 * @brief Implementation of message authentication
5 * using cryptographic hash functions (HMAC). See RFC2104.
10 * Copyright (C) 2005 Jan Hutter, Martin Willi
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 "hashers/hasher.h"
32 * Object representing a hmac
34 typedef struct hmac_s hmac_t
;
38 * @brief Generate message authentication code.
40 * @param this calling hmac
41 * @param data chunk of data to authenticate
42 * @param [out]buffer pointer where the generated bytes will be written
44 * - SUCCESS in any case
46 status_t (*get_mac
) (hmac_t
*this, chunk_t data
, u_int8_t
*buffer
);
49 * @brief Generates message authentication code and
50 * allocate space for them.
52 * @param this calling hmac
53 * @param data chunk of data to authenticate
54 * @param [out]chunk chunk which will hold generated bytes
56 * - SUCCESS in any case
57 * - OUT_OF_RES if space could not be allocated
59 status_t (*allocate_mac
) (hmac_t
*this, chunk_t data
, chunk_t
*chunk
);
62 * @brief get the block size of this hmac
64 * @param this calling hmac
65 * @return block size in bytes
67 size_t (*get_block_size
) (hmac_t
*this);
70 * @brief Destroys a hmac object.
72 * @param this hmac_t object to destroy
76 status_t (*destroy
) (hmac_t
*this);
80 * Creates a new hmac_t object
82 * @param hash_algorithm hash algorithm to use
83 * @param key A chunk containing the key
85 * - hmac_t if successfully
86 * - NULL if out of ressources or hash not supported
88 hmac_t
*hmac_create(hash_algorithm_t hash_algorithm
, chunk_t key
);