<i id='mPd2n'><tr id='mPd2n'><dt id='mPd2n'><q id='mPd2n'><span id='mPd2n'><b id='mPd2n'><form id='mPd2n'><ins id='mPd2n'></ins><ul id='mPd2n'></ul><sub id='mPd2n'></sub></form><legend id='mPd2n'></legend><bdo id='mPd2n'><pre id='mPd2n'><center id='mPd2n'></center></pre></bdo></b><th id='mPd2n'></th></span></q></dt></tr></i><div id='mPd2n'><tfoot id='mPd2n'></tfoot><dl id='mPd2n'><fieldset id='mPd2n'></fieldset></dl></div>
<tfoot id='mPd2n'></tfoot>

<small id='mPd2n'></small><noframes id='mPd2n'>

    <legend id='mPd2n'><style id='mPd2n'><dir id='mPd2n'><q id='mPd2n'></q></dir></style></legend>

        <bdo id='mPd2n'></bdo><ul id='mPd2n'></ul>

      .NET 中的 RSA 密钥指数有限制吗?

      时间:2023-06-02

        <i id='d9SXY'><tr id='d9SXY'><dt id='d9SXY'><q id='d9SXY'><span id='d9SXY'><b id='d9SXY'><form id='d9SXY'><ins id='d9SXY'></ins><ul id='d9SXY'></ul><sub id='d9SXY'></sub></form><legend id='d9SXY'></legend><bdo id='d9SXY'><pre id='d9SXY'><center id='d9SXY'></center></pre></bdo></b><th id='d9SXY'></th></span></q></dt></tr></i><div id='d9SXY'><tfoot id='d9SXY'></tfoot><dl id='d9SXY'><fieldset id='d9SXY'></fieldset></dl></div>
        <legend id='d9SXY'><style id='d9SXY'><dir id='d9SXY'><q id='d9SXY'></q></dir></style></legend>
      • <small id='d9SXY'></small><noframes id='d9SXY'>

              <bdo id='d9SXY'></bdo><ul id='d9SXY'></ul>
              1. <tfoot id='d9SXY'></tfoot>
                  <tbody id='d9SXY'></tbody>
                本文介绍了.NET 中的 RSA 密钥指数有限制吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                使用 C# 我无法导入指数为 {1, 0, 0, 0, 15} 的公共 RSA 密钥:有一个例外:

                Using C# I cannot import a public RSA key with an exponent of {1, 0, 0, 0, 15}: There is an exception:

                System.Security.Cryptography.CryptographicException was caught
                  HResult=-2146893819
                  Message=Bad Data.
                
                  Source=mscorlib
                  StackTrace:
                       at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
                       at System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey)
                       at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)
                       at TestRSA.Form1.buttonTest_Click(Object sender, EventArgs e) in c:UsersThomasDocumentsVisual Studio 2010ProjectsModulesTestRSAForm1.cs:line 32
                

                使用代码:

                RSACryptoServiceProvider rsaAlg = new RSACryptoServiceProvider();
                RSAParameters key = new RSAParameters();
                key.Exponent = new byte[5] { 1, 0, 0, 0, 15 };
                key.Modulus = GetModulus(); // byte Array with length 256...
                rsaAlg.ImportParameters(key); // <<== this call will throw the exception
                

                .NET 中的 RSA 密钥指数有限制吗?(使用 Exponent == { 1, 0, 1 } 导入将成功.

                Is there a limit for RSA key exponents in .NET? (With Exponent == { 1, 0, 1 } the import will succeed.

                问候托马斯

                推荐答案

                微软默认提供者只支持特定大小的公钥指数,CodesInChaos 认为:

                The default provider by Microsoft only supports public key exponents of a specific size, as CodesInChaos mused:

                CNG 在 RSA 密钥对方面更加灵活.例如,CNG 支持长度大于 32 位的公共指数,并且支持 p 和 q 长度不同的密钥.

                CNG is more flexible with regard to RSA key pairs. For example, CNG supports public exponents larger than 32-bits in length, and it supports keys in which p and q are different lengths.

                请注意,4 字节指数的限制仅适用于 MS CSP.如果使用第三方 CSP,CryptoAPI 应该能够使用 5 字节指数.

                Please, note that the restriction of 4 byte exponents are for MS CSPs only. CryptoAPI should be able to work with 5 byte exponents if using a third-party CSP.

                来源:

                • http://blogs.msdn.com/b/alejacma/archive/2010/07/28/cryptoapi-and-5-bytes-exponent-public-keys.aspx
                • 来源:http://msdn.microsoft.com/en-us/library/bb204778%28VS.85%29.aspx

                这篇关于.NET 中的 RSA 密钥指数有限制吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使用 FromBase64String 创建长度为 16 的字节 [] 下一篇:使用 C# 和 CryptoJS 的不同加密结果

                相关文章

                最新文章

                1. <small id='yRxRP'></small><noframes id='yRxRP'>

                  <legend id='yRxRP'><style id='yRxRP'><dir id='yRxRP'><q id='yRxRP'></q></dir></style></legend><tfoot id='yRxRP'></tfoot>

                      <bdo id='yRxRP'></bdo><ul id='yRxRP'></ul>
                    <i id='yRxRP'><tr id='yRxRP'><dt id='yRxRP'><q id='yRxRP'><span id='yRxRP'><b id='yRxRP'><form id='yRxRP'><ins id='yRxRP'></ins><ul id='yRxRP'></ul><sub id='yRxRP'></sub></form><legend id='yRxRP'></legend><bdo id='yRxRP'><pre id='yRxRP'><center id='yRxRP'></center></pre></bdo></b><th id='yRxRP'></th></span></q></dt></tr></i><div id='yRxRP'><tfoot id='yRxRP'></tfoot><dl id='yRxRP'><fieldset id='yRxRP'></fieldset></dl></div>