EXtended Tiny Encryption Algorithm

The first included encryption algorithm is XTEA (eXtended Tiny Encryption Algorithm). We have choosen XTEA because this block cipher operates on a 64-bit block size with a 128-bit key. This is an extremely tiny but very fast (with cycles less than 32 rounds) encryption algorithm. It is supposed to be as secure as DES or IDEA. Since cryptography is beyond the scope of this tutorial you can find further information about XTEA here:

http://en.wikipedia.org/wiki/XTEA

In order to encipher your data just perform the following steps:

  1. Ensure you have downloaded at least db4o Version 5.1. This is the first version which includes the XTeaEncryptionFileAdapter (the encryption IoAdapter plug-in for db4o file IO that realizes XTEA).
  2. Configure db4o to add this encryption mechanism:
  3. .NET: Db4o.Configure ().Io(new XTeaEncryptionFileAdapter("password"));

    This is the simplest way to add the encryption adapter. But the XTEAEncryptionFileAdapter can also wrap other custom IoAdapters to use:

    .NET: Db4o.Configure ().Io(new XTeaEncryptionFileAdapter(new myIoAdapter(),"password"));

  4. Choose your own password and number of cycles. The security of XTEA can be enhanced by increasing the number of iterations. There are four possible values: 
  • 8 rounds guarantee highest speed of db4o and lowest security (iterations = XTEA.ITERATIONS8).
  • 16 rounds assure high speed of db4o and sufficient security in the same time (iterations = XTEA.ITERATIONS16).
  • 32 rounds are ample for most applications, this is the default value (iterations = XTEA.ITERATIONS32).
  • 64 rounds achieve the best security but db4o will be about 20 per cent slower then without encryption (iterations = XTEA.ITERATIONS64).
.NET: Db4o.Configure ().Io(new XTeaEncryptionFileAdapter( "password", iterations) );

Or, if you wish to use your own IoAdapter:

.NET: Db4o.Configure ().Io(new XTeaEncryptionFileAdapter(new myIoAdapter(), "password", iterations) );

Keep in mind that all configurations must be set before opening the ObjectContainer.

Note that there are some limitations you should keep in mind:
There is no possibility of changing the password on an existing file. You will not be able to access your data if you lose the password. Thus please keep your key! And make sure that you always use the same password when subsequently opening your encrypted files. You can, however open a new file with a different password and replicateupdated (or defragment) your objects from one database to the other.

Feel free to use XTeaEncryptionFileAdapter for your own purposes. You may modify the class XTEA (which implement the XTEA encryption algorithm) and KeyGenerator (for key generation), and replace them with other algorithms if you like. Feel free to post your own IoAdapters to the db4o Community Forum http://developer.db4o.com/forums/