1

I develop Xamarin.Forms Application and right now I'm debugging it on my Android device (it's 4.4 ver. of Android, if it matters). I need to use cryptography with ECDsa, so I've found that System.Security.Cryptography.Cng is needed for System.Security.Cryptography to support it. I've downloaded System.Security.Cryptography.Cng ver. 4.5.0 in Nuget Packages for all my projects. So I need to create a new pair of keys to sign some data, and when I try do it like this

var p = new CngKeyCreationParameters
            {
                ExportPolicy = CngExportPolicies.AllowPlaintextExport,
                KeyCreationOptions = CngKeyCreationOptions.OverwriteExistingKey,
                UIPolicy = new CngUIPolicy(CngUIProtectionLevels.ProtectKey, KeyName, null, null, null)
            };
            CngKey key = CngKey.Create(CngAlgorithm.ECDsa, keyAlias, p);

I get error "System.NotImplementedException: The method or operation is not implemented." I've tried like many algorithms for CngAlgorithm, parameters, but still have the same exception. So what I'm doing wrong? I know it can be something pretty silly, and really need help to find this. I've tried to find the same problems, but didn't get lucky. The only close question was: "The requested operation is not supported in CngKey.Create", but it didn't help.

  • Most cryptographic operations on .NET are backed by native implementations (although for e.g. AES there is also a "managed" implementation. I'm wondering if you're doing something wrong or that it is simply not supported on a device like Android... – Maarten Bodewes May 15 '19 at 14:49
  • Yeah, this is what I try to learn. By the way I have tried even example functions from docs.microsoft and they do not work. But I still hope the case is in my crooked hands. – Drovosek2703 May 15 '19 at 16:15
  • Have a look at [this](https://forums.xamarin.com/discussion/80113/how-to-use-system-security-cryptography) thread may help. – nevermore May 16 '19 at 07:21
  • Does `ECDsa.Create()` not suffice? Using CngKey suggests you want to interop with the Windows crypto APIs directly... – bartonjs May 17 '19 at 20:23
  • Ok, I've found that, any ECDsa-related method doesn't work at all. I'm afraid it's really framework's problem, so I've gotta use different digital signature. – Drovosek2703 May 20 '19 at 07:12

0 Answers0