in Xamarin.Forms CngKey.Create shows “operation not implemented” error

时光怂恿深爱的人放手 提交于 2019-12-11 17:44:02

问题


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.

来源:https://stackoverflow.com/questions/56147823/in-xamarin-forms-cngkey-create-shows-operation-not-implemented-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!