I'd perhaps also say that data is nil, if something goes wrong w/ that read
(in the text)


On Fri, Feb 14, 2014 at 12:22 PM, Christos Vasilakis <
notifications@github.com> wrote:

> In docs/guides/aerogear-ios/Cryptography.asciidoc:
>
> > +    }];
> > +
> > +    // ok time to attempt reading..
> > +    NSArray *data = [store readAll]) { // 9
> > +
> > +    if (data)
> > +        // decryption succeeded!
> > +
> > +
> > +----
> > +
> > +In [1] we initialize a random _salt_ that will be used in the encryption. In [2] we initialize an instance of a link:http://aerogear.org/docs/specs/aerogear-ios/Classes/AGCryptoConfig.html[CryptoConfig] configuration object to set our crypto params. Here we use an http://aerogear.org/docs/specs/aerogear-ios/Classes/AGPassphraseCryptoConfig.html[PassphraseCryptoConfig] object, that sets the necessary crypto params for the PBKDF2 Encryption Service, mainly the salt [3] and the passphrase [4].
> > +
> > +Now that we have setup the configuration, it's time to obtain an instance of an link:http://aerogear.org/docs/specs/aerogear-ios/Classes/AGEncryptionService.html[EncryptionService] and that's exactly what we do in [5]. link:http://aerogear.org/docs/specs/aerogear-ios/Classes/AGKeyManager.html[KeyManager] parses the configuration and returns an instance of it. Because we passed an http://aerogear.org/docs/specs/aerogear-ios/Classes/AGPassphraseCryptoConfig.html[PassphraseCryptoConfig] object, a PBKDF2 encryption service would be returned.
> > +
> > +In [6] we initialize our data store (an encrypted plist [7]), setting the encryption service we obtained earlier [8]. Reading and saving operations are done like all the other stores, but this time the data are transparently encrypted/decrypted.
>
> hmm depending on the specific config object passed an appropriate
> encryption service always would be returned. The issue is with wrong crypto
> params passed on those config object which in that case attempting to read
> will fail ('data' will be nil). That is the reason have put a comment on
> the code.
>
> Let me know if I haven't understand correctly
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/aerogear/aerogear.org/pull/250/files#r9745570>
> .
>



-- 
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf