/****************************************************************************/
/*	Copyright (c) 2009, Bendor Research Pty. Ltd. All rights reserved.		*/
/*	This software is released under the GNU General Public License, version	*/
/*	3, with the exemptions that 1) the header files installed by this 	 	*/
/*	package can be included in closed-source code and 2) the libraries		*/
/*	built by this package can be statically linked into a closed-source 	*/
/*	binary. See the file LICENSE for the details.							*/
/*	This software is provided "AS IS", without any warranty or guarantee.	*/
/*	By using this software you acknowledge that neither Bendor Research nor	*/
/*	any of its personnel or affiliates can be held liable for any damages,	*/
/*	including, but not limited to, loss of business, loss of money, loss of */
/*	life, loss or reputation, arising out of this software being faulty or	*/
/*	not performing as advertised, even if Bendor Research was aware of such	*/
/*	faults in the software. You use this software at your own risk, any and */
/*	all liabilities that arise out of your using this software are strictly	*/
/*	yours.																	*/
/****************************************************************************/

#ifndef _BC_HASH_H
#define	_BC_HASH_H

#define	BC_HASH_MAX			(5)						// Max. no. of state words
#define	BC_HASH_MD5			(&_bc_hash_md5)			// Use MD5
#define	BC_HASH_MD5_FAST	(&_bc_hash_md5_fast)	// Use fast MD5
#define	BC_HASH_SHA1		(&_bc_hash_sha1)		// Use SHA-1
#define	BC_HASH_SHA1_FAST	(&_bc_hash_sha1_fast)	// Use fast SHA-1

/** @addtogroup hash */
/** @{ */

/**
*	Hash state descriptor object.
*/

typedef struct bc_hash_s {

	unsigned long long	n;					// Number of bits processed
	struct bc_hfun_s	*f;					// Opaque descriptor
	unsigned int		s[ BC_HASH_MAX ];	// The hash state variables
	unsigned int		d[ 16 ];			// Data buffer

} BC_HASH;

/**
*	HMAC state descriptor object.
*/

typedef struct {

	BC_HASH		hash;					// The hash state
	unsigned	opad[ BC_HASH_MAX ];	// Output pad

} BC_HMAC;

/** @} */

void	BC_HmacInit( BC_HMAC *hmac, const struct bc_hfun_s *func,
					 const void *kptr, unsigned int klen );
void	BC_HmacData( BC_HMAC *hmac, const void *data, unsigned dlen );
void	BC_HmacDone( const BC_HMAC *hmac, void *data );

void	BC_HashInit( BC_HASH *hash, const struct bc_hfun_s *func );
void	BC_HashData( BC_HASH *hash, const void *data, unsigned dlen );
void	BC_HashDone( const BC_HASH *hash, void *data );

extern const struct bc_hfun_s	_bc_hash_md5;
extern const struct bc_hfun_s	_bc_hash_md5_fast;
extern const struct bc_hfun_s	_bc_hash_sha1;
extern const struct bc_hfun_s	_bc_hash_sha1_fast;


#endif

