7 select encode(dearmor(armor('')), 'escape');
8 select encode(dearmor(armor('zooka')), 'escape');
10 select armor('0123456789abcdef0123456789abcdef0123456789abcdef
11 0123456789abcdef0123456789abcdef0123456789abcdef');
14 select encode(dearmor(' a pgp msg:
16 -----BEGIN PGP MESSAGE-----
23 -----END PGP MESSAGE-----'), 'escape');
26 select encode(dearmor('
28 -----BEGIN PGP MESSAGE-----
32 -----END PGP MESSAGE-----
35 -----BEGIN PGP MESSAGE-----
39 -----END PGP MESSAGE-----
42 -----BEGIN PGP MESSAGE-----
46 -----END PGP MESSAGE-----
51 -----BEGIN PGP MESSAGE-----
55 -----END PGP MESSAGE-----
58 -- corrupt (no space after the colon)
59 select * from pgp_armor_headers('
60 -----BEGIN PGP MESSAGE-----
65 -----END PGP MESSAGE-----
68 -- corrupt (no empty line)
69 select * from pgp_armor_headers('
70 -----BEGIN PGP MESSAGE-----
73 -----END PGP MESSAGE-----
77 select * from pgp_armor_headers('
78 -----BEGIN PGP MESSAGE-----
82 -----END PGP MESSAGE-----
85 -- header with empty value
86 select * from pgp_armor_headers('
87 -----BEGIN PGP MESSAGE-----
92 -----END PGP MESSAGE-----
96 select * from pgp_armor_headers('
97 -----BEGIN PGP MESSAGE-----
103 -----END PGP MESSAGE-----
106 -- insane keys, part 1
107 select * from pgp_armor_headers('
108 -----BEGIN PGP MESSAGE-----
113 -----END PGP MESSAGE-----
116 -- insane keys, part 2
117 select * from pgp_armor_headers('
118 -----BEGIN PGP MESSAGE-----
119 insane:key : text value here
123 -----END PGP MESSAGE-----
127 select * from pgp_armor_headers('
128 -----BEGIN PGP MESSAGE-----
129 long: this value is more than 76 characters long, but it should still parse correctly as that''s permitted by RFC 4880
133 -----END PGP MESSAGE-----
136 -- long value, split up
137 select * from pgp_armor_headers('
138 -----BEGIN PGP MESSAGE-----
139 long: this value is more than 76 characters long, but it should still
140 long: parse correctly as that''s permitted by RFC 4880
144 -----END PGP MESSAGE-----
147 -- long value, split up, part 2
148 select * from pgp_armor_headers('
149 -----BEGIN PGP MESSAGE-----
150 long: this value is more than
151 long: 76 characters long, but it should still
152 long: parse correctly as that''s permitted by RFC 4880
156 -----END PGP MESSAGE-----
159 -- long value, split up, part 3
160 select * from pgp_armor_headers('
161 -----BEGIN PGP MESSAGE-----
163 long: this value is more than
165 long: 76 characters long, but it should still
167 long: parse correctly as that''s permitted by RFC 4880
172 -----END PGP MESSAGE-----
175 select * from pgp_armor_headers('
176 -----BEGIN PGP MESSAGE-----
177 Comment: dat1.blowfish.sha1.mdc.s2k3.z0
179 jA0EBAMCfFNwxnvodX9g0jwB4n4s26/g5VmKzVab1bX1SmwY7gvgvlWdF3jKisvS
180 yA6Ce1QTMK3KdL2MPfamsTUSAML8huCJMwYQFfE=
182 -----END PGP MESSAGE-----
185 -- test CR+LF line endings
186 select * from pgp_armor_headers(replace('
187 -----BEGIN PGP MESSAGE-----
193 -----END PGP MESSAGE-----
196 -- test header generation
197 select armor('zooka', array['foo'], array['bar']);
198 select armor('zooka', array['Version', 'Comment'], array['Created by pgcrypto', 'PostgreSQL, the world''s most advanced open source database']);
199 select * from pgp_armor_headers(
200 armor('zooka', array['Version', 'Comment'],
201 array['Created by pgcrypto', 'PostgreSQL, the world''s most advanced open source database']));
203 -- error/corner cases
204 select armor('', array['foo'], array['too', 'many']);
205 select armor('', array['too', 'many'], array['foo']);
206 select armor('', array[['']], array['foo']);
207 select armor('', array['foo'], array[['']]);
208 select armor('', array[null], array['foo']);
209 select armor('', array['foo'], array[null]);
210 select armor('', '[0:0]={"foo"}', array['foo']);
211 select armor('', array['foo'], '[0:0]={"foo"}');
212 select armor('', array[E'embedded\nnewline'], array['foo']);
213 select armor('', array['foo'], array[E'embedded\nnewline']);
214 select armor('', array['embedded: colon+space'], array['foo']);