6 -----------------------------
7 -----BEGIN PGP MESSAGE-----+
10 -----END PGP MESSAGE----- +
16 -----------------------------
17 -----BEGIN PGP MESSAGE-----+
21 -----END PGP MESSAGE----- +
25 select encode(dearmor(armor('')), 'escape');
31 select encode(dearmor(armor('zooka')), 'escape');
37 select armor('0123456789abcdef0123456789abcdef0123456789abcdef
38 0123456789abcdef0123456789abcdef0123456789abcdef');
40 ------------------------------------------------------------------------------
41 -----BEGIN PGP MESSAGE----- +
43 MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmCjAxMjM0NTY3+
44 ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmMDEyMzQ1Njc4OWFiY2RlZg== +
46 -----END PGP MESSAGE----- +
51 select encode(dearmor(' a pgp msg:
53 -----BEGIN PGP MESSAGE-----
60 -----END PGP MESSAGE-----'), 'escape');
67 select encode(dearmor('
69 -----BEGIN PGP MESSAGE-----
73 -----END PGP MESSAGE-----
76 -----BEGIN PGP MESSAGE-----
80 -----END PGP MESSAGE-----
83 -----BEGIN PGP MESSAGE-----
87 -----END PGP MESSAGE-----
96 -----BEGIN PGP MESSAGE-----
100 -----END PGP MESSAGE-----
102 ERROR: Corrupt ascii-armor
103 -- corrupt (no space after the colon)
104 select * from pgp_armor_headers('
105 -----BEGIN PGP MESSAGE-----
110 -----END PGP MESSAGE-----
112 ERROR: Corrupt ascii-armor
113 -- corrupt (no empty line)
114 select * from pgp_armor_headers('
115 -----BEGIN PGP MESSAGE-----
118 -----END PGP MESSAGE-----
120 ERROR: Corrupt ascii-armor
122 select * from pgp_armor_headers('
123 -----BEGIN PGP MESSAGE-----
127 -----END PGP MESSAGE-----
133 -- header with empty value
134 select * from pgp_armor_headers('
135 -----BEGIN PGP MESSAGE-----
140 -----END PGP MESSAGE-----
148 select * from pgp_armor_headers('
149 -----BEGIN PGP MESSAGE-----
155 -----END PGP MESSAGE-----
163 -- insane keys, part 1
164 select * from pgp_armor_headers('
165 -----BEGIN PGP MESSAGE-----
170 -----END PGP MESSAGE-----
173 -------------+-------
177 -- insane keys, part 2
178 select * from pgp_armor_headers('
179 -----BEGIN PGP MESSAGE-----
180 insane:key : text value here
184 -----END PGP MESSAGE-----
187 -------------+-----------------
188 insane:key | text value here
192 select * from pgp_armor_headers('
193 -----BEGIN PGP MESSAGE-----
194 long: this value is more than 76 characters long, but it should still parse correctly as that''s permitted by RFC 4880
198 -----END PGP MESSAGE-----
201 ------+-----------------------------------------------------------------------------------------------------------------
202 long | this value is more than 76 characters long, but it should still parse correctly as that's permitted by RFC 4880
205 -- long value, split up
206 select * from pgp_armor_headers('
207 -----BEGIN PGP MESSAGE-----
208 long: this value is more than 76 characters long, but it should still
209 long: parse correctly as that''s permitted by RFC 4880
213 -----END PGP MESSAGE-----
216 ------+------------------------------------------------------------------
217 long | this value is more than 76 characters long, but it should still
218 long | parse correctly as that's permitted by RFC 4880
221 -- long value, split up, part 2
222 select * from pgp_armor_headers('
223 -----BEGIN PGP MESSAGE-----
224 long: this value is more than
225 long: 76 characters long, but it should still
226 long: parse correctly as that''s permitted by RFC 4880
230 -----END PGP MESSAGE-----
233 ------+-------------------------------------------------
234 long | this value is more than
235 long | 76 characters long, but it should still
236 long | parse correctly as that's permitted by RFC 4880
239 -- long value, split up, part 3
240 select * from pgp_armor_headers('
241 -----BEGIN PGP MESSAGE-----
243 long: this value is more than
245 long: 76 characters long, but it should still
247 long: parse correctly as that''s permitted by RFC 4880
252 -----END PGP MESSAGE-----
255 ----------+-------------------------------------------------
257 long | this value is more than
259 long | 76 characters long, but it should still
261 long | parse correctly as that's permitted by RFC 4880
265 select * from pgp_armor_headers('
266 -----BEGIN PGP MESSAGE-----
267 Comment: dat1.blowfish.sha1.mdc.s2k3.z0
269 jA0EBAMCfFNwxnvodX9g0jwB4n4s26/g5VmKzVab1bX1SmwY7gvgvlWdF3jKisvS
270 yA6Ce1QTMK3KdL2MPfamsTUSAML8huCJMwYQFfE=
272 -----END PGP MESSAGE-----
275 ---------+--------------------------------
276 Comment | dat1.blowfish.sha1.mdc.s2k3.z0
279 -- test CR+LF line endings
280 select * from pgp_armor_headers(replace('
281 -----BEGIN PGP MESSAGE-----
287 -----END PGP MESSAGE-----
295 -- test header generation
296 select armor('zooka', array['foo'], array['bar']);
298 -----------------------------
299 -----BEGIN PGP MESSAGE-----+
304 -----END PGP MESSAGE----- +
308 select armor('zooka', array['Version', 'Comment'], array['Created by pgcrypto', 'PostgreSQL, the world''s most advanced open source database']);
310 ---------------------------------------------------------------------
311 -----BEGIN PGP MESSAGE----- +
312 Version: Created by pgcrypto +
313 Comment: PostgreSQL, the world's most advanced open source database+
317 -----END PGP MESSAGE----- +
321 select * from pgp_armor_headers(
322 armor('zooka', array['Version', 'Comment'],
323 array['Created by pgcrypto', 'PostgreSQL, the world''s most advanced open source database']));
325 ---------+------------------------------------------------------------
326 Version | Created by pgcrypto
327 Comment | PostgreSQL, the world's most advanced open source database
330 -- error/corner cases
331 select armor('', array['foo'], array['too', 'many']);
332 ERROR: mismatched array dimensions
333 select armor('', array['too', 'many'], array['foo']);
334 ERROR: mismatched array dimensions
335 select armor('', array[['']], array['foo']);
336 ERROR: wrong number of array subscripts
337 select armor('', array['foo'], array[['']]);
338 ERROR: wrong number of array subscripts
339 select armor('', array[null], array['foo']);
340 ERROR: null value not allowed for header key
341 select armor('', array['foo'], array[null]);
342 ERROR: null value not allowed for header value
343 select armor('', '[0:0]={"foo"}', array['foo']);
345 -----------------------------
346 -----BEGIN PGP MESSAGE-----+
350 -----END PGP MESSAGE----- +
354 select armor('', array['foo'], '[0:0]={"foo"}');
356 -----------------------------
357 -----BEGIN PGP MESSAGE-----+
361 -----END PGP MESSAGE----- +
365 select armor('', array[E'embedded\nnewline'], array['foo']);
366 ERROR: header key must not contain newlines
367 select armor('', array['foo'], array[E'embedded\nnewline']);
368 ERROR: header value must not contain newlines
369 select armor('', array['embedded: colon+space'], array['foo']);
370 ERROR: header key must not contain ": "