[Aerogear-users] AeroGear Crypto API on iOS with AES-GCM
Niko - Whitebox.one
niko at whitebox.one
Fri Jun 19 14:06:25 EDT 2015
Thanks Bruno and Erik Jan for the quick and detailed answers!
noticed indeed that you are using the Elliptic curves crypto of NaCl on
iOS, which is a smart choice.
And thanks for pointing out the timing
attack (tables and cache) published in 2009.
I am well aware of this
kind of attack on AES and GCM when lookup tables are used, but since
2009, we got some improvements, on intel CPU (AES-NI) at least, which
patches are already included in openssl (Gueron et al). But I agree with
you that for ARM, we are a bit left behind.
About the question if
elliptic curves are safer than AES-GCM, i would say it is a question of
trust.... ECC is way too young for me to trust it. I prefer plain old
"modulo a prime" groups, with their caveats (longer keys, more cpu
intensive) and their limitations (side-channel attacks) but that have
benefited from a huge community of cryptographers, coders and debuggers
for now 40 years.
I believe that, if used correctly, RSA, AES, GCM,
and DHE can be very efficient. And I am a bit afraid of the sudden
euphoria for "magical" curves.
Now if we come back to our subject of
interest, which is ARM and iOS, i would say that the situation is
tricky, but we can find a solution, and I am interested in helping.
For ARMv7 we have NEON VMULL.P8 instructions (from iPhone 3GS and
above, if i am not mistaken, ARM11 doesnt have VMULL.P8)
For ARMv8 we
have much more, including AES HW accel... (this is in iPhone 5S and
You can have a look at :
- About binary polynominal
multiplication for GCM on ARMv7: "Fast Software Polynomial
Multiplication on ARM Processors using the NEON Engine." Danilo Camara,
Conrado P. L. Gouvea⋆, Julio Lopez and Ricardo Dahab. 2010/2013 
their code available here  hasn't made it into openssl (AFAIK)
- Implementing GCM on ARMv8. Conrado P. L. Gouvêa, Julio López. 2015
Which details also the ARMv7 case, and was presented at the RSA
Conference 2015 in the US, 2 months ago.
The paper is here .
is available here .
It seems that the openssl
implementation benefits from NEON in the GHASH (coded by Polyakov) since
march 2011  which means GCM timing attack is not possible (no lookup
Also to be checked, is the AES timing resistant bitsliced
implementation from Bernstein and Schwabe that Bruno referred to in the
linked PDF. It is probable that the ARM version has been integrated into
openssl, but I haven't double checked. If it is not there, then it most
probably is present in .
So... I am quite interested in helping
with having a fully secure AES-GCM stack on ARM, including on iOS. Let's
see how to proceed, starting probably from  and then integrate it in
OpenSSL? Any idea is welcomed.
Finally, just a small comment: If
AES-GCM is not as secure as ECC, then why are you still using it in the
android implementation of your crypto box? (Dont get me wrong, i prefer
AES-GCM over ECC!)
Also, bouncy castle's implementation of AES-GCM is
known to be slow, not accelerated at all (even on intel) and not even
parallelized. What performances have you got on that?
On 2015-06-19 13:54, abstractj wrote:
> Good morning Niko, I hope
you're doing well. Please, notice that GCM mode
> support is not a
limitation of AG iOS, but a restriction from Apple.
> If the
> states that GCM is support, it pretty much relates to Android. If
> senteces are not clear enough, feel free to file a Jira
> Answering your
> - Is GCM mode for AES encryption supported on iOS
aerogear crypto module
> (and the cordova plugin) ?
> No. But, we are
open for suggestions. In the future we plan to make
aerogear-ios-crypto pluggable. Into this way you're free to go with
CommonCrypto or whatever provider you want.
> - If not, how difficult
would it be to use the private API in iOS
> CommonCrypto ? I didnt try
it myself, i have just been reading the code....
> I'd say, would
take time and the only way I see today is plugging OpenSSL.
> The reason
why NaCl was choosen, was not only the fact of CommonCrypto not
supporting GCM, but also, because it's safer.
> If you feel like,
that should be reconsidered. Feel free to create a feature
against https://issues.jboss.org/browse/agios . I hope it helps.
 - https://cryptojedi.org/papers/aesbs-20090616.pdf 
View this message in context:
> Sent from the aerogear-users mailing list archive at
Aerogear-users mailing list
> Aerogear-users at lists.jboss.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Aerogear-users