RSAPrivateKey.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Renci.SshNet.Common;
  6. namespace Renci.SshNet.Security.Cryptography
  7. {
  8. /// <summary>
  9. /// Represents the standard parameters for the Renci.SshNet.Security.Cryptography.RSACipher algorithm.
  10. /// </summary>
  11. public class RSAPrivateKey : RSAPublicKey
  12. {
  13. /// <summary>
  14. /// Represents the D parameter for the Renci.SshNet.Security.Cryptography.RSACipher algorithm.
  15. /// </summary>
  16. public BigInteger D { get; private set; }
  17. /// <summary>
  18. /// Represents the DP parameter for the Renci.SshNet.Security.Cryptography.RSACipher algorithm.
  19. /// </summary>
  20. public BigInteger DP { get; private set; }
  21. /// <summary>
  22. /// Represents the DQ parameter for the Renci.SshNet.Security.Cryptography.RSACipher algorithm.
  23. /// </summary>
  24. public BigInteger DQ { get; private set; }
  25. /// <summary>
  26. /// Represents the InverseQ parameter for the Renci.SshNet.Security.Cryptography.RSACipher algorithm.
  27. /// </summary>
  28. public BigInteger InverseQ { get; private set; }
  29. /// <summary>
  30. /// Represents the P parameter for the Renci.SshNet.Security.Cryptography.RSACipher algorithm.
  31. /// </summary>
  32. public BigInteger P { get; private set; }
  33. /// <summary>
  34. /// Represents the Q parameter for the Renci.SshNet.Security.Cryptography.RSACipher algorithm.
  35. /// </summary>
  36. public BigInteger Q { get; private set; }
  37. /// <summary>
  38. /// Initializes a new instance of the <see cref="RSAPrivateKey"/> class.
  39. /// </summary>
  40. /// <param name="exponent">The exponent.</param>
  41. /// <param name="modulus">The modulus.</param>
  42. /// <param name="d">The d.</param>
  43. /// <param name="dp">The dp.</param>
  44. /// <param name="q">The q.</param>
  45. /// <param name="dq">The dq.</param>
  46. /// <param name="p">The p.</param>
  47. /// <param name="inverseQ">The inverse Q.</param>
  48. public RSAPrivateKey(byte[] exponent, byte[] modulus, byte[] d, byte[] dp, byte[] q, byte[] dq, byte[] p, byte[] inverseQ)
  49. : base(exponent, modulus)
  50. {
  51. if (d == null)
  52. throw new ArgumentNullException("d");
  53. if (dp == null)
  54. throw new ArgumentNullException("dp");
  55. if (q == null)
  56. throw new ArgumentNullException("q");
  57. if (dq == null)
  58. throw new ArgumentNullException("dq");
  59. if (p == null)
  60. throw new ArgumentNullException("p");
  61. if (inverseQ == null)
  62. throw new ArgumentNullException("inverseQ");
  63. this.D = new BigInteger(d.Reverse().ToArray());
  64. this.DP = new BigInteger(dp.Reverse().ToArray());
  65. this.Q = new BigInteger(q.Reverse().ToArray());
  66. this.DQ = new BigInteger(dq.Reverse().ToArray());
  67. this.P = new BigInteger(p.Reverse().ToArray());
  68. this.InverseQ = new BigInteger(inverseQ.Reverse().ToArray());
  69. }
  70. }
  71. }