24 #include <openssl/err.h>
25 #include <openssl/hmac.h>
44 #ifdef HAVE_HMAC_CTX_NEW
45 #define ALLOC(size) MemoryContextAlloc(TopMemoryContext, size)
47 #define ALLOC(size) palloc(size)
49 #define FREE(ptr) pfree(ptr)
51 #define ALLOC(size) malloc(size)
52 #define FREE(ptr) free(ptr)
86 return ERR_reason_error_string(ecode);
116 #ifdef HAVE_HMAC_CTX_NEW
131 (
errcode(ERRCODE_OUT_OF_MEMORY),
132 errmsg(
"out of memory")));
137 #ifdef HAVE_HMAC_CTX_NEW
143 memset(ctx->
hmacctx, 0,
sizeof(HMAC_CTX));
165 status = HMAC_Init_ex(ctx->
hmacctx,
key,
len, EVP_md5(), NULL);
168 status = HMAC_Init_ex(ctx->
hmacctx,
key,
len, EVP_sha1(), NULL);
171 status = HMAC_Init_ex(ctx->
hmacctx,
key,
len, EVP_sha224(), NULL);
174 status = HMAC_Init_ex(ctx->
hmacctx,
key,
len, EVP_sha256(), NULL);
177 status = HMAC_Init_ex(ctx->
hmacctx,
key,
len, EVP_sha384(), NULL);
180 status = HMAC_Init_ex(ctx->
hmacctx,
key,
len, EVP_sha512(), NULL);
303 #ifdef HAVE_HMAC_CTX_FREE
327 return _(
"out of memory");
341 return _(
"destination buffer too small");
343 return _(
"OpenSSL failure");
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
pg_hmac_ctx * pg_hmac_create(pg_cryptohash_type type)
const char * pg_hmac_error(pg_hmac_ctx *ctx)
static const char * SSLerrmessage(unsigned long ecode)
void pg_hmac_free(pg_hmac_ctx *ctx)
int pg_hmac_update(pg_hmac_ctx *ctx, const uint8 *data, size_t len)
int pg_hmac_init(pg_hmac_ctx *ctx, const uint8 *key, size_t len)
int pg_hmac_final(pg_hmac_ctx *ctx, uint8 *dest, size_t len)
Assert(fmt[strlen(fmt) - 1] !='\n')
#define MD5_DIGEST_LENGTH
void explicit_bzero(void *buf, size_t len)
static Datum PointerGetDatum(const void *X)
void ResourceOwnerEnlargeHMAC(ResourceOwner owner)
ResourceOwner CurrentResourceOwner
void ResourceOwnerRememberHMAC(ResourceOwner owner, Datum handle)
void ResourceOwnerForgetHMAC(ResourceOwner owner, Datum handle)
#define SHA1_DIGEST_LENGTH
#define PG_SHA256_DIGEST_LENGTH
#define PG_SHA384_DIGEST_LENGTH
#define PG_SHA512_DIGEST_LENGTH
#define PG_SHA224_DIGEST_LENGTH