2005-07-10 21:46:29 +08:00
|
|
|
--
|
|
|
|
-- PGP Armor
|
|
|
|
--
|
|
|
|
select armor('');
|
2006-02-10 23:47:44 +08:00
|
|
|
armor
|
|
|
|
-----------------------------
|
2005-07-10 21:46:29 +08:00
|
|
|
-----BEGIN PGP MESSAGE-----
|
2006-02-10 23:47:44 +08:00
|
|
|
|
|
|
|
=twTO
|
|
|
|
-----END PGP MESSAGE-----
|
|
|
|
|
2005-07-10 21:46:29 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
select armor('test');
|
2006-02-10 23:47:44 +08:00
|
|
|
armor
|
|
|
|
-----------------------------
|
2005-07-10 21:46:29 +08:00
|
|
|
-----BEGIN PGP MESSAGE-----
|
2006-02-10 23:47:44 +08:00
|
|
|
|
|
|
|
dGVzdA==
|
|
|
|
=+G7Q
|
|
|
|
-----END PGP MESSAGE-----
|
|
|
|
|
2005-07-10 21:46:29 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
select dearmor(armor(''));
|
|
|
|
dearmor
|
|
|
|
---------
|
2006-02-10 23:47:44 +08:00
|
|
|
|
2005-07-10 21:46:29 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
select dearmor(armor('zooka'));
|
|
|
|
dearmor
|
|
|
|
---------
|
2006-02-10 23:47:44 +08:00
|
|
|
zooka
|
2005-07-10 21:46:29 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
select armor('0123456789abcdef0123456789abcdef0123456789abcdef
|
|
|
|
0123456789abcdef0123456789abcdef0123456789abcdef');
|
2006-02-10 23:47:44 +08:00
|
|
|
armor
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
-----BEGIN PGP MESSAGE-----
|
|
|
|
|
|
|
|
MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmCjAxMjM0NTY3
|
|
|
|
ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmMDEyMzQ1Njc4OWFiY2RlZg==
|
|
|
|
=JFw5
|
|
|
|
-----END PGP MESSAGE-----
|
|
|
|
|
2005-07-10 21:46:29 +08:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- lots formatting
|
|
|
|
select dearmor(' a pgp msg:
|
|
|
|
|
|
|
|
-----BEGIN PGP MESSAGE-----
|
|
|
|
Comment: Some junk
|
|
|
|
|
|
|
|
em9va2E=
|
|
|
|
|
|
|
|
=D5cR
|
|
|
|
|
|
|
|
-----END PGP MESSAGE-----');
|
|
|
|
dearmor
|
|
|
|
---------
|
2006-02-10 23:47:44 +08:00
|
|
|
zooka
|
2005-07-10 21:46:29 +08:00
|
|
|
(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
|
|
|
|
---------
|
2006-02-10 23:47:44 +08:00
|
|
|
right
|
2005-07-10 21:46:29 +08:00
|
|
|
(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 10:06:21 +08:00
|
|
|
ERROR: Corrupt ascii-armor
|