EdSecretBcpgKey.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. public sealed class EdSecretBcpgKey
  8. : BcpgObject, IBcpgKey
  9. {
  10. internal readonly MPInteger m_x;
  11. public EdSecretBcpgKey(BcpgInputStream bcpgIn)
  12. {
  13. m_x = new MPInteger(bcpgIn);
  14. }
  15. public EdSecretBcpgKey(BigInteger x)
  16. {
  17. m_x = new MPInteger(x);
  18. }
  19. public string Format => "PGP";
  20. public override byte[] GetEncoded()
  21. {
  22. try
  23. {
  24. return base.GetEncoded();
  25. }
  26. catch (Exception)
  27. {
  28. return null;
  29. }
  30. }
  31. public override void Encode(BcpgOutputStream bcpgOut)
  32. {
  33. bcpgOut.WriteObject(m_x);
  34. }
  35. public BigInteger X => m_x.Value;
  36. }
  37. }
  38. #pragma warning restore
  39. #endif