/*********************************************************************
* Filename:   sha256.h
* Author:     Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details:    Defines the API for the corresponding SHA1 implementation.
*********************************************************************/

#ifndef SHA256_H
#define SHA256_H

/*************************** HEADER FILES ***************************/
#include <stddef.h>

/****************************** MACROS ******************************/
#define SHA256_BLOCK_SIZE 32            // SHA256 outputs a 32 byte digest
#define SHA256_BUFFER 80
#define SHA256_HASH_SIZE (256 / 8)

/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE;             // 8-bit byte
typedef unsigned int  HINT32;             // 32-bit word, change to "long" for 16-bit machines

typedef struct {
	BYTE data[64];
	HINT32 datalen;
	//unsigned long long bitlen;
	unsigned __int64 bitlen;
	HINT32 state[8];
} SHA256_CTX;

/*********************** FUNCTION DECLARATIONS **********************/
void sha256_init(SHA256_CTX *ctx);
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len);
void sha256_final(BYTE hash[], SHA256_CTX *ctx);

//POSTING
//gen a password & message-id and pass to sha_lock, returns pointer to cancel-lock
char * sha_lock(char *secret, int seclen,  char *message, int msglen);

//CANCELING
//use message-id of art to be cancelled, and password, returns cancel-key
char * sha_key( char *secret, int seclen,  char *message, int msglen);

//verify - use cancel-key header from cancel msg, and cancel-lock header
int sha_verify( char *key,  char *lock);


#endif   // SHA256_H
