1/*-------------------------------------------------------------------------
2 *
3 * scram.h
4 * Interface to libpq/scram.c
5 *
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/libpq/scram.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef PG_SCRAM_H
14#define PG_SCRAM_H
15
16#include "lib/stringinfo.h"
17#include "libpq/libpq-be.h"
18
19/* Status codes for message exchange */
20#define SASL_EXCHANGE_CONTINUE 0
21#define SASL_EXCHANGE_SUCCESS 1
22#define SASL_EXCHANGE_FAILURE 2
23
24/* Routines dedicated to authentication */
25extern void pg_be_scram_get_mechanisms(Port *port, StringInfo buf);
26extern void *pg_be_scram_init(Port *port, const char *selected_mech, const char *shadow_pass);
27extern int pg_be_scram_exchange(void *opaq, const char *input, int inputlen,
28 char **output, int *outputlen, char **logdetail);
29
30/* Routines to handle and check SCRAM-SHA-256 verifier */
31extern char *pg_be_scram_build_verifier(const char *password);
32extern bool parse_scram_verifier(const char *verifier, int *iterations, char **salt,
33 uint8 *stored_key, uint8 *server_key);
34extern bool scram_verify_plain_password(const char *username,
35 const char *password, const char *verifier);
36
37#endif /* PG_SCRAM_H */
38