#ifndef SHA_H
#define SHA_H

typedef unsigned int uint32;

#define SHA_BFSZ 1024

typedef struct {
    uint32 state[5];
    uint32 count[2];
    unsigned char buffer[64];
} lutil_SHA1_CTX;

#ifdef HAS_SYS_TYPES
#include <sys/types.h>
#else
#ifdef WIN32
typedef	unsigned int u_int;
typedef	unsigned char u_char;
#endif
#endif


/*Secure Hashing Algorithm SAM created by Tam Willacy, 14 March 2001
 * Most code is adapted from OpenLDAP source
 */
int create_ssha_base64_digest(char *passwd,char *ret,int ret_sz);
	/*if returns 1, has filled given buffer with the given password 
	digested using SSHA and then base64 encoded.  SSHA is basically SHA with salt.*/

int create_sha_base64_digest(char *passwd,char *ret,int ret_sz); 
	/*if returns 1, has filled given buffer with the given 
	password digested using SHA and then base64 encoded*/

char *get_sha_error(void);/*get error string, not greater than 400 
	chars, and first half is details rather than error. So can call 
	when no error*/

int raw_create_ssha(char *passwd,char *ret,int ret_sz, char *old_salt);
int create_sha_digest(char *cred, int cred_len, char *digest);
int ssha_test(void);
void lutil_SHA1Init(lutil_SHA1_CTX *context);
void lutil_SHA1Update(lutil_SHA1_CTX *context, const unsigned char *data, u_int len);
void lutil_SHA1Final(unsigned char digest[20], lutil_SHA1_CTX *context);
void hmac_sha(char *k, int lk, char *d, int ld, char *out, int *outsz) ;
#endif
