Discussion:
CFB8 Decrypt Slow
Ray Kelly
2013-01-18 14:00:07 UTC
Permalink
I am decrypting a CFB8/No Padding Stream.   BouncyCastle is about 80% slower that the native decryption (I cant use native Rijndael in my project for various reasons).   I ran a test decrypting 30k bytes in a single ProcessBytes call.   I compared the native Rijndael(TransformBlock) to the AesFastEngine and BouncyCastle Rijndael.   Here are the results:


Native Rijndael: 21ms
AesFastEngine: 34ms
BC Rijndael: 288ms

Native Rijndael: 19ms
AesFastEngine: 31ms
BC Rijndael: 288ms


Native Rijndael: 19ms
AesFastEngine: 31ms
BC Rijndael: 287ms

Is there another engine I should use or something I am doing wrong?  Thanks for your help,
Ray
Peter Dettman
2013-01-19 06:01:22 UTC
Permalink
It's basically a limitation of managed code (not to rule out that our
implementation might yet be improved).

You might consider experimenting with unsafe code in
EncryptBlock/DecryptBlock to see if there are array bounds checks that
can be eliminated, but I don't really have any idea what sort of
improvement that's likely to give, if any.

Pete.
I am decrypting a CFB8/No Padding Stream. BouncyCastle is about 80%
slower that the native decryption (I cant use native Rijndael in my
project for various reasons). I ran a test decrypting 30k bytes in a
single ProcessBytes call. I compared the native
Rijndael(TransformBlock) to the AesFastEngine and BouncyCastle
Native Rijndael: 21ms
AesFastEngine: 34ms
BC Rijndael: 288ms
Native Rijndael: 19ms
AesFastEngine: 31ms
BC Rijndael: 288ms
Native Rijndael: 19ms
AesFastEngine: 31ms
BC Rijndael: 287ms
Is there another engine I should use or something I am doing wrong?
Thanks for your help,
Ray
Peter Dettman
2013-01-19 06:01:57 UTC
Permalink
I forgot to ask: are these measurements including the CFB8 mode or just
for the AES cipher?

It's quite possible that BC's CFB mode is not very optimised for CFB8...
I am decrypting a CFB8/No Padding Stream. BouncyCastle is about 80%
slower that the native decryption (I cant use native Rijndael in my
project for various reasons). I ran a test decrypting 30k bytes in a
single ProcessBytes call. I compared the native
Rijndael(TransformBlock) to the AesFastEngine and BouncyCastle
Native Rijndael: 21ms
AesFastEngine: 34ms
BC Rijndael: 288ms
Native Rijndael: 19ms
AesFastEngine: 31ms
BC Rijndael: 288ms
Native Rijndael: 19ms
AesFastEngine: 31ms
BC Rijndael: 287ms
Is there another engine I should use or something I am doing wrong?
Thanks for your help,
Ray
Loading...