RecipientId.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  7. using BestHTTP.SecureProtocol.Org.BouncyCastle.X509.Store;
  8. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Cms
  9. {
  10. public class RecipientID
  11. : X509CertStoreSelector
  12. {
  13. private byte[] keyIdentifier;
  14. public byte[] KeyIdentifier
  15. {
  16. get { return Arrays.Clone(keyIdentifier); }
  17. set { keyIdentifier = Arrays.Clone(value); }
  18. }
  19. public override int GetHashCode()
  20. {
  21. int code = Arrays.GetHashCode(keyIdentifier)
  22. ^ Arrays.GetHashCode(this.SubjectKeyIdentifier);
  23. BigInteger serialNumber = this.SerialNumber;
  24. if (serialNumber != null)
  25. {
  26. code ^= serialNumber.GetHashCode();
  27. }
  28. X509Name issuer = this.Issuer;
  29. if (issuer != null)
  30. {
  31. code ^= issuer.GetHashCode();
  32. }
  33. return code;
  34. }
  35. public override bool Equals(
  36. object obj)
  37. {
  38. if (obj == this)
  39. return true;
  40. RecipientID id = obj as RecipientID;
  41. if (id == null)
  42. return false;
  43. return Arrays.AreEqual(keyIdentifier, id.keyIdentifier)
  44. && Arrays.AreEqual(SubjectKeyIdentifier, id.SubjectKeyIdentifier)
  45. && BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.Equals(SerialNumber, id.SerialNumber)
  46. && IssuersMatch(Issuer, id.Issuer);
  47. }
  48. }
  49. }
  50. #pragma warning restore
  51. #endif