ECSecretBCPGKey.cs 1.2 KB

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