0

Need to communicate with PHP code that decrypts in MCRYPT_RIJNDAEL_256. Is there any way I can use something exactly like MCRYPT_RIJNDAEL_256 in Swift?

Update: It's worth adding that I have been using AES256, because I was under the impression that AES256 and MCRYPT_RIJNDAEL_256 were the same thing (I understand now that this is not the case)

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
ChairmanMeowth
  • 121
  • 1
  • 4
  • Try [RNCryptor](https://github.com/RNCryptor/RNCryptor). – Adam Sep 08 '15 at 16:19
  • rijndael is just the original name for AES... – Marc B Sep 08 '15 at 16:20
  • 1
    This may help you https://gist.github.com/tlarevo/63840cdd421937ba9174 – RiggsFolly Sep 08 '15 at 16:23
  • I'd prefer to not use third-party libraries. – ChairmanMeowth Sep 08 '15 at 16:25
  • @MaartenBodewes Please be more respectful. There are various reasons OP may not want to use third-party libraries. Yes, it’s going to be hard if it’s not in the core iOS API, but you could have said so in a more polite manner. – Martin Bean Sep 08 '15 at 17:14
  • @MartinBean OK, answered "no". – Maarten Bodewes Sep 08 '15 at 17:21
  • maybe interesting? [Picking encryption cipher for mcrypt](http://stackoverflow.com/questions/4128497/picking-encryption-cipher-for-mcrypt). The second answer maybe more useful to you. If you can live with AES-128 then it may be the way to go? It may be worth trying to see if you can get them to work together? – Ryan Vincent Sep 08 '15 at 17:40
  • @RyanVincent I've voted down the [accepted ("first?") answer](http://stackoverflow.com/a/4131908/589259) by of the link you sent as it is plain wrong on many accounts. Better [point straight to the right answer](http://stackoverflow.com/a/19737721/589259) (by copying the link after hitting "share"). – Maarten Bodewes Sep 08 '15 at 21:46
  • @MaartenBodewes, Ah, that makes sense! Thanks for the advice about referring to the answer I wanted to use - I learned something today. And, yes, that was the answer I meant. – Ryan Vincent Sep 08 '15 at 21:49
  • [You might want to avoid mcrypt entirely](https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong). According to the documentation page, there are [Swift bindings for libsodium](http://doc.libsodium.org/bindings_for_other_languages/index.html), and I maintain the [PHP libsodium documentation](https://paragonie.com/book/pecl-libsodium). – Scott Arciszewski Sep 09 '15 at 05:43

1 Answers1

1

No you cannot, not without using 3rd party libraries. Rijndael 256 is a block cipher with 256 bit block size. Last time I checked the API doesn't contain Rijndael 256 or any other block cipher with that block size, and you cannot force any AES functionality to use a larger block size.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263