首页 > 解决方案 > 在 Xamarin.Forms CngKey.Create 中显示“操作未实现”错误

问题描述

我开发 Xamarin.Forms 应用程序,现在我正在我的 Android 设备上调试它(如果重要的话,它是 Android 的 4.4 版)。我需要将密码学与 ECDsa 一起使用,所以我发现 System.Security.Cryptography 需要 System.Security.Cryptography.Cng 来支持它。我已经下载了 System.Security.Cryptography.Cng 版本。我所有项目的 Nuget 包中的 4.5.0。所以我需要创建一对新的密钥来签署一些数据,当我尝试这样做时

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);

我收到错误“System.NotImplementedException:方法或操作未实现。” 我已经为 CngAlgorithm、参数尝试了许多算法,但仍然有同样的例外。那么我做错了什么?我知道这可能很愚蠢,真的需要帮助才能找到它。我试图找到同样的问题,但没有幸运。唯一接近的问题是:“ CngKey.Create 不支持请求的操作”,但它没有帮助。

标签: c#.netxamarin.formscryptographycng

解决方案


推荐阅读