<div dir="ltr">Good morning Niko, sorry about the late response. Answers inline.<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 19, 2015 at 2:06 PM, Niko - Whitebox.one <span dir="ltr">&lt;<a href="mailto:niko@whitebox.one" target="_blank">niko@whitebox.one</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div style="font-family:Verdana,Geneva,sans-serif">
<p>Thanks Bruno and Erik Jan for the quick and detailed answers!</p>
<p>I noticed indeed that you are using the Elliptic curves crypto of NaCl on iOS, which is a smart choice.</p>
<p>And thanks for pointing out the timing attack (tables and cache) published in 2009.</p>
<p>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.</p>
<p>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 &quot;modulo a prime&quot; 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.</p></div></blockquote><div>I think we might be talking about different things here. AES-GCM is regularly used for symmetric encryption, ECC for public key encryption.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Verdana,Geneva,sans-serif">
<p>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 &quot;magical&quot; curves.</p></div></blockquote><div>At least in our project, there&#39;s no euphoria, but pretty much common sense and a technical decision. We decided to use ECC for public key encryption, AES-GCM as our prefered choice for symmetric encryption. For platforms that we do not have the port yet for NaCl.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Verdana,Geneva,sans-serif">
<p>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.</p></div></blockquote><div><br></div><div>You are more than welcome to help.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Verdana,Geneva,sans-serif">
<p>For ARMv7 we have NEON VMULL.P8 instructions (from iPhone 3GS and above, if i am not mistaken, ARM11 doesnt have VMULL.P8)</p>
<p>For ARMv8 we have much more, including AES HW accel... (this is in iPhone 5S and above)</p>
<p>You can have a look at :</p>
<p>- About binary polynominal multiplication for GCM on ARMv7: &quot;Fast Software Polynomial Multiplication on ARM Processors using the NEON Engine.&quot; Danilo Camara, Conrado P. L. Gouvea⋆, Julio Lopez and Ricardo Dahab. 2010/2013 [1] <br>their code available here [2] hasn&#39;t made it into openssl (AFAIK)</p>
<p>and</p>
<p>- Implementing GCM on ARMv8. Conrado P. L. Gouvêa, Julio López. 2015 [3]<br>Which details also the ARMv7 case, and was presented at the RSA Conference 2015 in the US, 2 months ago.<br>The paper is here [4].<br>The code is available here [5].</p>
<p>In addition:</p>
<p>It seems that the openssl implementation benefits from NEON in the GHASH (coded by Polyakov) since march 2011 [6] which means GCM timing attack is not possible (no lookup tables).</p>
<p>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&#39;t double checked. If it is not there, then it most probably is present in [5].</p>
<p>So... I am quite interested in helping with having a fully secure AES-GCM stack on ARM, including on iOS. Let&#39;s see how to proceed, starting probably from [5] and then integrate it in OpenSSL? Any idea is welcomed.</p></div></blockquote><div>My idea around the crypto libraries for AeroGear is not to be tied to any providers; i.e OpenSSL, NaCL or CommonCrypto. Today we only support NaCL, but the goal is to let people choose whatever they want. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Verdana,Geneva,sans-serif">
<p>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!)<br></p></div></blockquote><div><br></div><div>I feel like we&#39;re comparing apples and oranges here. GCM is the mode of operation for symmetric encryption, ECC for public encryption, the alternative to ECC would be RSA. Btw I didn&#39;t mean that GCM was not secure, but NaCl was the safer option for iOS. <br><br></div><div>For Android, we decided to stick with ECC over RSA for public key encryption and AES-GCM as our default mode of operation for symmetric encryption. Why? We wanted to provide a simple library on top of BouncyCastle. Also, due to the timeframe, the Java implementation of NaCl for Android was postponed.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Verdana,Geneva,sans-serif"><p>Also, bouncy castle&#39;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?</p></div></blockquote><div>I haven&#39;t got any performances. But if you have other alternatives to BC, I&#39;m open to listen. Also, if you see performance issues, let us know.<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Verdana,Geneva,sans-serif">
<p>All the best,<br>Niko.<br><br></p>
<p>[1] <a href="http://conradoplg.cryptoland.net/files/2010/12/mocrysen13.pdf" target="_blank">http://conradoplg.cryptoland.net/files/2010/12/mocrysen13.pdf</a></p>
<p>[2] <a href="http://conradoplg.cryptoland.net/software/ecc-and-ae-for-arm-neon/" target="_blank">http://conradoplg.cryptoland.net/software/ecc-and-ae-for-arm-neon/</a></p>
<p>[3] <a href="https://www.rsaconference.com/writable/presentations/file_upload/cryp-w01-secure-and-efficient-implementation-of-aes-based-cryptosystems.pdf" target="_blank">https://www.rsaconference.com/writable/presentations/file_upload/cryp-w01-secure-and-efficient-implementation-of-aes-based-cryptosystems.pdf</a></p>
<p>[4] <a href="http://conradoplg.cryptoland.net/files/2010/12/gcm14.pdf" target="_blank">http://conradoplg.cryptoland.net/files/2010/12/gcm14.pdf</a></p>
<p>[5] <a href="https://github.com/conradoplg/authenc" target="_blank">https://github.com/conradoplg/authenc</a></p>
<p>[6] <a href="http://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=crypto/modes/asm/ghash-armv4.pl;h=d91586ee2925bb695899b17bb8a7242aa3bf9150;hb=9575d1a91ad9dd6eb5c964365dfbb72dbd3d1333#l35" target="_blank">http://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=crypto/modes/asm/ghash-armv4.pl;h=d91586ee2925bb695899b17bb8a7242aa3bf9150;hb=9575d1a91ad9dd6eb5c964365dfbb72dbd3d1333#l35</a></p><div><div class="h5">
<p>On 2015-06-19 13:54, abstractj wrote:</p>
<blockquote type="cite" style="padding-left:5px;border-left:2px solid rgb(16,16,255);margin-left:5px;width:100%">
<pre>Good morning Niko, I hope you&#39;re doing well. Please, notice that GCM mode
support is not a limitation of AG iOS, but a restriction from Apple. 

