summaryrefslogtreecommitdiffstats
path: root/contrib/pgcrypto/expected/pgp-armor.out
blob: 89d410a7dc0e1117c744d49adeb453b9989ddd5e (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
--
-- PGP Armor
--
-- ensure consistent test output regardless of the default bytea format
SET bytea_output TO escape;
select armor('');
            armor            
-----------------------------
 -----BEGIN PGP MESSAGE-----+
                            +
 =twTO                      +
 -----END PGP MESSAGE-----  +
 
(1 row)

select armor('test');
            armor            
-----------------------------
 -----BEGIN PGP MESSAGE-----+
                            +
 dGVzdA==                   +
 =+G7Q                      +
 -----END PGP MESSAGE-----  +
 
(1 row)

select dearmor(armor(''));
 dearmor 
---------
 
(1 row)

select dearmor(armor('zooka'));
 dearmor 
---------
 zooka
(1 row)

select armor('0123456789abcdef0123456789abcdef0123456789abcdef
0123456789abcdef0123456789abcdef0123456789abcdef');
                                    armor                                     
------------------------------------------------------------------------------
 -----BEGIN PGP MESSAGE-----                                                 +
                                                                             +
 MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmCjAxMjM0NTY3+
 ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmMDEyMzQ1Njc4OWFiY2RlZg==                    +
 =JFw5                                                                       +
 -----END PGP MESSAGE-----                                                   +
 
(1 row)

-- lots formatting
select dearmor(' a pgp msg:

-----BEGIN PGP MESSAGE-----
Comment: Some junk

em9va2E=

  =D5cR

-----END PGP MESSAGE-----');
 dearmor 
---------
 zooka
(1 row)

-- lots messages
select dearmor('
wrong packet:
  -----BEGIN PGP MESSAGE-----

  d3Jvbmc=
  =vCYP
  -----END PGP MESSAGE-----

right packet:
-----BEGIN PGP MESSAGE-----

cmlnaHQ=
=nbpj
-----END PGP MESSAGE-----

use only first packet
-----BEGIN PGP MESSAGE-----

d3Jvbmc=
=vCYP
-----END PGP MESSAGE-----
');
 dearmor 
---------
 right
(1 row)

-- bad crc
select dearmor('
-----BEGIN PGP MESSAGE-----

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
ERROR:  Corrupt ascii-armor
-- corrupt (no space after the colon)
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
foo:

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
ERROR:  Corrupt ascii-armor
-- corrupt (no empty line)
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
ERROR:  Corrupt ascii-armor
-- no headers
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
 key | value 
-----+-------
(0 rows)

-- header with empty value
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
foo: 

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
 key | value 
-----+-------
 foo | 
(1 row)

-- simple
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
fookey: foovalue
barkey: barvalue

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
  key   |  value   
--------+----------
 fookey | foovalue
 barkey | barvalue
(2 rows)

-- insane keys, part 1
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
insane:key : 

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
     key     | value 
-------------+-------
 insane:key  | 
(1 row)

-- insane keys, part 2
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
insane:key : text value here

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
     key     |      value      
-------------+-----------------
 insane:key  | text value here
(1 row)

-- long value
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
long: this value is more than 76 characters long, but it should still parse correctly as that''s permitted by RFC 4880

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
 key  |                                                      value                                                      
------+-----------------------------------------------------------------------------------------------------------------
 long | this value is more than 76 characters long, but it should still parse correctly as that's permitted by RFC 4880
(1 row)

-- long value, split up
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
long: this value is more than 76 characters long, but it should still 
long: parse correctly as that''s permitted by RFC 4880

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
 key  |                              value                               
------+------------------------------------------------------------------
 long | this value is more than 76 characters long, but it should still 
 long | parse correctly as that's permitted by RFC 4880
(2 rows)

-- long value, split up, part 2
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
long: this value is more than 
long: 76 characters long, but it should still 
long: parse correctly as that''s permitted by RFC 4880

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
 key  |                      value                      
------+-------------------------------------------------
 long | this value is more than 
 long | 76 characters long, but it should still 
 long | parse correctly as that's permitted by RFC 4880
(3 rows)

-- long value, split up, part 3
select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
emptykey: 
long: this value is more than 
emptykey: 
long: 76 characters long, but it should still 
emptykey: 
long: parse correctly as that''s permitted by RFC 4880
emptykey: 

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
   key    |                      value                      
----------+-------------------------------------------------
 emptykey | 
 long     | this value is more than 
 emptykey | 
 long     | 76 characters long, but it should still 
 emptykey | 
 long     | parse correctly as that's permitted by RFC 4880
 emptykey | 
(7 rows)

select * from pgp_armor_headers('
-----BEGIN PGP MESSAGE-----
Comment: dat1.blowfish.sha1.mdc.s2k3.z0

jA0EBAMCfFNwxnvodX9g0jwB4n4s26/g5VmKzVab1bX1SmwY7gvgvlWdF3jKisvS
yA6Ce1QTMK3KdL2MPfamsTUSAML8huCJMwYQFfE=
=JcP+
-----END PGP MESSAGE-----
');
   key   |             value              
---------+--------------------------------
 Comment | dat1.blowfish.sha1.mdc.s2k3.z0
(1 row)

-- test CR+LF line endings
select * from pgp_armor_headers(replace('
-----BEGIN PGP MESSAGE-----
fookey: foovalue
barkey: barvalue

em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
', E'\n', E'\r\n'));
  key   |  value   
--------+----------
 fookey | foovalue
 barkey | barvalue
(2 rows)

-- test header generation
select armor('zooka', array['foo'], array['bar']);
            armor            
-----------------------------
 -----BEGIN PGP MESSAGE-----+
 foo: bar                   +
                            +
 em9va2E=                   +
 =D5cR                      +
 -----END PGP MESSAGE-----  +
 
(1 row)

select armor('zooka', array['Version', 'Comment'], array['Created by pgcrypto', 'PostgreSQL, the world''s most advanced open source database']);
                                armor                                
---------------------------------------------------------------------
 -----BEGIN PGP MESSAGE-----                                        +
 Version: Created by pgcrypto                                       +
 Comment: PostgreSQL, the world's most advanced open source database+
                                                                    +
 em9va2E=                                                           +
 =D5cR                                                              +
 -----END PGP MESSAGE-----                                          +
 
(1 row)

select * from pgp_armor_headers(
  armor('zooka', array['Version', 'Comment'],
                 array['Created by pgcrypto', 'PostgreSQL, the world''s most advanced open source database']));
   key   |                           value                            
---------+------------------------------------------------------------
 Version | Created by pgcrypto
 Comment | PostgreSQL, the world's most advanced open source database
(2 rows)

-- error/corner cases
select armor('', array['foo'], array['too', 'many']);
ERROR:  mismatched array dimensions
select armor('', array['too', 'many'], array['foo']);
ERROR:  mismatched array dimensions
select armor('', array[['']], array['foo']);
ERROR:  wrong number of array subscripts
select armor('', array['foo'], array[['']]);
ERROR:  wrong number of array subscripts
select armor('', array[null], array['foo']);
ERROR:  null value not allowed for header key
select armor('', array['foo'], array[null]);
ERROR:  null value not allowed for header value
select armor('', '[0:0]={"foo"}', array['foo']);
            armor            
-----------------------------
 -----BEGIN PGP MESSAGE-----+
 foo: foo                   +
                            +
 =twTO                      +
 -----END PGP MESSAGE-----  +
 
(1 row)

select armor('', array['foo'], '[0:0]={"foo"}');
            armor            
-----------------------------
 -----BEGIN PGP MESSAGE-----+
 foo: foo                   +
                            +
 =twTO                      +
 -----END PGP MESSAGE-----  +
 
(1 row)

select armor('', array[E'embedded\nnewline'], array['foo']);
ERROR:  header key must not contain newlines
select armor('', array['foo'], array[E'embedded\nnewline']);
ERROR:  header value must not contain newlines
select armor('', array['embedded: colon+space'], array['foo']);
ERROR:  header key must not contain ": "