This blog is about Java (advanced Java topics like Reflection, Byte Code transformation, Code Generation), Maven, Web technologies, Raspberry Pi and IT in general.

Samstag, 22. September 2012

Truecrypt benchmark for Raspberry Pi with Turbo

Introducing turbo mode: up to 50% more performance for free. This benchmark was run on raspbian/wheezy with the overclock setting "Turbo". The buffer size was was 5MB. With turbo truecrypt is about 60% faster than without.

Algorithm Encrypt Decrypt Mean
Twofish 14 12 13
Serpent 10 10 10
AES 7 5.3 6.1
Twofish-Serpent 5.9 5.5 5.7
Serpant-AES 4.1 4.0 4.1
AES-Twofish 4.6 4.2 4.4
Serpant-Twofish-AES 3.2 3.0 3.1
AES-Twofish-Serpent 3.2 3.0 3.1

Mittwoch, 12. September 2012

Java SimpleArchive with RandomAccessFile

 I had a quite simple problem. I want to read several hundred thumbnail images (movie posters) to display them in a Java program.

File system
The simplest approach is to save the images directly in the file system. It's working fine if all images are cached from the OS. But if not it takes several seconds to load all images. Another downside is that most of the files have a size of 6kb - 7kb (in a range of 3kb - 10kb). So you loose some space because the block size is usually 4kb. In my case it was about 25%.

The next idea was to save all images in a Zip archive. The standard Java library supports Zip archives directly. It looked very promising. It was quite easy to use and it worked fine. But there is one big problem. It's not possible to add files to an existing archive. You had always to recreate the complete file. It's no problem if the archive is small but if it gets bigger than this could consume quite a long time. I looked for other libraries and archive formats. But it seemed that there is no easy to use archive library which supported to add files to an existing archive. So I wrote my own very simple archive library with the RandomAccessFile API.

SimpleArchive (github)
It's very simple and very fast. It can add files to an existing archive without the need to recreate the file. It just adds the file(s) and rewrite the file index which is located at the end of the file. So it will be much faster by adding files to an archive than the Zip implementation. In a very basic test it read the files ~3 times faster than the the Zip implementation. If you want to know more about it just visit the github.

Freitag, 20. Juli 2012

Truecrypt benchmark for Raspberry Pi

This benchmark was run on raspbian/wheezy. So it's used the armhf architecture. The buffer size was was 5MB. Checkout the truecrypt benchmark with the new turbo overclock setting.

Algorithm Encrypt Decrypt Mean
Twofish 8.9 7.7 8.3
Serpent 6.8 6.9 6.9
AES 4.4 3.7 4.1
Twofish-Serpent 3.9 3.7 3.8
Serpant-AES 2.7 2.4 2.5
AES-Twofish 1.9 2.4 2.1
Serpant-Twofish-AES 2.1 1.8 2.0
AES-Twofish-Serpent 2.0 1.8 1.9

Truecrypt armhf executable for Raspberry Pi (raspbian/wheezy)

Because Truecrypt it's a bit of a work and takes so long to compile I uploaded the compiled binary file

Compile Truecrypt on Raspberry Pi

I wanted to run Truecrypt on my Raspberry Pi. But there is no precompiled package which you could simply install with apt-get. So you have to compile it yourself - which take a few hours. If you just want the truecrypt binary for Raspbian/Wheezy then you can download them here.
The first thing you need to do is to get all needed dependencies. Thereby you have to compile one dependency yourself. We start with this dependency.

How to compile wxWidgets
First download the source code: I used wxAll 2.8.11. Unpack it, go into the directory and execute these commands.
sudo apt-get install libgtk2.0-dev

How to setup PKCS11
Truecrypt needs three header files (pkcs11.h, pkcs11f.h, pkcs11t.h) which you can download from this location:
Put them into a directory and then set the PKCS11_INC variable.
export PKCS11_INC=/home/pi/pkcs11

How to compile Truecrypt
First download the source code: I used 7.1a. Unpack it, go into the unpacked directory and execute these commands.
sudo apt-get install libfuse-dev nasm libwxgtk2.8-dev
make WX_ROOT=/home/pi/wxWidgets/ wxbuild

 There will be this warning
configure: WARNING: libSM not found; disabling session management detection
sadly I couldn't figure out how to fix it. But Truecrypt will work anyway.

If you get this error message
In file included from Keyfile.cpp:10:0:
.../SecurityToken.h:43:21: fatal error: pkcs11.h: No such file or directory
then the  PKCS11_INC variable isn't set correctly or you forgot to put the header files in the directory.

Now you can use Truecrypt. The executable file will be created in Main/truecrypt. To mount a truecrypt volume just use
./truecrypt /path/to/truecrypt-volume /path/to/mount-point
or you can just execute ./truecrypt and use the graphical surface.