1 /*------------------------------------------------------------------------- 2 * 3 * scram.h 4 * Interface to libpq/scram.c 5 * 6 * Portions Copyright (c) 1996-2020, 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 */ 25 extern void pg_be_scram_get_mechanisms(Port *port, StringInfo buf); 26 extern void *pg_be_scram_init(Port *port, const char *selected_mech, const char *shadow_pass); 27 extern 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 secret */ 31 extern char *pg_be_scram_build_secret(const char *password); 32 extern bool parse_scram_secret(const char *secret, int *iterations, char **salt, 33 uint8 *stored_key, uint8 *server_key); 34 extern bool scram_verify_plain_password(const char *username, 35 const char *password, const char *secret); 36 37 #endif /* PG_SCRAM_H */ 38