summaryrefslogtreecommitdiffstats
path: root/contrib/pgcrypto/expected/pgp-pubkey-encrypt.out
blob: df2756c4d0620cede4ee36f2de2c550fc45035fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--
-- PGP Public Key Encryption
--
-- ensure consistent test output regardless of the default bytea format
SET bytea_output TO escape;
-- successful encrypt/decrypt
select pgp_pub_decrypt(
	pgp_pub_encrypt('Secret msg', dearmor(pubkey)),
	dearmor(seckey))
from keytbl where keytbl.id=1;
 pgp_pub_decrypt 
-----------------
 Secret msg
(1 row)

select pgp_pub_decrypt(
		pgp_pub_encrypt('Secret msg', dearmor(pubkey)),
		dearmor(seckey))
from keytbl where keytbl.id=2;
 pgp_pub_decrypt 
-----------------
 Secret msg
(1 row)

select pgp_pub_decrypt(
		pgp_pub_encrypt('Secret msg', dearmor(pubkey)),
		dearmor(seckey))
from keytbl where keytbl.id=3;
 pgp_pub_decrypt 
-----------------
 Secret msg
(1 row)

select pgp_pub_decrypt(
		pgp_pub_encrypt('Secret msg', dearmor(pubkey)),
		dearmor(seckey))
from keytbl where keytbl.id=6;
 pgp_pub_decrypt 
-----------------
 Secret msg
(1 row)

-- try with rsa-sign only
select pgp_pub_decrypt(
		pgp_pub_encrypt('Secret msg', dearmor(pubkey)),
		dearmor(seckey))
from keytbl where keytbl.id=4;
ERROR:  No encryption key found
-- try with secret key
select pgp_pub_decrypt(
		pgp_pub_encrypt('Secret msg', dearmor(seckey)),
		dearmor(seckey))
from keytbl where keytbl.id=1;
ERROR:  Refusing to encrypt with secret key
-- does text-to-bytea works
select pgp_pub_decrypt_bytea(
		pgp_pub_encrypt('Secret msg', dearmor(pubkey)),
		dearmor(seckey))
from keytbl where keytbl.id=1;
 pgp_pub_decrypt_bytea 
-----------------------
 Secret msg
(1 row)

-- and bytea-to-text?
select pgp_pub_decrypt(
		pgp_pub_encrypt_bytea('Secret msg', dearmor(pubkey)),
		dearmor(seckey))
from keytbl where keytbl.id=1;
ERROR:  Not text data