Hello René,

Several answers inline...

On Tue, Jul 10, 2012 at 8:39 AM, René Ruppert <[email protected]> wrote:
> "On iOS this could default to the native implementation" - I really would
> like to know if it WILL.
> Are they compatible?

Yes. The .NET crypto stack is pluggable (new or replacement
implementations) and depends on using compatible implementations.

> Meaning: If I used SHA256Managed so far and now switch,
> can data still be decrypted?

SHA256 is an hash algorithm, so it does not encrypt (not decrypt) but
the CommonCrypto version is fully compatible with the .NET version.
Mono's whole crypto test suite (more than 2000 test cases) have been
ported to Touch.Unit to ensure all implementations behaves
identically.

...

>> Don't use 'new SHA256Managed', use 'SHA256.Create ()'. This way the
>> mono runtime will be able to select the 'best' SHA256 implementation
>> to use. On iOS this could default to the native implementation, on
>> desktop this will default to SHA256Managed.

That's a very good advice. That allows you to reuse your existing code
on .NET, Mono, Mono for Android... without change.

Now the "dynamic" switching allowed by CryptoConfig (the underlying
code under .Create methods) requires the runtime to load extra code at
runtime. That's not possible with iOS. This is explained in more
details in my blogs entries on the subject [1] [2] [3]. IOW for iOS
(only) using 'new SHA256Managed' or 'SHA256.Create ()' will be
identical and both will use the native (not managed) SHA256
implementation that CommonDigest offers.

[1] http://spouliot.wordpress.com/2012/04/30/managed-crypto-vs-commoncrypto/
[2] 
http://spouliot.wordpress.com/2012/05/01/managed-crypto-vs-commoncrypto-digesting-results/
[3] 
http://spouliot.wordpress.com/2012/05/02/managed-crypto-vs-commoncrypto-deciphering-results/

...

>> > from the docs of 5.3:
>> >
>> > Common Crypto
>> >
>> > MonoTouch will now use the iOS CommonCrypto libraries to provide some of
>> > the
>> > functionality exposed by its APIs. This replaces our managed
>> > implementations
>> > with the native versions. It is now used for for digest (hash) and
>> > symmetric
>> > ciphers, leveraging the hardware acceleration for SHA-1 and AES under
>> > the
>> > right circumstances.
>> >
>> >
>> > I'm using code like the one below for hashing and encryption. How can I
>> > take
>> > advantage of HW crypto?

If the "right" conditions are present (see my blog for details) then
iOS (not MonoTouch) will enable the cryptographic hardware.

>> > Or will it automatically become faster?

That's automatic (and out of the developer control). However even if
HW is not enabled (or not available for older devices) then it will
still be faster since it will be using optimized native code versions
of the algorithms.

Sebastien
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to