当前位置: 首页 > 编程语言 > C#

C#学习教程:.NET中的RSA密钥指数是否有限制?在

时间:2023-04-10 19:52:00 C#

.NET中共享RSA密钥指数是否有限制?使用C#我无法导入带有索引{1,0,0,0,15}的公共RSA密钥:有一个例外:System.Security.Cryptography.CryptographicException被捕获HResult=-2146893819Message=BadData.Source=mscorlibStackTrace:在System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32小时)在System.Security.Cryptography.Utils._ImportKey(SafeProvHandlehCSP,Int32keyNumber,CspProviderFlags标志,对象cspObject,SafeKeyHandle&hKey)在System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters参数)在TestRSA.Form1.buttonTest_Click(对象发件人,EventArgse)在c:UsersThomasDocumentsVisualStudio2010ProjectsModulesTestRSAForm1.cs:第32行使用的代码:RSACryptoServiceProviderrsaAlg=newRSACryptoServiceProviderrsaAlg=newRSACryptoServiceRSAPProviders()raCryptoServiceRSAPProviders()byte[5]{1,0,0,0,15};key.Modulus=GetModulus();//长度为256的字节数组...rsaAlg.ImportParameters(ke是);//<<==此调用将抛出异常.NET中的RSA密钥指数是否有限制?(使用Exponent=={1,0,1}导入会成功,因为ThomasMicrosoft的默认提供程序仅支持特定大小的公钥指数,正如CodesInChaos所想:CNG使用RSA密钥对更灵活。例如,CNG支持长度Public大于32位的指数,它支持具有不同p和q长度的密钥。请注意,4字节的指数限制仅适用于MSCSP。如果使用第三方CSP,CryptoAPI应该能够使用5字节的指数。来源:以上为C#学习教程:.NET中RSA密钥索引是否有限制?所有内容分享,如果对大家有用,需要详细了解C#学习教程,希望大家点赞更多关注——本文来自网络收藏,不代表立场,如涉及侵权,请点击右侧联系管理员删除,如需转载请注明出处: