Skip to content
Snippets Groups Projects
  1. Aug 15, 2005
  2. Aug 13, 2005
    • Bruce Momjian's avatar
      Remove API file. · f547909d
      Bruce Momjian authored
      Marko Kreen
      f547909d
    • Bruce Momjian's avatar
      The large one adds support for RSA keys and reorganizes · 87688ddf
      Bruce Momjian authored
      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
      87688ddf
  3. Jul 29, 2005
  4. Jul 25, 2005
  5. Jul 21, 2005
  6. Jul 20, 2005
  7. Jul 18, 2005
  8. Jul 14, 2005
  9. Jul 12, 2005
  10. Jul 11, 2005
  11. Jul 10, 2005
    • Bruce Momjian's avatar
      > One more failure: · 2e330699
      Bruce Momjian authored
      >
      > I think this is because we don't have -lz in SHLIB_LINK.
      > Following patch fixes it.
      
      Marko Kreen
      2e330699
    • Bruce Momjian's avatar
      Add extra argument for new pg_regexec API. · 21634e51
      Bruce Momjian authored
      21634e51
    • Tom Lane's avatar
      Suppress compile warning. · aacfeba6
      Tom Lane authored
      aacfeba6
    • Bruce Momjian's avatar
      Remove #include <openssl/bn.h> as compile fix. · 6e1004f0
      Bruce Momjian authored
      Marko Kreen
      6e1004f0
    • Bruce Momjian's avatar
      As Kris Jurka found out, pgcrypto does not work with · d51df918
      Bruce Momjian authored
      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
      d51df918
    • Bruce Momjian's avatar
      e94dd6ab
    • Bruce Momjian's avatar
      Major pgcrypto changes: · 73e24318
      Bruce Momjian authored
      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
      73e24318
    • Bruce Momjian's avatar
      - Add Fortuna PRNG to pgcrypto. · 4fcf8b11
      Bruce Momjian authored
      - 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
      4fcf8b11
    • Bruce Momjian's avatar
      This patch adds implementation of SHA2 to pgcrypto. · 248eeb82
      Bruce Momjian authored
      New hashes: SHA256, SHA384, SHA512.
      
      Marko Kreen
      248eeb82
  12. Jul 09, 2005
  13. Jul 08, 2005
    • Neil Conway's avatar
      This patch updates the DDL for contrib/pgcrypto to create all · 86897f54
      Neil Conway authored
      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.
      86897f54
  14. Jul 06, 2005
  15. Jul 05, 2005
  16. Jul 04, 2005
  17. Jul 03, 2005
    • Bruce Momjian's avatar
      This patch allows contrib/pgcrypto to build with OpenSSL 0.9.8 · 76eca0ec
      Bruce Momjian authored
      (currently in beta) when cryptolib = openssl.  According to the
      following checkin message from several years ago, OpenSSL application
      developers should no longer rely on <openssl/evp.h> to include
      everything they need:
      
      http://cvs.openssl.org/chngview?cn=9888
      
      This patch adds the necessary header files.  It doesn't appear to
      break anything when building against OpenSSL 0.9.7.
      
      BTW, core appears to build and work fine with OpenSSL 0.9.8.  I've
      built 7.3 through HEAD against 0.9.8-beta6 without noticing any
      problems.
      
      Michael Fuhr
      76eca0ec
  18. Jul 01, 2005
Loading