pgcryptokey

pgcryptokey

pgcryptokey : cryptographic key management

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
7320
pgcryptokey
pgcryptokey
0.85
SEC
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
Requires
pgcrypto
See Also
pgsodium
pgsmcrypto
pg_tde
faker
passwordcheck_cracklib
supautils
supabase_vault

missing 14 on el pgdg repo

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
MIXED
0.85
18
17
16
15
14
pgcryptokeypgcrypto
RPM
PIGSTY
0.85
18
17
16
15
14
pgcryptokey_$v-
DEB
PIGSTY
0.85
18
17
16
15
14
postgresql-$v-pgcryptokey-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
el8.aarch64
PIGSTY 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
el9.x86_64
PIGSTY 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
PIGSTY 0.85
el9.aarch64
PIGSTY 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
el10.x86_64
PIGSTY 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
el10.aarch64
PIGSTY 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
PGDG 0.85
d12.x86_64
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
d12.aarch64
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
d13.x86_64
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
d13.aarch64
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
u22.x86_64
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
u22.aarch64
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
u24.x86_64
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
u24.aarch64
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PIGSTY 0.85
PackageVersionOSORGSIZEFile URL
pgcryptokey_180.85el8.x86_64pigsty16.8 KiBpgcryptokey_18-0.85-1PIGSTY.el8.x86_64.rpm
pgcryptokey_180.85el8.aarch64pigsty17.1 KiBpgcryptokey_18-0.85-1PIGSTY.el8.aarch64.rpm
pgcryptokey_180.85el9.x86_64pigsty16.8 KiBpgcryptokey_18-0.85-1PIGSTY.el9.x86_64.rpm
pgcryptokey_180.85el9.aarch64pigsty16.9 KiBpgcryptokey_18-0.85-1PIGSTY.el9.aarch64.rpm
pgcryptokey_180.85el10.x86_64pigsty16.8 KiBpgcryptokey_18-0.85-1PIGSTY.el10.x86_64.rpm
pgcryptokey_180.85el10.aarch64pigsty17.0 KiBpgcryptokey_18-0.85-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgcryptokey0.85d12.x86_64pigsty11.4 KiBpostgresql-18-pgcryptokey_0.85-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgcryptokey0.85d12.aarch64pigsty11.6 KiBpostgresql-18-pgcryptokey_0.85-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgcryptokey0.85d13.x86_64pigsty11.4 KiBpostgresql-18-pgcryptokey_0.85-1PIGSTY~trixie_amd64.deb
postgresql-18-pgcryptokey0.85d13.aarch64pigsty11.6 KiBpostgresql-18-pgcryptokey_0.85-1PIGSTY~trixie_arm64.deb
postgresql-18-pgcryptokey0.85u22.x86_64pigsty11.5 KiBpostgresql-18-pgcryptokey_0.85-1PIGSTY~jammy_amd64.deb
postgresql-18-pgcryptokey0.85u22.aarch64pigsty11.5 KiBpostgresql-18-pgcryptokey_0.85-1PIGSTY~jammy_arm64.deb
postgresql-18-pgcryptokey0.85u24.x86_64pigsty11.6 KiBpostgresql-18-pgcryptokey_0.85-1PIGSTY~noble_amd64.deb
postgresql-18-pgcryptokey0.85u24.aarch64pigsty11.4 KiBpostgresql-18-pgcryptokey_0.85-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pgcryptokey_170.85el8.x86_64pgdg18.1 KiBpgcryptokey_17-0.85-6PGDG.rhel8.x86_64.rpm
pgcryptokey_170.85el8.x86_64pigsty16.8 KiBpgcryptokey_17-0.85-1PIGSTY.el8.x86_64.rpm
pgcryptokey_170.85el8.aarch64pgdg18.2 KiBpgcryptokey_17-0.85-6PGDG.rhel8.aarch64.rpm
pgcryptokey_170.85el8.aarch64pigsty17.1 KiBpgcryptokey_17-0.85-1PIGSTY.el8.aarch64.rpm
pgcryptokey_170.85el9.x86_64pgdg17.5 KiBpgcryptokey_17-0.85-6PGDG.rhel9.x86_64.rpm
pgcryptokey_170.85el9.x86_64pigsty16.8 KiBpgcryptokey_17-0.85-1PIGSTY.el9.x86_64.rpm
pgcryptokey_170.85el9.aarch64pgdg17.4 KiBpgcryptokey_17-0.85-6PGDG.rhel9.aarch64.rpm
pgcryptokey_170.85el9.aarch64pigsty16.9 KiBpgcryptokey_17-0.85-1PIGSTY.el9.aarch64.rpm
pgcryptokey_170.85el10.x86_64pgdg17.9 KiBpgcryptokey_17-0.85-8PGDG.rhel10.x86_64.rpm
pgcryptokey_170.85el10.x86_64pigsty16.8 KiBpgcryptokey_17-0.85-1PIGSTY.el10.x86_64.rpm
pgcryptokey_170.85el10.aarch64pgdg17.9 KiBpgcryptokey_17-0.85-8PGDG.rhel10.aarch64.rpm
pgcryptokey_170.85el10.aarch64pigsty17.0 KiBpgcryptokey_17-0.85-1PIGSTY.el10.aarch64.rpm
postgresql-17-pgcryptokey0.85d12.x86_64pigsty11.4 KiBpostgresql-17-pgcryptokey_0.85-1PIGSTY~bookworm_amd64.deb
postgresql-17-pgcryptokey0.85d12.aarch64pigsty11.5 KiBpostgresql-17-pgcryptokey_0.85-1PIGSTY~bookworm_arm64.deb
postgresql-17-pgcryptokey0.85d13.x86_64pigsty11.4 KiBpostgresql-17-pgcryptokey_0.85-1PIGSTY~trixie_amd64.deb
postgresql-17-pgcryptokey0.85d13.aarch64pigsty11.6 KiBpostgresql-17-pgcryptokey_0.85-1PIGSTY~trixie_arm64.deb
postgresql-17-pgcryptokey0.85u22.x86_64pigsty11.7 KiBpostgresql-17-pgcryptokey_0.85-1PIGSTY~jammy_amd64.deb
postgresql-17-pgcryptokey0.85u22.aarch64pigsty11.8 KiBpostgresql-17-pgcryptokey_0.85-1PIGSTY~jammy_arm64.deb
postgresql-17-pgcryptokey0.85u24.x86_64pigsty11.6 KiBpostgresql-17-pgcryptokey_0.85-1PIGSTY~noble_amd64.deb
postgresql-17-pgcryptokey0.85u24.aarch64pigsty11.4 KiBpostgresql-17-pgcryptokey_0.85-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pgcryptokey_160.85el8.x86_64pgdg18.0 KiBpgcryptokey_16-0.85-5PGDG.rhel8.x86_64.rpm
pgcryptokey_160.85el8.x86_64pigsty16.8 KiBpgcryptokey_16-0.85-1PIGSTY.el8.x86_64.rpm
pgcryptokey_160.85el8.aarch64pgdg18.1 KiBpgcryptokey_16-0.85-5PGDG.rhel8.aarch64.rpm
pgcryptokey_160.85el8.aarch64pigsty17.1 KiBpgcryptokey_16-0.85-1PIGSTY.el8.aarch64.rpm
pgcryptokey_160.85el9.x86_64pgdg17.3 KiBpgcryptokey_16-0.85-5PGDG.rhel9.x86_64.rpm
pgcryptokey_160.85el9.x86_64pigsty16.8 KiBpgcryptokey_16-0.85-1PIGSTY.el9.x86_64.rpm
pgcryptokey_160.85el9.aarch64pgdg17.0 KiBpgcryptokey_16-0.85-5PGDG.rhel9.aarch64.rpm
pgcryptokey_160.85el9.aarch64pigsty16.8 KiBpgcryptokey_16-0.85-1PIGSTY.el9.aarch64.rpm
pgcryptokey_160.85el10.x86_64pgdg17.9 KiBpgcryptokey_16-0.85-8PGDG.rhel10.x86_64.rpm
pgcryptokey_160.85el10.x86_64pigsty16.8 KiBpgcryptokey_16-0.85-1PIGSTY.el10.x86_64.rpm
pgcryptokey_160.85el10.aarch64pgdg17.9 KiBpgcryptokey_16-0.85-8PGDG.rhel10.aarch64.rpm
pgcryptokey_160.85el10.aarch64pigsty17.0 KiBpgcryptokey_16-0.85-1PIGSTY.el10.aarch64.rpm
postgresql-16-pgcryptokey0.85d12.x86_64pigsty11.4 KiBpostgresql-16-pgcryptokey_0.85-1PIGSTY~bookworm_amd64.deb
postgresql-16-pgcryptokey0.85d12.aarch64pigsty11.5 KiBpostgresql-16-pgcryptokey_0.85-1PIGSTY~bookworm_arm64.deb
postgresql-16-pgcryptokey0.85d13.x86_64pigsty11.4 KiBpostgresql-16-pgcryptokey_0.85-1PIGSTY~trixie_amd64.deb
postgresql-16-pgcryptokey0.85d13.aarch64pigsty11.6 KiBpostgresql-16-pgcryptokey_0.85-1PIGSTY~trixie_arm64.deb
postgresql-16-pgcryptokey0.85u22.x86_64pigsty11.7 KiBpostgresql-16-pgcryptokey_0.85-1PIGSTY~jammy_amd64.deb
postgresql-16-pgcryptokey0.85u22.aarch64pigsty11.8 KiBpostgresql-16-pgcryptokey_0.85-1PIGSTY~jammy_arm64.deb
postgresql-16-pgcryptokey0.85u24.x86_64pigsty11.6 KiBpostgresql-16-pgcryptokey_0.85-1PIGSTY~noble_amd64.deb
postgresql-16-pgcryptokey0.85u24.aarch64pigsty11.4 KiBpostgresql-16-pgcryptokey_0.85-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pgcryptokey_150.85el8.x86_64pgdg22.4 KiBpgcryptokey_15-0.85-3.rhel8.x86_64.rpm
pgcryptokey_150.85el8.x86_64pigsty16.8 KiBpgcryptokey_15-0.85-1PIGSTY.el8.x86_64.rpm
pgcryptokey_150.85el8.aarch64pgdg22.4 KiBpgcryptokey_15-0.85-3.rhel8.aarch64.rpm
pgcryptokey_150.85el8.aarch64pigsty17.1 KiBpgcryptokey_15-0.85-1PIGSTY.el8.aarch64.rpm
pgcryptokey_150.85el9.x86_64pgdg22.7 KiBpgcryptokey_15-0.85-3.rhel9.x86_64.rpm
pgcryptokey_150.85el9.x86_64pigsty16.8 KiBpgcryptokey_15-0.85-1PIGSTY.el9.x86_64.rpm
pgcryptokey_150.85el9.aarch64pgdg22.4 KiBpgcryptokey_15-0.85-3.rhel9.aarch64.rpm
pgcryptokey_150.85el9.aarch64pigsty16.9 KiBpgcryptokey_15-0.85-1PIGSTY.el9.aarch64.rpm
pgcryptokey_150.85el10.x86_64pgdg17.9 KiBpgcryptokey_15-0.85-8PGDG.rhel10.x86_64.rpm
pgcryptokey_150.85el10.x86_64pigsty16.8 KiBpgcryptokey_15-0.85-1PIGSTY.el10.x86_64.rpm
pgcryptokey_150.85el10.aarch64pgdg17.9 KiBpgcryptokey_15-0.85-8PGDG.rhel10.aarch64.rpm
pgcryptokey_150.85el10.aarch64pigsty17.0 KiBpgcryptokey_15-0.85-1PIGSTY.el10.aarch64.rpm
postgresql-15-pgcryptokey0.85d12.x86_64pigsty11.4 KiBpostgresql-15-pgcryptokey_0.85-1PIGSTY~bookworm_amd64.deb
postgresql-15-pgcryptokey0.85d12.aarch64pigsty11.5 KiBpostgresql-15-pgcryptokey_0.85-1PIGSTY~bookworm_arm64.deb
postgresql-15-pgcryptokey0.85d13.x86_64pigsty11.4 KiBpostgresql-15-pgcryptokey_0.85-1PIGSTY~trixie_amd64.deb
postgresql-15-pgcryptokey0.85d13.aarch64pigsty11.6 KiBpostgresql-15-pgcryptokey_0.85-1PIGSTY~trixie_arm64.deb
postgresql-15-pgcryptokey0.85u22.x86_64pigsty11.7 KiBpostgresql-15-pgcryptokey_0.85-1PIGSTY~jammy_amd64.deb
postgresql-15-pgcryptokey0.85u22.aarch64pigsty11.8 KiBpostgresql-15-pgcryptokey_0.85-1PIGSTY~jammy_arm64.deb
postgresql-15-pgcryptokey0.85u24.x86_64pigsty11.6 KiBpostgresql-15-pgcryptokey_0.85-1PIGSTY~noble_amd64.deb
postgresql-15-pgcryptokey0.85u24.aarch64pigsty11.4 KiBpostgresql-15-pgcryptokey_0.85-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pgcryptokey_140.85el8.x86_64pgdg22.6 KiBpgcryptokey_14-0.85-3.rhel8.x86_64.rpm
pgcryptokey_140.85el8.x86_64pigsty16.8 KiBpgcryptokey_14-0.85-1PIGSTY.el8.x86_64.rpm
pgcryptokey_140.85el8.aarch64pgdg22.4 KiBpgcryptokey_14-0.85-3.rhel8.aarch64.rpm
pgcryptokey_140.85el8.aarch64pigsty17.1 KiBpgcryptokey_14-0.85-1PIGSTY.el8.aarch64.rpm
pgcryptokey_140.85el9.x86_64pigsty16.8 KiBpgcryptokey_14-0.85-1PIGSTY.el9.x86_64.rpm
pgcryptokey_140.85el9.aarch64pgdg22.3 KiBpgcryptokey_14-0.85-3.rhel9.aarch64.rpm
pgcryptokey_140.85el9.aarch64pigsty16.8 KiBpgcryptokey_14-0.85-1PIGSTY.el9.aarch64.rpm
pgcryptokey_140.85el10.x86_64pgdg17.9 KiBpgcryptokey_14-0.85-8PGDG.rhel10.x86_64.rpm
pgcryptokey_140.85el10.x86_64pigsty16.8 KiBpgcryptokey_14-0.85-1PIGSTY.el10.x86_64.rpm
pgcryptokey_140.85el10.aarch64pgdg17.9 KiBpgcryptokey_14-0.85-8PGDG.rhel10.aarch64.rpm
pgcryptokey_140.85el10.aarch64pigsty17.0 KiBpgcryptokey_14-0.85-1PIGSTY.el10.aarch64.rpm
postgresql-14-pgcryptokey0.85d12.x86_64pigsty11.4 KiBpostgresql-14-pgcryptokey_0.85-1PIGSTY~bookworm_amd64.deb
postgresql-14-pgcryptokey0.85d12.aarch64pigsty11.5 KiBpostgresql-14-pgcryptokey_0.85-1PIGSTY~bookworm_arm64.deb
postgresql-14-pgcryptokey0.85d13.x86_64pigsty11.4 KiBpostgresql-14-pgcryptokey_0.85-1PIGSTY~trixie_amd64.deb
postgresql-14-pgcryptokey0.85d13.aarch64pigsty11.6 KiBpostgresql-14-pgcryptokey_0.85-1PIGSTY~trixie_arm64.deb
postgresql-14-pgcryptokey0.85u22.x86_64pigsty11.6 KiBpostgresql-14-pgcryptokey_0.85-1PIGSTY~jammy_amd64.deb
postgresql-14-pgcryptokey0.85u22.aarch64pigsty11.7 KiBpostgresql-14-pgcryptokey_0.85-1PIGSTY~jammy_arm64.deb
postgresql-14-pgcryptokey0.85u24.x86_64pigsty11.6 KiBpostgresql-14-pgcryptokey_0.85-1PIGSTY~noble_amd64.deb
postgresql-14-pgcryptokey0.85u24.aarch64pigsty11.4 KiBpostgresql-14-pgcryptokey_0.85-1PIGSTY~noble_arm64.deb

