pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Struck <struck.d@retrovirology.lu>
To: Bruno Wolff III <bruno@wolff.to>
Cc: Greg Stark <gsstark@mit.edu>
Cc: Mitch Pirtle <mitchy@spacemonkeylabs.com>
Cc: pgsql-php@postgresql.org
Subject: Re: [ADMIN] Secure DB Systems - How to
Date: Fri, 30 Jul 2004 11:43:31 +0200
Message-ID: <20040730114331.38845c7f@gentoo> (raw)
In-Reply-To: <20040729180010.GA23523@wolff.to>
References: <ccjra4$pgl$1@sea.gmane.org>
	<20040709152722.GA20935@wolff.to>
	<20040713113557.31e9d6dc@localhost>
	<20040713123817.GB3710@wolff.to>
	<20040713151838.0004cb8e@localhost>
	<40F3EC4A.1060101@spacemonkeylabs.com>
	<20040727134133.676ab9cf@localhost>
	<20040727194905.GA20499@wolff.to>
	<87brhzsx9x.fsf@stark.xeocode.com>
	<20040729180010.GA23523@wolff.to>

> IVs act to make the key appear longer. This is especially useful when humans
> are picking passphrases that are used to generate the key. If you control
> what the actual keys are, then you can make dictionary attacks impractical.
> However, there still would be the problem that identical items in the
> database would be identical. Which, depnding on your application, might
> be a problem because of information leakage.

I don't think this is true for CBC mode. Here the first block of plaintext is XORed with the IV then encrypted with a block ciper like AES for example. The next plaintext block is than XORed with the previous cyphertext and so on.

So IV in CBC is used to make the encrypted cyphertext unique.

You can find some info in chapter 9.3 of "Appplied Cryptopgraphy" from Bruce Schneier.

In my application I do use a different IV for every encrypted plaintext:
$td = mcrypt_module_open('rijndael-128', '', 'cbc', '');
$iv = base64_encode(mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_URANDOM));
I do use base64 as it is easier to store it in the database.

The plaintext is then encrypted using:
$ciphertext = "encrypt_iv('" . $plaintext . "','" . $password] . "',decode('$iv','base64'),'aes')";

The IV is then stored together with the ciphertext in the database.


Daniel


-- 
Retrovirology Laboratory Luxembourg
Centre Hospitalier de Luxembourg
4, rue E. Barblé
L-1210 Luxembourg

phone: +352-44116105
fax:   +352-44116113
web: http://www.retrovirology.lu
e-mail: struck.d@retrovirology.lu



view thread (17+ messages)  latest in thread

Message-ID: <20040730114331.38845c7f@gentoo>
Permalink:  ../20040730114331.38845c7f@gentoo/
Also on:    postgresql.org/message-id/20040730114331.38845c7f@gentoo

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: struck.d@retrovirology.lu, bruno@wolff.to, gsstark@mit.edu, mitchy@spacemonkeylabs.com, pgsql-php@postgresql.org
  Subject: Re: [ADMIN] Secure DB Systems - How to
  In-Reply-To: <20040730114331.38845c7f@gentoo>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox