MCPcopy Create free account
hub / github.com/apache/cloudberry / pg_hmac_create

Function pg_hmac_create

src/common/hmac_openssl.c:70–116  ·  view source on GitHub ↗

* pg_hmac_create * * Allocate a hash context. Returns NULL on failure for an OOM. The * backend issues an error, without returning. */

Source from the content-addressed store, hash-verified

68 * backend issues an error, without returning.
69 */
70pg_hmac_ctx *
71pg_hmac_create(pg_cryptohash_type type)
72{
73 pg_hmac_ctx *ctx;
74
75 ctx = ALLOC(sizeof(pg_hmac_ctx));
76 if (ctx == NULL)
77 return NULL;
78 memset(ctx, 0, sizeof(pg_hmac_ctx));
79
80 ctx->type = type;
81
82 /*
83 * Initialization takes care of assigning the correct type for OpenSSL.
84 */
85#ifdef HAVE_HMAC_CTX_NEW
86#ifndef FRONTEND
87 ResourceOwnerEnlargeHMAC(CurrentResourceOwner);
88#endif
89 ctx->hmacctx = HMAC_CTX_new();
90#else
91 ctx->hmacctx = ALLOC(sizeof(HMAC_CTX));
92#endif
93
94 if (ctx->hmacctx == NULL)
95 {
96 explicit_bzero(ctx, sizeof(pg_hmac_ctx));
97 FREE(ctx);
98#ifndef FRONTEND
99 ereport(ERROR,
100 (errcode(ERRCODE_OUT_OF_MEMORY),
101 errmsg("out of memory")));
102#endif
103 return NULL;
104 }
105
106#ifdef HAVE_HMAC_CTX_NEW
107#ifndef FRONTEND
108 ctx->resowner = CurrentResourceOwner;
109 ResourceOwnerRememberHMAC(CurrentResourceOwner, PointerGetDatum(ctx));
110#endif
111#else
112 memset(ctx->hmacctx, 0, sizeof(HMAC_CTX));
113#endif /* HAVE_HMAC_CTX_NEW */
114
115 return ctx;
116}
117
118/*
119 * pg_hmac_init

Callers

nothing calls this directly

Calls 5

ResourceOwnerEnlargeHMACFunction · 0.85
explicit_bzeroFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected