postgresql/contrib
Bruce Momjian 73e2431817 Major pgcrypto changes:
of password-based encryption from RFC2440 (OpenPGP).

The goal of this code is to be more featureful encryption solution
than current encrypt(), which only functionality is running cipher
over data.

Compared to encrypt(), pgp_encrypt() does following:

* It uses the equvialent of random Inital Vector to get cipher
  into random state before it processes user data
* Stores SHA-1 of the data into result so any modification
  will be detected.
* Remembers if data was text or binary - thus it can decrypt
  to/from text data.  This was a major nuisance for encrypt().
* Stores info about used algorithms with result, so user needs
  not remember them - more user friendly!
* Uses String2Key algorithms (similar to crypt()) with random salt
  to generate full-length binary key to be used for encrypting.
* Uses standard format for data - you can feed it to GnuPG, if needed.

Optional features (off by default):

* Can use separate session key - user data will be encrypted
  with totally random key, which will be encrypted with S2K
  generated key and attached to result.
* Data compression with zlib.
* Can convert between CRLF<->LF line-endings - to get fully
  RFC2440-compliant behaviour.  This is off by default as
  pgcrypto does not know the line-endings of user data.

Interface is simple:


    pgp_encrypt(data text, key text) returns bytea
    pgp_decrypt(data text, key text) returns text
    pgp_encrypt_bytea(data bytea, key text) returns bytea
    pgp_decrypt_bytea(data bytea, key text) returns bytea

To change parameters (cipher, compression, mdc):

    pgp_encrypt(data text, key text, parms text) returns bytea
    pgp_decrypt(data text, key text, parms text) returns text
    pgp_encrypt_bytea(data bytea, key text, parms text) returns bytea
    pgp_decrypt_bytea(data bytea, key text, parms text) returns bytea

Parameter names I lifted from gpg:

   pgp_encrypt('message', 'key', 'compress-algo=1,cipher-algo=aes256')

For text data, pgp_encrypt simply encrypts the PostgreSQL internal data.

This maps to RFC2440 data type 't' - 'extenally specified encoding'.
But this may cause problems if data is dumped and reloaded into database
which as different internal encoding.  My next goal is to implement data
type 'u' - which means data is in UTF-8 encoding by converting internal
encoding to UTF-8 and back.  And there wont be any compatibility
problems with current code, I think its ok to submit this without UTF-8
encoding by converting internal encoding to UTF-8 and back.  And there
wont be any compatibility problems with current code, I think its ok to
submit this without UTF-8 support.


Here is v4 of PGP encrypt.  This depends on previously sent
Fortuna-patch, as it uses the px_add_entropy function.

- New function: pgp_key_id() for finding key id's.
- Add SHA1 of user data and key into RNG pools.  We need to get
  randomness from somewhere, and it is in user best interests
  to contribute.
- Regenerate pgp-armor test for SQL_ASCII database.
- Cleanup the key handling so that the pubkey support is less
  hackish.

Marko Kreen
2005-07-10 03:57:55 +00:00
..
adddepend make sure the $Id tags are converted to $PostgreSQL as well ... 2003-11-29 22:41:33 +00:00
btree_gist Fixes from Janko Richter <jankorichter@yahoo.de> 2005-07-01 13:44:56 +00:00
chkpass Make sure contrib C functions are marked strict where needed. 2005-01-29 22:35:02 +00:00
cube Remove the << >> &< and &> operators for contrib/cube, which were 2005-06-27 01:19:43 +00:00
dbase Clean up bogus checking of date and numeric fields in DBF files, 2005-05-27 15:44:04 +00:00
dblink Cause initdb to create a third standard database "postgres", which 2005-06-21 04:02:34 +00:00
dbmirror Convert oidvector and int2vector into variable-length arrays. This 2005-03-29 00:17:27 +00:00
dbsize Arrange for the postmaster (and standalone backends, initdb, etc) to 2005-07-04 04:51:52 +00:00
earthdistance Refer to ll_to_earth() function by its actual name. 2004-10-04 22:52:47 +00:00
fulltextindex > Please find enclose a submission to fix these problems. 2004-08-20 20:13:10 +00:00
fuzzystrmatch The attached patch implements the soundex difference function which 2005-01-26 08:04:04 +00:00
intagg Treat a zero-D array as empty in int_enum(), per Andrew@supernews. 2005-04-23 17:55:50 +00:00
intarray Add parentheses to macros when args are used in computations. Without 2005-05-25 21:40:43 +00:00
isbn_issn Make sure contrib C functions are marked strict where needed. 2005-01-29 22:35:02 +00:00
lo Cleanup the contrib/lo module: there is no need anymore to implement 2005-06-23 00:06:37 +00:00
ltree Add parentheses to macros when args are used in computations. Without 2005-05-25 21:40:43 +00:00
mSQL-interface Consistently use geteuid() not getuid(); there were a few places deviating 2005-01-08 22:51:15 +00:00
mac make sure the $Id tags are converted to $PostgreSQL as well ... 2003-11-29 22:41:33 +00:00
oid2name Cause initdb to create a third standard database "postgres", which 2005-06-21 04:02:34 +00:00
oracle Triggers should return TRIGGER not OPAQUE. Looks like this script got 2004-12-30 00:30:40 +00:00
pg_autovacuum Fix display of database name during autovacuum. 2005-06-15 13:55:23 +00:00
pg_buffercache Change relblocknumber field of pg_buffercache view from numeric to int8 2005-05-31 00:07:47 +00:00
pg_trgm Cleanup of GiST extensions in contrib/: now that we always invoke GiST 2005-05-21 12:08:06 +00:00
pgbench Correct a thinko in pgbench that might result in incorrectly ignoring an 2005-05-24 00:26:40 +00:00
pgcrypto Major pgcrypto changes: 2005-07-10 03:57:55 +00:00
pgstattuple Document get_call_result_type() and friends; mark TypeGetTupleDesc() 2005-05-30 23:09:07 +00:00
reindexdb Cause initdb to create a third standard database "postgres", which 2005-06-21 04:02:34 +00:00
seg Adjust contrib/seg &< and &> operators so that r-tree indexing logic 2005-06-27 00:48:07 +00:00
spi Clean up the rather historically encumbered interface to now() and 2005-06-29 22:51:57 +00:00
start-scripts Adjust postmaster to recognize that a lockfile containing its parent's PID 2004-10-01 18:30:25 +00:00
tablefunc Fix inadequate error checking: you can't assume that fcinfo->resultinfo 2005-07-09 01:53:22 +00:00
tips > Please find enclose a submission to fix these problems. 2004-08-20 20:13:10 +00:00
tsearch2 Add E'' syntax so eventually normal strings can treat backslashes 2005-06-26 03:04:37 +00:00
userlock Simplify shared-memory lock data structures as per recent discussion: 2005-06-14 22:15:33 +00:00
vacuumlo Cleanup the contrib/lo module: there is no need anymore to implement 2005-06-23 00:06:37 +00:00
xml2 Fix inadequate error checking: you can't assume that fcinfo->resultinfo 2005-07-09 01:53:22 +00:00
Makefile Remove contrib version of rtree_gist --- now in core system. 2005-07-01 19:23:07 +00:00
README Remove contrib version of rtree_gist --- now in core system. 2005-07-01 19:23:07 +00:00
contrib-global.mk Add a --dbname option to the pg_regress script, and use pl_regression 2005-05-17 18:26:23 +00:00

README

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly because
they address a limited audience or are too experimental to be part of
the main source tree.  This does not preclude their usefulness.

Each subdirectory contains a README file with information about the
module.  Most items can be built with `gmake all' and installed with
`gmake install' in the usual fashion, after you have run the `configure'
script in the top-level directory.  Some directories supply new
user-defined functions, operators, or types.  In these cases, after you have
installed the files you need to register the new entities in the database
system by running the commands in the supplied .sql file.  For example,

	$ psql -d dbname -f module.sql

See the PostgreSQL documentation for more information about this
procedure.


Index:
------

adddepend -
	Add object dependency information to pre-7.3 objects.
	by Rod Taylor <rbt@rbt.ca>

btree_gist -
	Support for emulating BTREE indexing in GiST
	by Oleg Bartunov <oleg@sai.msu.su> and Teodor Sigaev <teodor@sigaev.ru>

chkpass -
	An auto-encrypted password datatype
	by D'Arcy J.M. Cain <darcy@druid.net>

