BouncyCastle RSAPrivateKey to .NET RSAPrivateKey

前端 未结 5 599
我在风中等你
我在风中等你 2020-12-07 23:27

I\'m creating a certificate distribution system to keep track of clients and stuff.

What happens is:

  • Client send CSR to Server
  • Server checks a
5条回答
  •  感情败类
    2020-12-08 00:04

    Neither of the solutions worked for me. But I've noticed that the exception is always thrown when one of the following arrays:

    parms.Modulus   = rpckp.Modulus.ToByteArrayUnsigned();
    parms.P         = rpckp.P.ToByteArrayUnsigned();
    parms.Q         = rpckp.Q.ToByteArrayUnsigned();
    parms.DP        = rpckp.DP.ToByteArrayUnsigned();
    parms.DQ        = rpckp.DQ.ToByteArrayUnsigned();
    parms.InverseQ  = rpckp.QInv.ToByteArrayUnsigned();
    parms.D         = rpckp.Exponent.ToByteArrayUnsigned();
    parms.Exponent  = rpckp.PublicExponent.ToByteArrayUnsigned();
    

    has a different size then its neighbor:

    DP, DQ, InverseQ, P, Q
    

    or double sized:

    D, Modulus
    

    For each of these two groups I have calculated the max length and added extra zeroes at the beginning of each array to make them the same length (the same for each group). This works, I suppose that ImportParameters checks that they are of the same length (unfortunately I don't have an access to the ImportParameters code, it seems that it calls some native library).

    I'm using BouncyCastle.Crypto.dll ver 1.7

提交回复
热议问题