If the document on
<a href="https://github.com/edewit/aerogear-crypto-cordova/blob/master/README.md" target="_blank">https://github.com/edewit/aerogear-crypto-cordova/blob/master/README.md</a>
states that GCM is support, it pretty much relates to Android. If the
senteces are not clear enough, feel free to file a Jira
<a href="https://issues.jboss.org/browse/AGCORDOVA" target="_blank">https://issues.jboss.org/browse/AGCORDOVA</a>.

Answering your questions:

- 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&#39;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&#39;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&#39;s safer[1].

If you feel like, that should be reconsidered. Feel free to create a feature
request against <a href="https://issues.jboss.org/browse/agios" target="_blank">https://issues.jboss.org/browse/agios</a>. I hope it helps.

[1] - <a href="https://cryptojedi.org/papers/aesbs-20090616.pdf" target="_blank">https://cryptojedi.org/papers/aesbs-20090616.pdf</a>



--
View this message in context: <a href="http://aerogear-users.1116366.n5.nabble.com/Aerogear-users-AeroGear-Crypto-API-on-iOS-with-AES-GCM-tp55p61.html" target="_blank">http://aerogear-users.1116366.n5.nabble.com/Aerogear-users-AeroGear-Crypto-API-on-iOS-with-AES-GCM-tp55p61.html</a>
Sent from the aerogear-users mailing list archive at Nabble.com.
_______________________________________________
Aerogear-users mailing list
<a href="mailto:Aerogear-users@lists.jboss.org" target="_blank">Aerogear-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-users" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-users</a>
</pre>
</blockquote>
<div> </div>
</div></div></div>
<br>_______________________________________________<br>
Aerogear-users mailing list<br>
<a href="mailto:Aerogear-users@lists.jboss.org">Aerogear-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-users" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div><br></div>-- <br>&quot;The measure of a man is what he does with power&quot; - Plato<br>-<br>@abstractj<br>-<br>Volenti Nihil Difficile</div>
</div></div></div>