cube -
	Multidimensional-cube datatype (GiST indexing example)
	by Gene Selkov, Jr. <selkovjr@mcs.anl.gov>

dbase -
	Converts from dbase/xbase to PostgreSQL
	by Maarten.Boekhold <Maarten.Boekhold@reuters.com>,
	   Frank Koormann <fkoorman@usf.uni-osnabrueck.de>,
	   Ivan Baldo <lubaldo@adinet.com.uy>

dblink -
	Allows remote query execution
	by Joe Conway <mail@joeconway.com>

dbmirror -
	Replication server
	by Steven Singer <ssinger@navtechinc.com>

dbsize -
	Reports database and table disk space
	by Peter Eisentraut <peter_e@gmx.net>

earthdistance -
	Operator for computing earth distance for two points
	by Hal Snyder <hal@vailsys.com>

fulltextindex -
	Full text indexing using triggers
	by Maarten Boekhold <maartenb@dutepp0.et.tudelft.nl>

fuzzystrmatch -
	Levenshtein, metaphone, and soundex fuzzy string matching
	by Joe Conway <mail@joeconway.com>, Joel Burton <jburton@scw.org>

intagg -
	Integer aggregator
	by mlw <markw@mohawksoft.com>

intarray -
	Index support for arrays of int4, using GiST
	by Teodor Sigaev <teodor@sigaev.ru> and Oleg Bartunov <oleg@sai.msu.su>

isbn_issn -
	PostgreSQL type extensions for ISBN (books) and ISSN (serials)
	by Garrett A. Wollman <wollman@khavrinen.lcs.mit.edu>

lo -
	Large Object maintenance
	by Peter Mount <peter@retep.org.uk> 

ltree -
	Tree-like data structures
	by Teodor Sigaev <teodor@sigaev.ru> and Oleg Bartunov <oleg@sai.msu.su>

mSQL-interface -
	mSQL API translation library
	by Aldrin Leal <aldrin@americasnet.com>

mac -
	Support functions for MAC address types
	by Lawrence E. Rosenman <ler@lerctr.org>

oid2name - 
	Maps numeric files to table names
	by B Palmer <bpalmer@crimelabs.net>

oracle -
	Converts Oracle database schema to PostgreSQL
	by Gilles Darold <gilles@darold.net>

pg_autovacuum -
	Automatically performs vacuum
	by Matthew T. O'Connor <matthew@zeut.net>

pg_buffercache -
	Real time queries on the shared buffer cache
	by Mark Kirkwood <markir@paradise.net.nz>

pg_trgm -
	Functions for determining the similarity of text based on trigram
	matching.
	by Oleg Bartunov <oleg@sai.msu.su> and Teodor Sigaev <teodor@sigaev.ru>

pgbench -
	TPC-B like benchmarking tool
	by Tatsuo Ishii <t-ishii@sra.co.jp>

pgcrypto -
	Cryptographic functions
	by Marko Kreen <marko@l-t.ee>

pgstattuple -
	A function to return statistics about "dead" tuples and free
	space within a table
	by Tatsuo Ishii <t-ishii@sra.co.jp>

reindexdb - 
	Reindexes a database
	by Shaun Thomas <sthomas@townnews.com>

seg -
	Confidence-interval datatype (GiST indexing example)
	by Gene Selkov, Jr. <selkovjr@mcs.anl.gov>

spi -
	Various trigger functions, examples for using SPI.

start-scripts - 
	Scripts for starting the server at boot time.

tablefunc -
	Examples of functions returning tables
	by Joe Conway <mail@joeconway.com>

tips/apache_logging -
	Getting Apache to log to PostgreSQL
	by Terry Mackintosh <terry@terrym.com>

tsearch2 -
	Full-text-index support using GiST
	by Teodor Sigaev <teodor@sigaev.ru> and Oleg Bartunov
	<oleg@sai.msu.su>.

userlock -
	User locks
	by Massimo Dal Zotto <dz@cs.unitn.it>

vacuumlo -
	Remove orphaned large objects
	by Peter T Mount <peter@retep.org.uk>

xml2 -
	Storing XML in PostgreSQL
	by John Gray <jgray@azuli.co.uk>