]> begriffs open source - ai-pg/blob - full-docs/txt/encryption-options.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / encryption-options.txt
1
2 18.8. Encryption Options #
3
4    PostgreSQL offers encryption at several levels, and provides
5    flexibility in protecting data from disclosure due to database server
6    theft, unscrupulous administrators, and insecure networks. Encryption
7    might also be required to secure sensitive data such as medical records
8    or financial transactions.
9
10    Password Encryption
11           Database user passwords are stored as hashes (determined by the
12           setting password_encryption), so the administrator cannot
13           determine the actual password assigned to the user. If SCRAM or
14           MD5 encryption is used for client authentication, the
15           unencrypted password is never even temporarily present on the
16           server because the client encrypts it before being sent across
17           the network. SCRAM is preferred, because it is an Internet
18           standard and is more secure than the PostgreSQL-specific MD5
19           authentication protocol.
20
21 Warning
22
23           Support for MD5-encrypted passwords is deprecated and will be
24           removed in a future release of PostgreSQL. Refer to Section 20.5
25           for details about migrating to another password type.
26
27    Encryption For Specific Columns
28           The pgcrypto module allows certain fields to be stored
29           encrypted. This is useful if only some of the data is sensitive.
30           The client supplies the decryption key and the data is decrypted
31           on the server and then sent to the client.
32
33           The decrypted data and the decryption key are present on the
34           server for a brief time while it is being decrypted and
35           communicated between the client and server. This presents a
36           brief moment where the data and keys can be intercepted by
37           someone with complete access to the database server, such as the
38           system administrator.
39
40    Data Partition Encryption
41           Storage encryption can be performed at the file system level or
42           the block level. Linux file system encryption options include
43           eCryptfs and EncFS, while FreeBSD uses PEFS. Block level or full
44           disk encryption options include dm-crypt + LUKS on Linux and
45           GEOM modules geli and gbde on FreeBSD. Many other operating
46           systems support this functionality, including Windows.
47
48           This mechanism prevents unencrypted data from being read from
49           the drives if the drives or the entire computer is stolen. This
50           does not protect against attacks while the file system is
51           mounted, because when mounted, the operating system provides an
52           unencrypted view of the data. However, to mount the file system,
53           you need some way for the encryption key to be passed to the
54           operating system, and sometimes the key is stored somewhere on
55           the host that mounts the disk.
56
57    Encrypting Data Across A Network
58           SSL connections encrypt all data sent across the network: the
59           password, the queries, and the data returned. The pg_hba.conf
60           file allows administrators to specify which hosts can use
61           non-encrypted connections (host) and which require SSL-encrypted
62           connections (hostssl). Also, clients can specify that they
63           connect to servers only via SSL.
64
65           GSSAPI-encrypted connections encrypt all data sent across the
66           network, including queries and data returned. (No password is
67           sent across the network.) The pg_hba.conf file allows
68           administrators to specify which hosts can use non-encrypted
69           connections (host) and which require GSSAPI-encrypted
70           connections (hostgssenc). Also, clients can specify that they
71           connect to servers only on GSSAPI-encrypted connections
72           (gssencmode=require).
73
74           Stunnel or SSH can also be used to encrypt transmissions.
75
76    SSL Host Authentication
77           It is possible for both the client and server to provide SSL
78           certificates to each other. It takes some extra configuration on
79           each side, but this provides stronger verification of identity
80           than the mere use of passwords. It prevents a computer from
81           pretending to be the server just long enough to read the
82           password sent by the client. It also helps prevent “man in the
83           middle” attacks where a computer between the client and server
84           pretends to be the server and reads and passes all data between
85           the client and server.
86
87    Client-Side Encryption
88           If the system administrator for the server's machine cannot be
89           trusted, it is necessary for the client to encrypt the data;
90           this way, unencrypted data never appears on the database server.
91           Data is encrypted on the client before being sent to the server,
92           and database results have to be decrypted on the client before
93           being used.