ECSecretBCPGKey.cs 1.2 KB

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