GOST3410PrivateKeyParameters.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.Asn1.CryptoPro;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
  7. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
  8. {
  9. public class Gost3410PrivateKeyParameters
  10. : Gost3410KeyParameters
  11. {
  12. private readonly BigInteger x;
  13. public Gost3410PrivateKeyParameters(
  14. BigInteger x,
  15. Gost3410Parameters parameters)
  16. : base(true, parameters)
  17. {
  18. if (x.SignValue < 1 || x.BitLength > 256 || x.CompareTo(Parameters.Q) >= 0)
  19. throw new ArgumentException("Invalid x for GOST3410 private key", "x");
  20. this.x = x;
  21. }
  22. public Gost3410PrivateKeyParameters(
  23. BigInteger x,
  24. DerObjectIdentifier publicKeyParamSet)
  25. : base(true, publicKeyParamSet)
  26. {
  27. if (x.SignValue < 1 || x.BitLength > 256 || x.CompareTo(Parameters.Q) >= 0)
  28. throw new ArgumentException("Invalid x for GOST3410 private key", "x");
  29. this.x = x;
  30. }
  31. public BigInteger X
  32. {
  33. get { return x; }
  34. }
  35. }
  36. }
  37. #pragma warning restore
  38. #endif