DsaSecretBcpgKey.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Bcpg
  6. {
  7. /// <remarks>Base class for a DSA secret key.</remarks>
  8. public class DsaSecretBcpgKey
  9. : BcpgObject, IBcpgKey
  10. {
  11. internal MPInteger x;
  12. /**
  13. * @param in
  14. */
  15. public DsaSecretBcpgKey(
  16. BcpgInputStream bcpgIn)
  17. {
  18. this.x = new MPInteger(bcpgIn);
  19. }
  20. public DsaSecretBcpgKey(
  21. BigInteger x)
  22. {
  23. this.x = new MPInteger(x);
  24. }
  25. /// <summary>The format, as a string, always "PGP".</summary>
  26. public string Format
  27. {
  28. get { return "PGP"; }
  29. }
  30. /// <summary>Return the standard PGP encoding of the key.</summary>
  31. public override byte[] GetEncoded()
  32. {
  33. try
  34. {
  35. return base.GetEncoded();
  36. }
  37. catch (Exception)
  38. {
  39. return null;
  40. }
  41. }
  42. public override void Encode(
  43. BcpgOutputStream bcpgOut)
  44. {
  45. bcpgOut.WriteObject(x);
  46. }
  47. /**
  48. * @return x
  49. */
  50. public BigInteger X
  51. {
  52. get { return x.Value; }
  53. }
  54. }
  55. }
  56. #pragma warning restore
  57. #endif