Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

AesEcb: BlockLength not supported on iOS #62

Closed
rsnitsch opened this issue Jan 21, 2016 · 14 comments
Closed

AesEcb: BlockLength not supported on iOS #62

rsnitsch opened this issue Jan 21, 2016 · 14 comments
Assignees
Milestone

Comments

@rsnitsch
Copy link

On iOS I get the following exception:

System.NotSupportedException: Specified method is not supported.

This is my code:

var provider = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesEcb);
var blockLength = provider.BlockLength; // <- This is where the exception is thrown.

Details:

  • Tested on iPhone 5C 9.1 (real device) and iPhone 6 9.2 (simulator)
  • I can use SymmetricAlgorithm.AesCbcPkcs7 without problems
@AArnott
Copy link
Owner

AArnott commented Jan 21, 2016

I think AES in ECB block mode isn't supported on iOS at all. Either that, or PCLCrypto simply hasn't written the special code on iOS that it requires to use it. If you're aware of which it is, please share. And if we can fix it, please consider sending a PR to fix it.

I'm on a long'ish effort improving crypto support on WinRT/desktop for the next major release of this project so I won't be able to circle back around to iOS for this for a while unless it's just to review a PR.

@rsnitsch
Copy link
Author

According to the Wiki page "Algorithms X platforms support", the ECB blockmode should actually be supported on iOS: https://github.com/AArnott/PCLCrypto/wiki/Algorithms-X-platforms-support

Can you check up on this, please?

@AArnott
Copy link
Owner

AArnott commented Jan 26, 2016

Yes. I'll look more into it.

@rsnitsch
Copy link
Author

rsnitsch commented Feb 4, 2016

Have you found out why the docs say it's supported on iOS? I see two possibilities: First, the docs are wrong. Second, the code is wrong. I think you can find out what it is much faster than anyone else.

Please note that this issue is not very urgent for me. Please take your time. Issue #61 is more important to me.

Best regards,
Robert

@Matt-17
Copy link

Matt-17 commented Feb 5, 2016

I have the same issue. If you look into PCLCrypto.iOS there a no files at all. Is there any implementation yet?

Best regards,
Matt

@AArnott
Copy link
Owner

AArnott commented Feb 5, 2016

@Matt-17 What are you looking at when you don't see any files? There are certainly files to support iOS in the compiled package.

@rsnitsch: I just finished a PInvoke release, so I'm circling back to PCLCrypto work. It may still be a few days before I have an answer for you.

@Matt-17
Copy link

Matt-17 commented Feb 5, 2016

I know figured out, AesCbcPkcs7 is working. All others threw NotImplementedException. I had nuget .86 version.

@AArnott
Copy link
Owner

AArnott commented Feb 5, 2016

@Matt-17 That might be because on iOS we're still using mono APIs for symmetric encryption and it may not support any other encryption types or variants. Or it might simply be because we haven't exposed those variables yet. I'm slowly working through all the platforms, switching from .NET/mono APIs to native crypto for each platform in order to get improved perf and more feature completeness.

@Matt-17
Copy link

Matt-17 commented Feb 5, 2016

No problem. I was just confused earlier, because on documentation it looked like it should work as easy and the same as on Android. Good work anyway :)

@AArnott
Copy link
Owner

AArnott commented Feb 5, 2016

Well I appreciate the reports on documentation. It's not done and fully vetted yet. And it's based on the master branch, besides, which hasn't shipped in quite a while.

@rsnitsch
Copy link
Author

Sorry @AArnott, we have decided to drop PCLCrypto and create our own encryption code for iOS and Android. I will not be able to contribute to a fix for this issue. Sorry.

@AArnott
Copy link
Owner

AArnott commented Feb 23, 2016

Best of luck to you, @rsnitsch. Sorry we couldn't get it working for you in time.
FWIW, it was a bear getting iOS and Android encryption working using their native APIs, and using managed ones was either to limiting or too slow (such as for RSA).
May I ask why you decided to drop PCLCrypto? I suspect this isn't the only issue as it would highly likely be easier for you to fork this project and submit the fix yourself than to create a whole new one. What other reasons went into it?

@rsnitsch
Copy link
Author

Our customer requested that we drop PCLCrypto instead of trying to fix it. We only need simple AES encryption, which was easy to implement on Android and iOS using .NET's AesManaged class. On Android, the AesManaged class was even faster than Android's native Cipher class (about 10-40%). (On iOS we did not even try the native methods.)

@AArnott
Copy link
Owner

AArnott commented Feb 24, 2016

Ah, that makes sense. Thanks.

@AArnott AArnott added this to the 2.0 milestone Mar 12, 2016
@AArnott AArnott self-assigned this Mar 12, 2016
AArnott added a commit that referenced this issue Mar 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants