GOST3410PublicKeyAlgParameters.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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(
  70. publicKeyParamSet, digestParamSet);
  71. if (encryptionParamSet != null)
  72. {
  73. v.Add(encryptionParamSet);
  74. }
  75. return new DerSequence(v);
  76. }
  77. }
  78. }
  79. #pragma warning restore
  80. #endif