Re: Encrypting Data...

From: Peter J. Holzer (hjp_at_wsr.ac.at)
Date: 01/21/04


Date: Wed, 21 Jan 2004 10:28:36 +0100
To: dbi-users@perl.org


On 2004-01-20 17:08:03 -0800, Tim Howell wrote:
> This question isn't strictly DBI, but I wasn't sure where to ask. Is
> there a preferred way to encrypt data stored in a database? I'm
> developing an application that has higher security requirements than
> what I've done in the past and I want to make sure the data is safe.
> I know that MySQL has an AES encrypt function, and I know about the
> Crypt:: modules, but I'm not sure what is typically used as a key (eg,
> when multiple users need to see the same data), etc.

If multiple users have to access the same data, you have two
possibilities:

* Store the key(s) in the database.
  That's not good: Anybody who has access to the database also has
  access to the keys, and hence to the encrypted data - so why encrypt
  at all?

* Give the key(s) to the users which need to access the data.
  Not good either: Whenever someone leaves the company, you have to
  choose new keys, reencrypt all the data, distribute the new keys ...

But you can combine these methods:

Choose random keys. For each user, encrypt the keys with a password
chosen by the user. Store the encrypted keys. When a user needs to
access some data, use his password to decrypt the keys and then decrypt
the data.

An attacker then needs access to the database plus a user's password to
access the data. But note that if he needs the password only once to
decrypt the keys. If the password is changed later, he still has access.
Therefore you should make sure that users do not have direct access to
their encrypted keys. To revoke a user's privileges, simply remove his
encrypted keys.

More elaborate schemes are possible, but you cannot be 100% safe against
an attacker who who has complete access to the database and the
application (I think - I would like to be proven wrong).

        hp

-- 
   _  | Peter J. Holzer      | Shooting the users in the foot is bad. 
|_|_) | Sysadmin WSR / LUGA  | Giving them a gun isn't.
| |   | hjp@wsr.ac.at        |	-- Gordon Schumacher,
__/   | http://www.hjp.at/   |     mozilla bug #84128




Relevant Pages

  • Re: Which is more secure RC2 or RC4 ?
    ... same database temporarily, until the order is approved manually and the ... obviously there are a LOT of security related issues that arise ... itself in order to decrypt the information, ... meaning if I encrypt the information using AES and a password driven ...
    (sci.crypt)
  • Re: Simple Encryption/Decryption
    ... where I had to encrypt anything. ... >> string back. ... When I try the Decrypt method I can't even run the ... >>> Where are you assigning the keys and ivs? ...
    (microsoft.public.dotnet.security)
  • Re: 2 Keys decrypts same message
    ... is the key used to encrypt, M is the message to be decrypted. ... keys that decrypt to the same message in a straightforward ... e_K1 can be used to decrypt the ciphertext. ...
    (sci.crypt)
  • Re: Portable hard drive through airport security?
    ... encrypt using the built-in MS system. ... How do you make sure you export all the keys? ... For example, if you're traveling between offices, simply transferring ... "With AEFSDR (Advanced EFS Data Recovery), ...
    (rec.travel.air)
  • Re: Java Security
    ... (We can pick a private algorithm but decompiling ... Never give encrypt keys on an application. ... give them by phone or letter, or use a SSL http website with the user login, ...
    (comp.lang.java.help)