AES Encryption Using MonoTouch

I am creating a Monotouch application that downloads data from a server encrypted using AES. Then I need to decrypt this data when the file is accessed.

What is the best way to do this with MonoTouch? iOS AES decryption is clearly hardware accelerated , and so I would ideally like to call CCCrypt. I am a little n00b for MonoTouch, so does anyone know how to do this?

Or, conversely, is there a better approach to decrypting AES in MonoTouch?

+4
source share
2 answers

MonoTouch provides AES support inside the class library, for example. class RijndaelManaged .

However, you need to know a little more about how it was encrypted (encryption mode, padding mode, key size) in order to be able to decrypt the file. Also, depending on the size of the file, you can decrypt it in memory (safer) if it is small or into a temporary file (if large).

Notes:

  • Rijndael is the original name of the algorithm that was chosen as AES;

  • AES is a subset of Rijndael (only one block size, 128 bits), so you can do anything that supports AES using RijndaelManaged ;

  • MonoTouch currently does not use CommonCrypto (it uses a managed implementation from Mono), so you will not get hardware acceleration. This is likely to change in future releases (and will be compatible, i.e. just recompile for people who have used RijndaelManaged in their applications).

EDIT

MonoTouch 5.3.3 (alpha) now defaults to CommonCrypto implementations, including hardware acceleration (if available) for AES and SHA1.

+6
source

If you are interested in encrypting data at rest (i.e. databases) in MonoTouch SQLCipher, this might be a good option ( http://sqlcipher.net ). The MonoTouch provider for SQLCipher provides full encryption of the SQLite database using AES-256 ( http://sqlcipher.net/sqlcipher-for-monotouch ). There is also a companion library for Mono on Android, which provides the same API and functions for Android ( http://sqlcipher.net/sqlcipher-on-mono-for-android )

Disclosure: I work for Zetetic, author of SQLCipher.

0
source

Source: https://habr.com/ru/post/1402937/


All Articles