DhbmParameter.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cmp
  6. {
  7. /**
  8. * DHBMParameter ::= SEQUENCE {
  9. * owf AlgorithmIdentifier,
  10. * -- AlgId for a One-Way Function (SHA-1 recommended)
  11. * mac AlgorithmIdentifier
  12. * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
  13. * } -- or HMAC [RFC2104, RFC2202])
  14. */
  15. public class DhbmParameter
  16. : Asn1Encodable
  17. {
  18. public static DhbmParameter GetInstance(object obj)
  19. {
  20. if (obj is DhbmParameter dhbmParameter)
  21. return dhbmParameter;
  22. if (obj != null)
  23. return new DhbmParameter(Asn1Sequence.GetInstance(obj));
  24. return null;
  25. }
  26. private readonly AlgorithmIdentifier m_owf;
  27. private readonly AlgorithmIdentifier m_mac;
  28. private DhbmParameter(Asn1Sequence sequence)
  29. {
  30. if (sequence.Count != 2)
  31. throw new ArgumentException("expecting sequence size of 2");
  32. m_owf = AlgorithmIdentifier.GetInstance(sequence[0]);
  33. m_mac = AlgorithmIdentifier.GetInstance(sequence[1]);
  34. }
  35. public DhbmParameter(AlgorithmIdentifier owf, AlgorithmIdentifier mac)
  36. {
  37. m_owf = owf;
  38. m_mac = mac;
  39. }
  40. public virtual AlgorithmIdentifier Owf => m_owf;
  41. public virtual AlgorithmIdentifier Mac => m_mac;
  42. public override Asn1Object ToAsn1Object()
  43. {
  44. return new DerSequence(m_owf, m_mac);
  45. }
  46. }
  47. }
  48. #pragma warning restore
  49. #endif