Need some suggestions on encryption / decryption code and process

I am using the code below to provide file encryption of highly secure data on Sun servers. Below is strictly an example of my encryption / decryption algorithms stripped to the minimum and embedded in main(). The code works fine and performs as it should. Here are a few questions I have for our specific environment:

We have a requirement that a minimum of 2 key custodians be used to

know the passphrase (i.e. no one individual would know the enitre key - in this implementation, the 16 byte String used in enc_key. - I am planning on having two individuals supporting 64 bits of the passphrase - combined providing the 128 bits required for AES-128). Is there a better way of doing this? I know in Enterprise databases there tends to be multiple keys / master keys / certificates to implement this level of key management. I initially am trying to keep this as simple as possible, but without compromising security. The 128 bit passphrase is strictly stored in memory on our servers, and must be keyed in manually by each of the two key custodians (this can be done with the key custodians at different locations, and entering the keys at different times -- the full blown service does not start until each operator has provided their half). I am also supporting code methods that allow changing of the passphrase, and full re-encryption of the encrypted file storage area, real-time. Does anyone see in security flaws with this process - again, I know a key management package might simplify things, but this is the initial route we are going down. We just don't want to compromise security. Any feedback is appreciated.

import java.io.*;

import java.net.*;

import javax.crypto.KeyGenerator;

import javax.crypto.SecretKey;

import javax.crypto.spec.IvParameterSpec;

import javax.crypto.Cipher;

import java.security.Security;

import javax.crypto.spec.SecretKeySpec;

publicclass Enc1

{

publicstaticvoid main(String[] args)throws Exception

{

byte[] data ="this is a test !!!!!!!".getBytes();

SecretKeySpec enc_key =new SecretKeySpec("abcdefghijklmnop".getBytes(),"AES");

Cipher enc_cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");

enc_cipher.init(Cipher.ENCRYPT_MODE, enc_key);

byte[] enc =newbyte[enc_cipher.getOutputSize(data.length)];

System.out.println(enc.length);

int size1 = enc_cipher.update(data, 0, data.length, enc, 0);

enc_cipher.doFinal(enc, size1);

SecretKeySpec dec_key =new SecretKeySpec("abcdefghijklmnop".getBytes(),"AES");

Cipher dec_cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");

dec_cipher.init(Cipher.DECRYPT_MODE, dec_key);

byte[] dec =newbyte[dec_cipher.getOutputSize(enc.length)];

System.out.println(dec.length);

int size2 = dec_cipher.update(enc, 0, enc.length, dec, 0);

int size3 = dec_cipher.doFinal(dec, size2)

System.out.println(new String(enc));

System.out.println(enc.length);

System.out.println(new String(dec));

System.out.println(dec.length);

}

}

[4341 byte] By [kcook1973a] at [2007-11-27 6:50:34]
# 1

There are a number of ways to meet the "split-key knowledge" requirement, and breaking up the key is indeed one of them. However, there are other ways to achieve the same goal:

1) Having 2 users type in a password string (meeting all the rules of a strong password), concatenating them and then using PBE (Password-Based-Encryption) to generate a symmetric key from the password;

2) Encrypting the symmetric key with a public key and then having multiple custodians type in their strong passwords as input to a concatenated password to protect the private key;

3) Using a smartcard/TPM device to store the private-key (which protects the symmetric key) and having multiple custodians input PINs to the device;

The advantage of #1 is that you don't need to store the symmetric key anywhere, since you can always regenerate the same symmetric key, as long as the same concatenated string is available as input (along with some salt and iteration count - see examples of PBE in David Hook's book "Beginning Cryptography in Java").

The advantage of #2 is that you can share the encrypted key with multiple users/applications (by encrypting it with their individual public keys) and transporting it to them. They will all use their individual private-keys to decrypt the symmetric key for use.

The advantage of #3 is that it adds another factor of security to the scenario - something you have and something you know. You can also have one custodian have possession of the physical device, and another know the PIN to the device, so that they both have to come together to make it work.

If you are looking for a sophisticated key-management system, StrongKey (www.strongkey.org) is an open-source key-management solution that uses #2 and #3 within its architecture. Your task will just come down to implementing it rather than building such a capability from scratch.

arshad.noora at 2007-7-12 18:24:39 > top of Java-index,Security,Cryptography...