jump to navigation

a letter to mcrypt maintainer (a weird observation) February 27, 2007

Posted by TSAI HONG-BIN in Diary.
add a comment

Dear mcrypt maintainer:

Thank you for maintaining this great work. It’s quite handy and powerful.
However, after running a quick benchmarking, I found that the
encryption/decryption speed of Rijndael (with key size both in 128
bits and 256 bits) is much slower than Twofish, CAST …etc. More
strangely, rijndael-128 is slower than rijndael-256. This isn’t
normal. So do you have any idea about this issue? The experiment
result is appened.

mcrypt -t -f key.256 -a rijndael-256 <data>
1st round (in seconds) 2M 16M 64M 256M
encryption                     0.152 1.192 4.71 23.195
decryption                     0.154 1.184 4.736 23.577

2nd round                      0.148 1.164 4.612 23.424
0.15 1.184 4.703 19.013

3rd round                     0.149 1.171 4.617 19.96
0.155 1.182 4.724 18.868

average                     0.149666667 1.175666667 4.646333333 22.193
0.153 1.183333333 4.721 20.486

mcrypt -t -f key.128 -a rijndael-128 <data>
1st round (in seconds) 2M 16M 64M
encryption                     0.184 1.241 4.975
decryption                     0.165 1.282 5.81

2nd round                     0.164 1.238 4.891
0.166 1.276 5.078

3rd round                     0.16 1.244 4.899
0.168 1.276 5.102

average                     0.16933 1.241 4.92167
0.16633 1.278 5.33

The encryption/decryption time of 16M data, using Twofish, is
approximately 0.5 second. 0.8 second if CAST is used.

Best regards,


dm-crypt mount delay experiment February 27, 2007

Posted by TSAI HONG-BIN in Linux.
add a comment

Obviously encrypted loopback files require more time to complete mount/umount operations. It seems that no matter how big the encrypted loopback file is, the delay is always approximately 0.72 second. I’ve made a loopback file in 1G, and it’s mount delay is around 0.72 as well. Security is always a trade-off of performance, however.

The experiment is run on an Intel core duo 1.86G platform with 1G RAM.

encrypted loopback file           
1st round (in seconds)                                            16M      64M     256M
losetup + cryptsetup luksOpen + mount            0.722    0.72    0.734
umount + cryptsetup luksClose + losetup          0.011    0.011    0.011

2nd round                                                                0.733    0.714    0.713
0.012    0.011    0.01

3rd round                                                                  0.72    0.72    0.72
0.01    0.011    0.011

Average                                                                    0.725     0.718     0.722
0.011    0.011    0.010666667


native loopback file       
1st round (in seconds)                                    16M      64M      256M
mount                                                                0.007    0.006    0.007
umount                                                              0.003    0.003    0.004

2nd round                                                         0.007    0.006    0.006
0.005    0.004    0.003

3rd round                                                          0.007    0.006    0.006
0.003    0.004    0.003

average                                                             0.007    0.006    0.0063
0.0037    0.0037    0.0033



install mcrypt manually February 27, 2007

Posted by TSAI HONG-BIN in Diary.
1 comment so far

Mcrypt is a replacement for crypt on Linux system. Fedora users can simply install mcrypt by running yum install mcrypt, libmcrypt will be installed at the same time. In order to better understand its implementation, I decided to install mcrypt and libmcrypt manually, and found that the install script on my system doesn’t work properly. I got an error says “../.././mkinstalldirs: No such file or directory” while executing make install. It’s no big deal, just remove “$(top_builddir)/” at line 30 in ~/mcrypt-2.x/po/Makefile and re-run the installation.

Note that libmhash is required to compile mcrypt.

c-faq review and a chinese translation (1.12) February 15, 2007

Posted by TSAI HONG-BIN in Programming.
add a comment

please refer to http://c-faq.com/decl/auto.html for original document.

1.12 What’s the auto keyword good for?

Nothing; it’s archaic. [One can imagine stylistic uses such as emphasizing that a variable must be automatic, and supposedly some compilers have used it to force a variable not to be in a register.] (It’s a holdover from C’s typeless predecessor language B, where in the absence of keywords like int a declaration always needed a storage class.) See also question 20.37.


關鍵字 auto 有什麼好處

沒有,那已廢棄不用。auto可以做為字面上強調該變數必需為自動(automatic),也許某些編輯器以此來強迫變數不要存放在register裡。C語言的前身B語言沒有類似 int 的關鍵字,因此用auto來做 storage class。


c-faq review and a chinese translation (1.11) February 15, 2007

Posted by TSAI HONG-BIN in Programming.
add a comment

please refer to http://c-faq.com/decl/extern.html for the origin

1.11 What does extern mean in a function declaration?

is significant only with data declarations. In function declarations, it can be used as a stylistic hint to indicate that the function’s definition is probably in another source file, but there is no formal difference between

extern int f();


int f();

See also question 1.10.

References: ISO Sec., Sec. 6.5.1
Rationale Sec.
H&S Secs. 4.3,4.3.1 pp. 75-6

函式宣告時的 extern 代表什麼意思?

extern 只有在資料宣告時有意義。在函式宣告時,它可以拿來當作字面上的提示,表示該函式的可能定義在其他源碼,但其實

extern int f();

int f();