24 #include <openssl/err.h>
25 #include <openssl/evp.h>
43 #define ALLOC(size) MemoryContextAlloc(TopMemoryContext, size)
44 #define FREE(ptr) pfree(ptr)
46 #define ALLOC(size) malloc(size)
47 #define FREE(ptr) free(ptr)
87 return ERR_reason_error_string(ecode);
124 ctx->
evpctx = EVP_MD_CTX_create();
132 (
errcode(ERRCODE_OUT_OF_MEMORY),
133 errmsg(
"out of memory")));
164 status = EVP_DigestInit_ex(ctx->
evpctx, EVP_md5(), NULL);
167 status = EVP_DigestInit_ex(ctx->
evpctx, EVP_sha1(), NULL);
170 status = EVP_DigestInit_ex(ctx->
evpctx, EVP_sha224(), NULL);
173 status = EVP_DigestInit_ex(ctx->
evpctx, EVP_sha256(), NULL);
176 status = EVP_DigestInit_ex(ctx->
evpctx, EVP_sha384(), NULL);
179 status = EVP_DigestInit_ex(ctx->
evpctx, EVP_sha512(), NULL);
284 status = EVP_DigestFinal_ex(ctx->
evpctx,
dest, 0);
307 EVP_MD_CTX_destroy(ctx->
evpctx);
332 return _(
"out of memory");
346 return _(
"destination buffer too small");
348 return _(
"OpenSSL failure");
int pg_cryptohash_update(pg_cryptohash_ctx *ctx, const uint8 *data, size_t len)
int pg_cryptohash_init(pg_cryptohash_ctx *ctx)
static const char * SSLerrmessage(unsigned long ecode)
@ PG_CRYPTOHASH_ERROR_DEST_LEN
@ PG_CRYPTOHASH_ERROR_NONE
@ PG_CRYPTOHASH_ERROR_OPENSSL
void pg_cryptohash_free(pg_cryptohash_ctx *ctx)
pg_cryptohash_ctx * pg_cryptohash_create(pg_cryptohash_type type)
int pg_cryptohash_final(pg_cryptohash_ctx *ctx, uint8 *dest, size_t len)
const char * pg_cryptohash_error(pg_cryptohash_ctx *ctx)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Assert(fmt[strlen(fmt) - 1] !='\n')
#define MD5_DIGEST_LENGTH
void explicit_bzero(void *buf, size_t len)
static Datum PointerGetDatum(const void *X)
ResourceOwner CurrentResourceOwner
void ResourceOwnerRememberCryptoHash(ResourceOwner owner, Datum handle)
void ResourceOwnerEnlargeCryptoHash(ResourceOwner owner)
void ResourceOwnerForgetCryptoHash(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
pg_cryptohash_errno error