#include "hmacbuf"

#include <string>
#include <openssl/hmac.h>
#include <ostream>

#include <bobcat/exception>
#include "../ohexstreambuf/ohexstreambuf"

#if  OPENSSL_VERSION_NUMBER < 0x10100000L

inline HMAC_CTX *HMAC_CTX_new()
{
    return new HMAC_CTX;
}
    
inline int HMAC_CTX_reset(HMAC_CTX *ctx)
{
    HMAC_CTX_init(ctx);
    return 1;
}

inline void HMAC_CTX_free(HMAC_CTX *ctx)
{
    HMAC_CTX_cleanup(ctx);
    delete ctx;
}
   
#endif


namespace FBB
{

struct HMacBufImp
{
    HMAC_CTX     *ctx;
    EVP_MD const *md;
    std::string   digest;
    char         *buffer;
    size_t        bufsize;
    std::string   key;

    HMacBufImp(std::string const &key, size_t bufsize);
    ~HMacBufImp();                                      // destructor.f
};

#include "destructor.f"

} // FBB

using namespace std;
using namespace FBB;
