<div dir="ltr"><div>Thanks for putting together the gist; I did read several times over it, and I guess it mostly makes sense :-) </div><div><br></div><div>However I do have a few (minor?) questions:</div><div><br></div><div>
===JavaScript:===</div><div><br></div><div>* key: generatedKey,</div><div><br></div><div>where does the generate key come from ? Is that a key that, as shown in the diagram, comes from "the server"?</div><div><br>
</div><div>Java</div><div><br></div><div>* CryptoBox: It is used for different algorithms (GCM and ECC), like a "ToolBox" / "ToolChain", right ? </div><div><br></div><div>* PBKDF2: However, in the (outdated?) gist we use a function (AeroGearCrypto.pbkdf2()) to get access to the Pbkdf2 class; I can't see that in the code - there a direct usage of the Pbkdf2 class is present.</div>
<div><br></div><div>Now, wondering about the different 'access' mechanisms (AeroGearCrypto.pbkdf2() vs. CryptoBox), does it make sense (honestly not sure) to add the 'PBKDF2' to the "CryptoBox" as well ? </div>
<div><br></div><div> </div><div>@iOS</div><div><br></div><div>we had a kick off meeting early this week, and now trying to see how we move on. A few infos are available in this forked gist:</div><div><br></div><div><a href="https://gist.github.com/matzew/7cdf1831c55e3d656477">https://gist.github.com/matzew/7cdf1831c55e3d656477</a></div>
<div><br></div><div>More to follow....</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 7, 2013 at 9:02 PM, Bruno Oliveira <span dir="ltr"><<a href="mailto:bruno@abstractj.org" target="_blank">bruno@abstractj.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Good morning all, just to start the discussion about the APIs and<br>
encrypted storage I wrote this gist. Probably after some revisions I<br>
hope to make it a specification.<br>
<br>
Regarding the available scenarios, feel free to add or change the priority.<br>
<br>
<br>
Gist: <a href="https://gist.github.com/abstractj/f1229ae075f8e6688c75" target="_blank">https://gist.github.com/abstractj/f1229ae075f8e6688c75</a><br>
<br>
# AeroGear Crypto API<br>
<br>
**Note**: This document is a working progress<br>
<br>
# Authors<br>
<br>
- Bruno Oliveira<br>
- *put your pretty name here*<br>
<br>
## Goals<br>
<br>
- User friendly interface for non crypto experts<br>
- Advanced developers can make use of the pure crypto provider<br>
implementation.<br>
<br>
## Supported Algorithms<br>
<br>
- <a href="https://issues.jboss.org/browse/AGSEC-114" target="_blank">https://issues.jboss.org/browse/AGSEC-114</a><br>
<br>
<br>
## Scenarios<br>
<br>
**Note**: For all scenarios the authentication process was intentionally<br>
ignored.<br>
<br>
- A logged in user wants to store sensitive data on mobile<br>
<br>
![](<a href="http://www.websequencediagrams.com/cgi-bin/cdraw?lz=dGl0bGUgRGF0YSBlbmNyeXB0aW9uCgpDbGllbnQtPlNlcnZlcjogUmVxdWVzdAAZCyBrZXlzCgAaBgAeCkdlbmVyYXRlIHRoZQAdBSBhbmQgc3RvcmUAIwkAVgY6IFNlbmQAIAggYmFjayB0bwAzBWMAeAUAewkAKAhFAIEaBgBWBWRhdGEK&s=napkin" target="_blank">http://www.websequencediagrams.com/cgi-bin/cdraw?lz=dGl0bGUgRGF0YSBlbmNyeXB0aW9uCgpDbGllbnQtPlNlcnZlcjogUmVxdWVzdAAZCyBrZXlzCgAaBgAeCkdlbmVyYXRlIHRoZQAdBSBhbmQgc3RvcmUAIwkAVgY6IFNlbmQAIAggYmFjayB0bwAzBWMAeAUAewkAKAhFAIEaBgBWBWRhdGEK&s=napkin</a>)<br>
<br>
- The mobile device goes offline but the sensitive data must be safe<br>
<br>
[Under development]<br>
<br>
- Device was stolen and data must be destroyed<br>
<br>
[Under development]<br>
<br>
- The data must be backed up on the server, but passwords can't be exposed<br>
<br>
[Under development]<br>
<br>
- The application was installed into another device and the keys must be<br>
revoked on the server<br>
<br>
[Under development]<br>
<br>
- User wants to configure for how long the keys will be considered valid<br>
<br>
<br>
## JavaScript<br>
<br>
### Dependencies<br>
<br>
- [sjcl](<a href="http://crypto.stanford.edu/sjcl/" target="_blank">http://crypto.stanford.edu/sjcl/</a>) with wrappers for basic<br>
functionalities like: encrypt, decrypt, password salting and key pair<br>
generation.<br>
<br>
<br>
### Implementation details<br>
<br>
- The size of sjcl library is still a concern (28K)<br>
<br>
- Crypto bits were built in a separate module so it may be<br>
included/excluded in a custom build.<br>
<br>
- The project will be developed under AeroGear.js repository<br>
(<a href="https://github.com/aerogear/aerogear-js/pull/57" target="_blank">https://github.com/aerogear/aerogear-js/pull/57</a>)<br>
<br>
### API (draft 0)<br>
<br>
- Password based key derivation support (PBKDF2)<br>
<br>
myEncryptedPassword = AeroGear.password("strong");<br>
<br>
- Symmetric encryption support (GCM)<br>
<br>
- Encryption:<br>
<br>
var options = {<br>
IV: superRandomInitializationVector,<br>
AAD: "whateverAuthenticatedData",<br>
key: generatedKey,<br>
data: "My bonnie lies over the ocean"<br>
};<br>
<br>
var cipherText = AeroGear.encrypt( options );<br>
<br>
- Decryption:<br>
<br>
var options = {<br>
IV: superRandomInitializationVector,<br>
AAD: "whateverAuthenticatedData",<br>
key: generatedKey,<br>
data: cipherText<br>
};<br>
AeroGear.decrypt( options );<br>
<br>
<br>
- Message authentication support (GMAC, HMAC)<br>
<br>
[Under development]<br>
<br>
<br>
**Note**: The implementations below are currently under discussion at<br>
<a href="https://github.com/aerogear/aerogear-js/pull/62" target="_blank">https://github.com/aerogear/aerogear-js/pull/62</a><br>
<br>
- Hashing support (SHA-256, SHA-512)<br>
<br>
digest = AeroGear.crypto.hash("some message");<br>
<br>
- Asymmetric encryption support (ECC)<br>
<br>
var hex = sjcl.codec.hex,<br>
keyPair = new AeroGear.crypto.KeyPair(),<br>
cipherText, plainText,<br>
options = {<br>
IV: superRandomInitializationVector,<br>
AAD: "whateverAuthenticatedData",<br>
key: keyPair.publicKey,<br>
data: ""My bonnie lies over the ocean"<br>
};<br>
cipherText = AeroGear.crypto.encrypt( options );<br>
options.key = keyPair.privateKey;<br>
options.data = cipherText;<br>
plainText = AeroGear.crypto.decrypt( options );<br>
<br>
- Digital signatures support (ECDSA)<br>
<br>
var validation,<br>
options = {<br>
keys: sjcl.ecc.ecdsa.generateKeys(192),<br>
message: "My bonnie lies over the ocean"<br>
};<br>
options.signature = AeroGear.crypto.sign( options );<br>
validation = AeroGear.crypto.verify( options );<br>
<br>
## Android<br>
<br>
### Dependencies<br>
<br>
- [Spongy Castle](<a href="http://rtyley.github.io/spongycastle/" target="_blank">http://rtyley.github.io/spongycastle/</a>) with wrappers<br>
for basic functionalities like: encrypt, decrypt, password salting and<br>
key pair generation.<br>
<br>
<br>
### Implementation details<br>
<br>
- The bouncycastle "provided" in Android doesn't have ECDH that's the<br>
reason why Spongy Castle was chosen.<br>
<br>
- aerogear-crypto-java will be the main repository to provide a crypto<br>
API for Android and the Java server.<br>
<br>
<br>
### API (draft 0)<br>
<br>
**Note**: The implementations below are currently under discussion at<br>
<a href="https://github.com/aerogear/aerogear-crypto-java/tree/refactoring" target="_blank">https://github.com/aerogear/aerogear-crypto-java/tree/refactoring</a><br>
<br>
- Password based key derivation support (PBKDF2)<br>
<br>
Pbkdf2 pbkdf2 = AeroGearCrypto.pbkdf2();<br>
byte[] rawPassword = pbkdf2.encrypt(PASSWORD);<br>
<br>
- Symmetric encryption support (GCM)<br>
<br>
- Encryption:<br>
<br>
CryptoBox cryptoBox = new CryptoBox(new<br>
PrivateKey(SOME_SECRET_KEY));<br>
final byte[] IV = new Random().randomBytes();<br>
final byte[] message = "My bonnie lies over the<br>
ocean".getBytes();<br>
final byte[] ciphertext = cryptoBox.encrypt(IV, message);<br>
<br>
- Decryption:<br>
<br>
CryptoBox pandora = new CryptoBox(new<br>
PrivateKey(SOME_SECRET_KEY));<br>
final byte[] message = pandora.decrypt(IV, ciphertext);<br>
<br>
<br>
- Message authentication support (GMAC, HMAC)<br>
<br>
[Under development]<br>
<br>
- Hashing support (SHA-256, SHA-512)<br>
<br>
[Under development]<br>
<br>
- Asymmetric encryption support (ECC)<br>
<br>
KeyPair keyPair = new KeyPair();<br>
KeyPair keyPairPandora = new KeyPair();<br>
<br>
CryptoBox cryptoBox = new CryptoBox(keyPair.getPrivateKey(),<br>
keyPairPandora.getPublicKey());<br>
final byte[] IV = new Random().randomBytes();<br>
final byte[] message = "My bonnie lies over the ocean".getBytes();<br>
final byte[] ciphertext = cryptoBox.encrypt(IV, message);<br>
<br>
CryptoBox pandora = new<br>
CryptoBox(keyPairPandora.getPrivateKey(), keyPair.getPublicKey());<br>
final byte[] message = pandora.decrypt(IV, ciphertext);<br>
<br>
- Digital signatures support (ECDSA)<br>
<br>
[Under development]<br>
<br>
<br>
## iOS<br>
<br>
### Dependencies<br>
<br>
[TBD] - <a href="http://oksoclap.com/p/iOS_Meeting_(Security)" target="_blank">http://oksoclap.com/p/iOS_Meeting_(Security)</a><br>
<br>
- [Common<br>
Crypto](<a href="https://developer.apple.com/library/mac/documentation/security/conceptual/cryptoservices/GeneralPurposeCrypto/GeneralPurposeCrypto.html" target="_blank">https://developer.apple.com/library/mac/documentation/security/conceptual/cryptoservices/GeneralPurposeCrypto/GeneralPurposeCrypto.html</a>)<br>
<br>
<br>
### Implementation details<br>
<br>
[TBD]<br>
<br>
<br>
### API (draft 0)<br>
<br>
- Password based key derivation support (PBKDF2)<br>
<br>
[Under development]<br>
<br>
- Symmetric encryption support (GCM)<br>
<br>
[Under development]<br>
<br>
- Message authentication support (GMAC, HMAC)<br>
<br>
[Under development]<br>
<br>
- Hashing support (SHA-256, SHA-512)<br>
<br>
[Under development]<br>
<br>
- Asymmetric encryption support (ECC)<br>
<br>
[Under development]<br>
<br>
- Digital signatures support (ECDSA)<br>
<br>
[Under development]<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
abstractj<br>
<br>
<br>
</font></span><br>_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Matthias Wessendorf <br>
<br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>
twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>
</div>