This package seems to be very good, it includes all kind of asymetric
encryption/decryption functions, and data types to store keys into
postgresql tables.
It still unfinished, but maybe it already incorporates the functionality
your looking for.
Docs:
http://www.dimensional.com/~bgiles/pkixdoc/book1.html
Download:
http://www.dimensional.com/~bgiles/index1.html
hope it helps.