mirror of
https://github.com/postgres/postgres.git
synced 2025-08-14 02:22:38 +03:00
config
contrib
adminpack
auth_delay
auto_explain
btree_gin
btree_gist
chkpass
citext
cube
dblink
dict_int
dict_xsyn
dummy_seclabel
earthdistance
file_fdw
fuzzystrmatch
hstore
intagg
intarray
isn
lo
ltree
oid2name
pageinspect
passwordcheck
pg_archivecleanup
pg_buffercache
pg_freespacemap
pg_standby
pg_stat_statements
pg_test_fsync
pg_trgm
pg_upgrade
pg_upgrade_support
pgbench
pgcrypto
expected
sql
3des.sql
blowfish.sql
cast5.sql
crypt-blowfish.sql
crypt-des.sql
crypt-md5.sql
crypt-xdes.sql
des.sql
hmac-md5.sql
hmac-sha1.sql
init.sql
md5.sql
pgp-armor.sql
pgp-compression.sql
pgp-decrypt.sql
pgp-encrypt-DISABLED.sql
pgp-encrypt.sql
pgp-info.sql
pgp-pubkey-DISABLED.sql
pgp-pubkey-decrypt.sql
pgp-pubkey-encrypt.sql
pgp-zlib-DISABLED.sql
rijndael.sql
sha1.sql
sha2.sql
.gitignore
Makefile
blf.c
blf.h
crypt-blowfish.c
crypt-des.c
crypt-gensalt.c
crypt-md5.c
fortuna.c
fortuna.h
imath.c
imath.h
internal-sha2.c
internal.c
mbuf.c
mbuf.h
md5.c
md5.h
openssl.c
pgcrypto--1.0.sql
pgcrypto--unpackaged--1.0.sql
pgcrypto.c
pgcrypto.control
pgcrypto.h
pgp-armor.c
pgp-cfb.c
pgp-compress.c
pgp-decrypt.c
pgp-encrypt.c
pgp-info.c
pgp-mpi-internal.c
pgp-mpi-openssl.c
pgp-mpi.c
pgp-pgsql.c
pgp-pubdec.c
pgp-pubenc.c
pgp-pubkey.c
pgp-s2k.c
pgp.c
pgp.h
px-crypt.c
px-crypt.h
px-hmac.c
px.c
px.h
random.c
rijndael.c
rijndael.h
rijndael.tbl
sha1.c
sha1.h
sha2.c
sha2.h
pgrowlocks
pgstattuple
seg
sepgsql
spi
sslinfo
start-scripts
tablefunc
test_parser
tsearch2
unaccent
uuid-ossp
vacuumlo
xml2
Makefile
README
contrib-global.mk
doc
src
.gitignore
COPYRIGHT
GNUmakefile.in
Makefile
README
README.git
aclocal.m4
configure
configure.in
98 lines
3.0 KiB
SQL
98 lines
3.0 KiB
SQL
--
|
|
-- PGP encrypt
|
|
--
|
|
-- ensure consistent test output regardless of the default bytea format
|
|
SET bytea_output TO escape;
|
|
|
|
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'), 'key');
|
|
|
|
-- check whether the defaults are ok
|
|
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'),
|
|
'key', 'expect-cipher-algo=aes128,
|
|
expect-disable-mdc=0,
|
|
expect-sess-key=0,
|
|
expect-s2k-mode=3,
|
|
expect-s2k-digest-algo=sha1,
|
|
expect-compress-algo=0
|
|
');
|
|
|
|
-- maybe the expect- stuff simply does not work
|
|
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'),
|
|
'key', 'expect-cipher-algo=bf,
|
|
expect-disable-mdc=1,
|
|
expect-sess-key=1,
|
|
expect-s2k-mode=0,
|
|
expect-s2k-digest-algo=md5,
|
|
expect-compress-algo=1
|
|
');
|
|
|
|
-- bytea as text
|
|
select pgp_sym_decrypt(pgp_sym_encrypt_bytea('Binary', 'baz'), 'baz');
|
|
|
|
-- text as bytea
|
|
select pgp_sym_decrypt_bytea(pgp_sym_encrypt('Text', 'baz'), 'baz');
|
|
|
|
|
|
-- algorithm change
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=bf'),
|
|
'key', 'expect-cipher-algo=bf');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=aes'),
|
|
'key', 'expect-cipher-algo=aes128');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=aes192'),
|
|
'key', 'expect-cipher-algo=aes192');
|
|
|
|
-- s2k change
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=0'),
|
|
'key', 'expect-s2k-mode=0');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=1'),
|
|
'key', 'expect-s2k-mode=1');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=3'),
|
|
'key', 'expect-s2k-mode=3');
|
|
|
|
-- s2k digest change
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 's2k-digest-algo=md5'),
|
|
'key', 'expect-s2k-digest-algo=md5');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 's2k-digest-algo=sha1'),
|
|
'key', 'expect-s2k-digest-algo=sha1');
|
|
|
|
-- sess key
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'sess-key=0'),
|
|
'key', 'expect-sess-key=0');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1'),
|
|
'key', 'expect-sess-key=1');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=bf'),
|
|
'key', 'expect-sess-key=1, expect-cipher-algo=bf');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=aes192'),
|
|
'key', 'expect-sess-key=1, expect-cipher-algo=aes192');
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=aes256'),
|
|
'key', 'expect-sess-key=1, expect-cipher-algo=aes256');
|
|
|
|
-- no mdc
|
|
select pgp_sym_decrypt(
|
|
pgp_sym_encrypt('Secret.', 'key', 'disable-mdc=1'),
|
|
'key', 'expect-disable-mdc=1');
|
|
|
|
-- crlf
|
|
select encode(pgp_sym_decrypt_bytea(
|
|
pgp_sym_encrypt(E'1\n2\n3\r\n', 'key', 'convert-crlf=1'),
|
|
'key'), 'hex');
|
|
|
|
-- conversion should be lossless
|
|
select encode(digest(pgp_sym_decrypt(
|
|
pgp_sym_encrypt(E'\r\n0\n1\r\r\n\n2\r', 'key', 'convert-crlf=1'),
|
|
'key', 'convert-crlf=1'), 'sha1'), 'hex') as result,
|
|
encode(digest(E'\r\n0\n1\r\r\n\n2\r', 'sha1'), 'hex') as expect;
|