GOST3410PublicKeyAlgParameters.cs 2.6 KB

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