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

Function scram_ClientKey

src/common/scram-common.c:116–134  ·  view source on GitHub ↗

* Calculate ClientKey. Returns 0 on success, -1 on failure. */

Source from the content-addressed store, hash-verified

114 * Calculate ClientKey. Returns 0 on success, -1 on failure.
115 */
116int
117scram_ClientKey(const uint8 *salted_password, uint8 *result)
118{
119 pg_hmac_ctx *ctx = pg_hmac_create(PG_SHA256);
120
121 if (ctx == NULL)
122 return -1;
123
124 if (pg_hmac_init(ctx, salted_password, SCRAM_KEY_LEN) < 0 ||
125 pg_hmac_update(ctx, (uint8 *) "Client Key", strlen("Client Key")) < 0 ||
126 pg_hmac_final(ctx, result, SCRAM_KEY_LEN) < 0)
127 {
128 pg_hmac_free(ctx);
129 return -1;
130 }
131
132 pg_hmac_free(ctx);
133 return 0;
134}
135
136/*
137 * Calculate ServerKey. Returns 0 on success, -1 on failure.

Callers 2

scram_build_secretFunction · 0.85
calculate_client_proofFunction · 0.85

Calls 5

pg_hmac_createFunction · 0.70
pg_hmac_initFunction · 0.70
pg_hmac_updateFunction · 0.70
pg_hmac_finalFunction · 0.70
pg_hmac_freeFunction · 0.70

Tested by

no test coverage detected