File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libstrongswan / crypto / mac.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Jun 3 09:46:44 2020 UTC (4 years, 2 months ago) by misho
Branches: strongswan, MAIN
CVS tags: v5_9_2p0, v5_8_4p7, HEAD
Strongswan

    1: /*
    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
    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: /**
   19:  * @defgroup mac mac
   20:  * @{ @ingroup crypto
   21:  */
   22: 
   23: #ifndef MAC_H_
   24: #define MAC_H_
   25: 
   26: typedef struct mac_t mac_t;
   27: 
   28: #include <library.h>
   29: 
   30: /**
   31:  * Generic interface for message authentication codes.
   32:  *
   33:  * Classes implementing this interface can use the PRF and signer wrappers.
   34:  */
   35: struct mac_t {
   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,
   42: 	 * the MAC of all appended data is calculated, written to out and the
   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
   47: 	 * @return			TRUE if MAC generated successfully
   48: 	 */
   49: 	bool (*get_mac)(mac_t *this, chunk_t data,
   50: 					uint8_t *out) __attribute__((warn_unused_result));
   51: 
   52: 	/**
   53: 	 * Get the size of the resulting MAC.
   54: 	 *
   55: 	 * @return			block size in bytes
   56: 	 */
   57: 	size_t (*get_mac_size)(mac_t *this);
   58: 
   59: 	/**
   60: 	 * Set the key to be used for the MAC.
   61: 	 *
   62: 	 * Any key length must be accepted.
   63: 	 *
   64: 	 * @param key		key to set
   65: 	 * @return			TRUE if key set successfully
   66: 	 */
   67: 	bool (*set_key)(mac_t *this,
   68: 					chunk_t key) __attribute__((warn_unused_result));
   69: 
   70: 	/**
   71: 	 * Destroys a mac_t object.
   72: 	 */
   73: 	void (*destroy) (mac_t *this);
   74: };
   75: 
   76: #endif /** MAC_H_ @}*/

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>