PostgreSQL Source Code git master
Loading...
Searching...
No Matches
crypt.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * crypt.h
4 * Interface to libpq/crypt.c
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/libpq/crypt.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef PG_CRYPT_H
14#define PG_CRYPT_H
15
16#include "datatype/timestamp.h"
17
18/*
19 * Valid password hashes may be very long, but we don't want to store anything
20 * that might need out-of-line storage, since de-TOASTing won't work during
21 * authentication because we haven't selected a database yet and cannot read
22 * pg_class. 512 bytes should be more than enough for all practical use, and
23 * our own password encryption routines should never produce hashes longer than
24 * this.
25 */
26#define MAX_ENCRYPTED_PASSWORD_LEN (512)
27
28/* Threshold for password expiration warnings. */
30
31/* Enables deprecation warnings for MD5 passwords. */
33
34/*
35 * Types of password hashes or secrets.
36 *
37 * Plaintext passwords can be passed in by the user, in a CREATE/ALTER USER
38 * command. They will be encrypted to MD5 or SCRAM-SHA-256 format, before
39 * storing on-disk, so only MD5 and SCRAM-SHA-256 passwords should appear
40 * in pg_authid.rolpassword. They are also the allowed values for the
41 * password_encryption GUC.
42 */
49
51extern char *encrypt_password(PasswordType target_type, const char *role,
52 const char *password);
53
54extern char *get_role_password(const char *role, const char **logdetail);
55
56extern int md5_crypt_verify(const char *role, const char *shadow_pass,
57 const char *client_pass, const uint8 *md5_salt,
58 int md5_salt_len, const char **logdetail);
59extern int plain_crypt_verify(const char *role, const char *shadow_pass,
60 const char *client_pass,
61 const char **logdetail);
62
63#endif
#define PGDLLIMPORT
Definition c.h:1356
uint8_t uint8
Definition c.h:556
int md5_crypt_verify(const char *role, const char *shadow_pass, const char *client_pass, const uint8 *md5_salt, int md5_salt_len, const char **logdetail)
Definition crypt.c:265
int plain_crypt_verify(const char *role, const char *shadow_pass, const char *client_pass, const char **logdetail)
Definition crypt.c:336
PGDLLIMPORT int password_expiration_warning_threshold
Definition crypt.c:30
PasswordType
Definition crypt.h:44
@ PASSWORD_TYPE_PLAINTEXT
Definition crypt.h:45
@ PASSWORD_TYPE_SCRAM_SHA_256
Definition crypt.h:47
@ PASSWORD_TYPE_MD5
Definition crypt.h:46
char * get_role_password(const char *role, const char **logdetail)
Definition crypt.c:43
PasswordType get_password_type(const char *shadow_pass)
Definition crypt.c:153
PGDLLIMPORT bool md5_password_warnings
Definition crypt.c:33
char * encrypt_password(PasswordType target_type, const char *role, const char *password)
Definition crypt.c:180
static int fb(int x)
static char * password
Definition streamutil.c:51