[botan-devel] ARM/iOS SHA performance [Was: CRC32 intermediate state]

Richard Huveneers richard at hekkihek.nl
Sun Jul 29 17:33:56 EDT 2012


Ok, here are the test results (in seconds). Tested on my iPhone 3GS.
PBKDF2 with 30.000 iterations. Each run using the same salt, password and
key length.

*Botan::SHA_160 19.1*

*Botan::SHA_256 12.1*

*Botan::SHA_512 12.9*

**

*FastHashSHA1   0.93*

*FastHashSHA256 0.68*

*FastHashSHA512 1.71*
*
*
These numbers are similar to the tests I did last month. Huge difference.

Just before sending this message I decided to check the compiler
optimization options during debugging. Turns out that Xcode is configured
(by default) to do no code optimization at all during debugging..........
After changing that I redid the tests above to find these timings:

*Botan::SHA_160 2.12*

*Botan::SHA_256 1.08*

*Botan::SHA_512 1.58*

**

*FastHashSHA1   0.79*

*FastHashSHA256 0.62*

*FastHashSHA512 1.66*
*
*
For SHA-1 there is still a substantial difference, although more in line
with your expectations (2-3x).
For SHA-2 the results are comparable.

Richard.

2012/7/29 Jack Lloyd <lloyd at randombit.net>

>
> According to
> http://theiphonewiki.com/wiki/index.php?title=S5L8720_%28Hardware_-_SHA1%29
> there is at least SHA-1 hardware in some(?) iPhones, which presumably
> is being used by the libraries if it is available. Did you see a
> similar speed up for SHA-2?
>
> -Jack
>
> On Sun, Jul 29, 2012 at 08:30:56PM +0200, Richard Huveneers wrote:
> > The 10x is the correct order of magnitude, the key derivation for some
> disk
> > images reduced from around 90 to 8 seconds (measured by hand) on my
> iPhone
> > 3GS. It could well have hardware support for this, although it's a rather
> > old device..
> >
> > Richard.
> >
> > 2012/7/29 Jack Lloyd <lloyd at randombit.net>
> >
> > >
> > > Interesting, the iOS library hashes are really _10x_ the performance
> > > of the C++ code in botan? I'm definitely intrigued by that, as, at
> > > least for the ARM I have (an ARM926EJ), OpenSSL's asm SHA-1 and
> > > SHA-256 are slower than Botan's C++ (12% and 40%, resp), so I figured
> > > I was doing OK even lacking asm!
> > >
> > > Is it possible the iPhone has physical SHA hardware? I could believe
> > > careful asm (and NEON support, which I know the Cortex has but which
> > > no ARM I have access to does) might provide even 2-3x speedup but 10x
> > > is pretty crazy and I'm really wondering what I'm missing. If it
> > > really is giving that speedup, a CommonCrypto engine (or some ARM asm
> > > at least, if this is easy to replicate) would make a lot of sense.
> > >
> > > -Jack
> > >
> > > On Sun, Jul 29, 2012 at 08:08:24PM +0200, Richard Huveneers wrote:
> > > > Ok, here goes..
> > > >
> > > > The object names made sense when I was doing performance tests,
> should
> > > > probably be renamed to reflect the iOS/Mac environment.
> > > >
> > > > Regards, Richard.
> > > >
> > > > 2012/7/29 Timothy Prepscius <timprepscius at gmail.com>
> > > >
> > > > > I'm interested.
> > > > >
> > > > > On Jul 29, 2012, at 11:57 AM, Richard Huveneers wrote:
> > > > >
> > > > > ve made a few objects wrapping iOS's SHA functions into subclasses
> > > > > of Botan::HashFunction. Since Botan does not have ARM assembly
> > > versions,
> > > > > these are much (10x) faster than the default SHA implementation
> > > provided by
> > > > > Botan. If anybody is interested, I'll gladly provide a zip file
> > > containing
> > > > > the sources.
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > botan-devel mailing list
> > > > > botan-devel at randombit.net
> > > > > http://lists.randombit.net/mailman/listinfo/botan-devel
> > > > >
> > > > >
> > >
> > >
> > > > _______________________________________________
> > > > botan-devel mailing list
> > > > botan-devel at randombit.net
> > > > http://lists.randombit.net/mailman/listinfo/botan-devel
> > >
> > > _______________________________________________
> > > botan-devel mailing list
> > > botan-devel at randombit.net
> > > http://lists.randombit.net/mailman/listinfo/botan-devel
> > >
>
> > _______________________________________________
> > botan-devel mailing list
> > botan-devel at randombit.net
> > http://lists.randombit.net/mailman/listinfo/botan-devel
>
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://lists.randombit.net/mailman/listinfo/botan-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20120729/cc95a766/attachment.html>


More information about the botan-devel mailing list