42
42
#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig)
43
43
#define HMAC_close(ctx)
44
44
#elif defined(USE_GNUTLS)
45
#include <gnutls/gnutls.h>
45
#include <nettle/hmac.h>
47
46
#ifndef SHA256_DIGEST_LENGTH
48
47
#define SHA256_DIGEST_LENGTH 32
50
#define HMAC_CTX gcry_md_hd_t
51
#define HMAC_setup(ctx, key, len) gcry_md_open(&ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC); gcry_md_setkey(ctx, key, len)
52
#define HMAC_crunch(ctx, buf, len) gcry_md_write(ctx, buf, len)
53
#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen)
54
#define HMAC_close(ctx) gcry_md_close(ctx)
50
#define HMAC_CTX struct hmac_sha256_ctx
51
#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(&ctx, len, key)
52
#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(&ctx, len, buf)
53
#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig)
54
#define HMAC_close(ctx)
55
55
#else /* USE_OPENSSL */
56
56
#include <openssl/ssl.h>
57
57
#include <openssl/sha.h>