ElGamalSecretBcpgKey.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 an ElGamal secret key.</remarks>
  8. public class ElGamalSecretBcpgKey
  9. : BcpgObject, IBcpgKey
  10. {
  11. internal MPInteger x;
  12. /**
  13. * @param in
  14. */
  15. public ElGamalSecretBcpgKey(
  16. BcpgInputStream bcpgIn)
  17. {
  18. this.x = new MPInteger(bcpgIn);
  19. }
  20. /**
  21. * @param x
  22. */
  23. public ElGamalSecretBcpgKey(
  24. BigInteger x)
  25. {
  26. this.x = new MPInteger(x);
  27. }
  28. /// <summary>The format, as a string, always "PGP".</summary>
  29. public string Format
  30. {
  31. get { return "PGP"; }
  32. }
  33. public BigInteger X
  34. {
  35. get { return x.Value; }
  36. }
  37. /// <summary>Return the standard PGP encoding of the key.</summary>
  38. public override byte[] GetEncoded()
  39. {
  40. try
  41. {
  42. return base.GetEncoded();
  43. }
  44. catch (Exception)
  45. {
  46. return null;
  47. }
  48. }
  49. public override void Encode(
  50. BcpgOutputStream bcpgOut)
  51. {
  52. bcpgOut.WriteObject(x);
  53. }
  54. }
  55. }
  56. #pragma warning restore
  57. #endif