summaryrefslogtreecommitdiff
path: root/contrib/pgcrypto
AgeCommit message (Collapse)Author
2007-01-14Replace unnecessary DISABLE_ZLIB define in pgcrypto with HAVE_LIBZ from core.Alvaro Herrera
Patch from Marko Kreen.
2006-11-10Minor code cleanup for pgcrypto: for UDFs declared to be strict, checkingNeil Conway
for NULL-ness of function arguments is wasted code.
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-09-22Fix bugs in plpgsql and ecpg caused by assuming that isspace() would onlyTom Lane
return true for exactly the characters treated as whitespace by their flex scanners. Per report from Victor Snezhko and subsequent investigation. Also fix a passel of unsafe usages of <ctype.h> functions, that is, ye olde char-vs-unsigned-char issue. I won't miss <ctype.h> when we are finally able to stop using it.
2006-09-05Silence compiler warnings about incompatible function pointer types.Tom Lane
2006-09-05Remove pgcrypto functions that were deprecated and slated for removal.Tom Lane
Marko Kreen
2006-08-05Fix references to the Options section in the pgcrypto documentation.Neil Conway
Patch from Michael Fuhr.
2006-07-19pgcrypto merge cleanup:Neil Conway
- Few README fixes - Keep imath Id string, put $PostgreSQL$ separately. Patch from Marko Kreen.
2006-07-16Fix a few places where $Id$ and $Header$ CVS tags had crept into theTom Lane
source tree. They should all be $PostgreSQL$ of course.
2006-07-15Fix some pgcrypto portability issues, per Marko Kreen.Tom Lane
2006-07-14In PGP public key tests, encrypt the secret key with AES not CAST5,Tom Lane
so that the test passes with or without OpenSSL. Marko Kreen
2006-07-13Fix C++-style comment.Neil Conway
2006-07-13"Annual" pgcrypto update from Marko Kreen:Neil Conway
Few cleanups and couple of new things: - add SHA2 algorithm to older OpenSSL - add BIGNUM math to have public-key cryptography work on non-OpenSSL build. - gen_random_bytes() function The status of SHA2 algoritms and public-key encryption can now be changed to 'always available.' That makes pgcrypto functionally complete and unless there will be new editions of AES, SHA2 or OpenPGP standards, there is no major changes planned.
2006-07-10Allow /contrib include files to compile on their own.Bruce Momjian
2006-06-08Add missing 3rd argument to open().Bruce Momjian
2006-05-30Magic blocks don't do us any good unless we use 'em ... so install oneTom Lane
in every shared library.
2006-05-30Re-defines SHA2 symbols so that they would not conflict with certainBruce Momjian
versions of OpenSSL. If your OpenSSL does not contain SHA2, then there should be no conflict. But ofcourse, if someone upgrades OpenSSL, server starts crashing. Backpatched to 8.1.X. Marko Kreen
2006-05-21Fix errors in fortuna PRNG reseeding logic that could cause a predictableTom Lane
session key to be selected by pgp_sym_encrypt() in some cases. This only affects non-OpenSSL-using builds. Marko Kreen
2006-03-11Add CVS tag lines to files that were lacking them.Bruce Momjian
2006-03-08Update /contrib regression tests for escape_string_warning.Bruce Momjian
2006-02-27Clean up CREATE FUNCTION syntax usage in contrib and elsewhere, inPeter Eisentraut
particular get rid of single quotes around language names and old WITH () construct.
2006-02-18Patch from Marko Kreen:Neil Conway
pgcrypto crypt()/md5 and hmac() leak memory when compiled against OpenSSL as openssl.c digest ->reset will do two DigestInit calls against a context. This happened to work with OpenSSL 0.9.6 but not with 0.9.7+. Reason for the messy code was that I tried to avoid creating wrapper structure to transport algorithm info and tried to use OpenSSL context for it. The fix is to create wrapper structure. It also uses newer digest API to avoid memory allocations on reset with newer OpenSSLs. Thanks to Daniel Blaisdell for reporting it.
2006-02-10Fix fallout from psql line-wrapping patch.Tom Lane
2006-01-03There is a signedness bug in Openwall gen_salt code that pgcrypto uses.Tom Lane
This makes the salt space for md5 and xdes algorithms a lot smaller than it should be. Marko Kreen
2005-11-22Re-run pgindent, fixing a problem where comment lines after a blankBruce Momjian
comment line where output as too long, and update typedefs for /lib directory. Also fix case where identifiers were used as variable names in the backend, but as typedefs in ecpg (favor the backend for indenting). Backpatch to 8.1.X.
2005-11-03pgcrypto documentation polishing from Marko Kreen, and a small amountTom Lane
of copy-editing from myself.
2005-10-15Standard pgindent run for 8.1.Bruce Momjian
2005-09-27PGXS should be set with := not =, as specified in the documentation,Tom Lane
to avoid useless multiple executions of pg_config.
2005-09-24Suppress signed-vs-unsigned-char warnings in contrib.Tom Lane
2005-08-13Remove API file.Bruce Momjian
Marko Kreen
2005-08-13The large one adds support for RSA keys and reorganizesBruce Momjian
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-07-18pgcrypto documentation update. Marko KreenTom Lane
2005-07-18Fortuna fixes. Marko KreenTom Lane
2005-07-18Small cleanups for pgcrypto. Marko KreenTom Lane
2005-07-18Fix C++-style comments, per Rocco Altier.Tom Lane
2005-07-12More pgcrypto fixes: handle long messages correctly, suppressTom Lane
compiler warnings. Marko Kreen and Kris Jurka.
2005-07-11Further tweaking of Win32-specific random code. Marko KreenTom Lane
2005-07-11I forgot to update win32 code when doing a renaming in random.c.Tom Lane
Marko Kreen
2005-07-11Avoid bzero/bxopy in favor of more standard library routines.Tom Lane
Marko Kreen
2005-07-11More pgcrypto fixes: avoid bogus alignment assumptions in sha2,Tom Lane
be more wary about having a value for BYTE_ORDER, clean up randomly- chosen ways of including Postgres core headers. Marko Kreen and Tom Lane
2005-07-11Add support for AES cipher with older OpenSSL libraries.Tom Lane
Marko Kreen
2005-07-10> One more failure:Bruce Momjian
> > I think this is because we don't have -lz in SHLIB_LINK. > Following patch fixes it. Marko Kreen
2005-07-10Suppress compile warning.Tom Lane
2005-07-10Remove #include <openssl/bn.h> as compile fix.Bruce Momjian
Marko Kreen
2005-07-10As Kris Jurka found out, pgcrypto does not work withBruce Momjian
OpenSSL 0.9.6x. The DES functions use the older 'des_' API, but the newer 3DES functions use the 0.9.7x-only 'DES_' API. I think I just used /usr/include/openssl/des.h for reference when implementing them, and had upgraded OpenSSL in the meantime. Following patch converts DES also to newer API and provides compatibility functions for OpenSSL < 0.9.7. I chose this route because: - openssl.c uses few DES functions. - compatibility for old 'des_' API is going away at some point of time from OpenSSL. - as seen from macros, new API is saner - Thus pgcrypto supports any OpenSSL version from 0.9.5 to 1.0 Tested with OpenSSL 0.9.6c and 0.9.7e. Marko Kreen
2005-07-10Add missing pgcrypto files from previous commit.Bruce Momjian
2005-07-10Major pgcrypto changes:Bruce Momjian
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- Add Fortuna PRNG to pgcrypto.Bruce Momjian
- Move openssl random provider to openssl.c and builtin provider to internal.c - Make px_random_bytes use Fortuna, instead of giving error. - Retarget random.c to aquiring system randomness, for initial seeding of Fortuna. There is ATM 2 functions for Windows, reader from /dev/urandom and the regular time()/getpid() silliness. Marko Kreen
2005-07-10This patch adds implementation of SHA2 to pgcrypto.Bruce Momjian
New hashes: SHA256, SHA384, SHA512. Marko Kreen
2005-07-08This patch updates the DDL for contrib/pgcrypto to create allNeil Conway
functions as STRICT, and all functions except gen_salt() as IMMUTABLE. gen_salt() is VOLATILE. Although the functions are now STRICT, I left their PG_ARGISNULL() checks in place as a protective measure for users who install the new code but use old (non-STRICT) catalog entries (e.g., restored from a dump). Per recent discussion in pgsql-hackers. Patch from Michael Fuhr.