I\'m creating a certificate distribution system to keep track of clients and stuff.
What happens is:
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