Source

pig build pkg pgcryptokey;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgcryptokey;		# install via package name, for the active PG version

pig install pgcryptokey -v 18;   # install for PG 18
pig install pgcryptokey -v 17;   # install for PG 17
pig install pgcryptokey -v 16;   # install for PG 16
pig install pgcryptokey -v 15;   # install for PG 15
pig install pgcryptokey -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pgcryptokey CASCADE; -- requires pgcrypto

Usage

pgcryptokey: Cryptographic key management for PostgreSQL

pgcryptokey manages cryptographic data encryption keys within PostgreSQL. Keys are stored encrypted and secured by access passwords, supporting both system-wide and per-session key access.

CREATE EXTENSION pgcryptokey;

Key Management Functions

FunctionDescription
create_cryptokey(name, byte_len)Generate a new cryptographic key
set_cryptokey(name)Set the active key for operations
get_cryptokey(name)Retrieve key material
drop_cryptokey(name)Remove a key
supersede_cryptokey()Rotate to a new key (same access password)
change_key_access_password()Update key authentication credentials
reencrypt_data()Re-encrypt data with a different key

Session Control

FunctionDescription
get_shared_key()Establish client/server shared secret (SSL/Unix only)
set_session_access_password()Client-supplied password authentication

Typical Workflow

-- Create a key
SELECT create_cryptokey('mykey', 32);

-- Set active key
SELECT set_cryptokey('mykey');

-- Encrypt data using pgcrypto functions with the managed key
UPDATE secrets SET data = pgp_sym_encrypt(plaintext, get_cryptokey('mykey'));

-- Decrypt data
SELECT pgp_sym_decrypt(data, get_cryptokey('mykey')) FROM secrets;

-- Rotate key
SELECT supersede_cryptokey();

Access passwords can be configured at database boot time for system-wide access, or per-session by individual clients for granular security control.

Last updated on