char **salt, uint8 *stored_key, uint8 *server_key);
static bool is_scram_printable(char *p);
static char *sanitize_char(char c);
-static char *scram_MockSalt(const char *username);
+static char *scram_mock_salt(const char *username);
/*
* pg_be_scram_init
return memcmp(computed_key, server_key, SCRAM_KEY_LEN) == 0;
}
-/*
- * Check if given verifier can be used for SCRAM authentication.
- *
- * Returns true if it is a SCRAM verifier, and false otherwise.
- */
-bool
-is_scram_verifier(const char *verifier)
-{
- int iterations;
- char *salt = NULL;
- uint8 stored_key[SCRAM_KEY_LEN];
- uint8 server_key[SCRAM_KEY_LEN];
- bool result;
-
- result = parse_scram_verifier(verifier, &iterations, &salt,
- stored_key, server_key);
- if (salt)
- pfree(salt);
-
- return result;
-}
-
/*
* Parse and validate format of given SCRAM verifier.
int encoded_len;
/* Generate deterministic salt */
- raw_salt = scram_MockSalt(username);
+ raw_salt = scram_mock_salt(username);
encoded_salt = (char *) palloc(pg_b64_enc_len(SCRAM_DEFAULT_SALT_LEN) + 1);
encoded_len = pg_b64_encode(raw_salt, SCRAM_DEFAULT_SALT_LEN, encoded_salt);
if (c >= 0x21 && c <= 0x7E)
snprintf(buf, sizeof(buf), "'%c'", c);
else
- snprintf(buf, sizeof(buf), "0x%02x", c);
+ snprintf(buf, sizeof(buf), "0x%02x", (unsigned char) c);
return buf;
}
* pointer to a static buffer of size SCRAM_DEFAULT_SALT_LEN.
*/
static char *
-scram_MockSalt(const char *username)
+scram_mock_salt(const char *username)
{
pg_sha256_ctx ctx;
static uint8 sha_digest[PG_SHA256_DIGEST_LENGTH];
break;
case FE_SCRAM_PROOF_SENT:
- /* Receive server proof */
+ /* Receive server signature */
if (!read_server_final_message(state, input, errorMessage))
goto error;
{
*success = false;
printfPQExpBuffer(errorMessage,
- libpq_gettext("invalid server proof\n"));
+ libpq_gettext("invalid server signature\n"));
}
*done = true;
state->state = FE_SCRAM_FINISHED;