GOST3410PublicKeyAlgParameters.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.CryptoPro
  5. {
  6. public class Gost3410PublicKeyAlgParameters
  7. : Asn1Encodable
  8. {
  9. private DerObjectIdentifier publicKeyParamSet;
  10. private DerObjectIdentifier digestParamSet;
  11. private DerObjectIdentifier encryptionParamSet;
  12. public static Gost3410PublicKeyAlgParameters GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
  13. {
  14. return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
  15. }
  16. public static Gost3410PublicKeyAlgParameters GetInstance(object obj)
  17. {
  18. if (obj == null || obj is Gost3410PublicKeyAlgParameters)
  19. return (Gost3410PublicKeyAlgParameters)obj;
  20. return new Gost3410PublicKeyAlgParameters(Asn1Sequence.GetInstance(obj));
  21. }
  22. public Gost3410PublicKeyAlgParameters(
  23. DerObjectIdentifier publicKeyParamSet,
  24. DerObjectIdentifier digestParamSet)
  25. : this (publicKeyParamSet, digestParamSet, null)
  26. {
  27. }
  28. public Gost3410PublicKeyAlgParameters(
  29. DerObjectIdentifier publicKeyParamSet,
  30. DerObjectIdentifier digestParamSet,
  31. DerObjectIdentifier encryptionParamSet)
  32. {
  33. if (publicKeyParamSet == null)
  34. throw new ArgumentNullException("publicKeyParamSet");
  35. if (digestParamSet == null)
  36. throw new ArgumentNullException("digestParamSet");
  37. this.publicKeyParamSet = publicKeyParamSet;
  38. this.digestParamSet = digestParamSet;
  39. this.encryptionParamSet = encryptionParamSet;
  40. }
  41. private Gost3410PublicKeyAlgParameters(Asn1Sequence seq)
  42. {
  43. this.publicKeyParamSet = (DerObjectIdentifier) seq[0];
  44. this.digestParamSet = (DerObjectIdentifier) seq[1];
  45. if (seq.Count > 2)
  46. {
  47. this.encryptionParamSet = (DerObjectIdentifier) seq[2];
  48. }
  49. }
  50. public DerObjectIdentifier PublicKeyParamSet
  51. {
  52. get { return publicKeyParamSet; }
  53. }
  54. public DerObjectIdentifier DigestParamSet
  55. {
  56. get { return digestParamSet; }
  57. }
  58. public DerObjectIdentifier EncryptionParamSet
  59. {
  60. get { return encryptionParamSet; }
  61. }
  62. public override Asn1Object ToAsn1Object()
  63. {
  64. Asn1EncodableVector v = new Asn1EncodableVector(publicKeyParamSet, digestParamSet);
  65. v.AddOptional(encryptionParamSet);
  66. return new DerSequence(v);
  67. }
  68. }
  69. }
  70. #pragma warning restore
  71. #endif