postgresql/contrib/pgcrypto/expected/pgp-armor.out

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

371 lines
9.2 KiB
Plaintext
Raw Normal View History

--
-- PGP Armor
--
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 encode(dearmor(armor('')), 'escape');
encode
--------
(1 row)
select encode(dearmor(armor('zooka')), 'escape');
encode
--------
zooka
(1 row)
select armor('0123456789abcdef0123456789abcdef0123456789abcdef
0123456789abcdef0123456789abcdef0123456789abcdef');
armor
------------------------------------------------------------------------------
-----BEGIN PGP MESSAGE----- +
+
MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmCjAxMjM0NTY3+
ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmMDEyMzQ1Njc4OWFiY2RlZg== +
=JFw5 +
-----END PGP MESSAGE----- +
(1 row)
-- lots formatting
select encode(dearmor(' a pgp msg:
-----BEGIN PGP MESSAGE-----
Comment: Some junk
em9va2E=
=D5cR
-----END PGP MESSAGE-----'), 'escape');
encode
--------
zooka
(1 row)
-- lots messages
select encode(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-----
'), 'escape');
encode
--------
right
(1 row)
-- bad crc
select dearmor('
-----BEGIN PGP MESSAGE-----
em9va2E=
=ZZZZ
-----END PGP MESSAGE-----
');
The large one adds support for RSA keys and reorganizes the pubkey functions a bit. The actual RSA-specific code there is tiny, most of the patch consists of reorg of the pubkey code, as lots of it was written as elgamal-only. --------------------------------------------------------------------------- The SHLIB section was copy-pasted from somewhere and contains several unnecessary libs. This cleans it up a bit. -lcrypt we don't use system crypt() -lssl, -lssleay32 no SSL here -lz in win32 section already added on previous line -ldes The chance anybody has it is pretty low. And the chance pgcrypto works with it is even lower. Also trim the win32 section. --------------------------------------------------------------------------- It is already disabled in Makefile, remove code too. --------------------------------------------------------------------------- I was bit hasty making the random exponent 'k' a prime. Further researh shows that Elgamal encryption has no specific needs in respect to k, any random number is fine. It is bit different for signing, there it needs to be 'relatively prime' to p - 1, that means GCD(k, p-1) == 1, which is also a lot lighter than full primality. As we don't do signing, this can be ignored. This brings major speedup to Elgamal encryption. --------------------------------------------------------------------------- o pgp_mpi_free: Accept NULLs o pgp_mpi_cksum: result should be 16bit o Remove function name from error messages - to be similar to other SQL functions, and it does not match anyway the called function o remove couple junk lines --------------------------------------------------------------------------- o Support for RSA encryption o Big reorg to better separate generic and algorithm-specific code. o Regression tests for RSA. --------------------------------------------------------------------------- o Tom stuck a CVS id into file. I doubt the usefulness of it, but if it needs to be in the file then rather at the end. Also tag it as comment for asciidoc. o Mention bytea vs. text difference o Couple clarifications --------------------------------------------------------------------------- There is a choice whether to update it with pgp functions or remove it. I decided to remove it, updating is pointless. I've tried to keep the core of pgcrypto relatively independent from main PostgreSQL, to make it easy to use externally if needed, and that is good. Eg. that made development of PGP functions much nicer. But I have no plans to release it as generic library, so keeping such doc up-to-date is waste of time. If anyone is interested in using it in other products, he can probably bother to read the source too. Commented source is another thing - I'll try to make another pass over code to see if there is anything non-obvious that would need more comments. --------------------------------------------------------------------------- Marko Kreen
2005-08-13 04:06:21 +02:00
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 ": "