UseSrtpData.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls
  5. {
  6. /// <summary>RFC 5764 4.1.1</summary>
  7. public sealed class UseSrtpData
  8. {
  9. private readonly int[] m_protectionProfiles;
  10. private readonly byte[] m_mki;
  11. /// <param name="protectionProfiles">see <see cref="SrtpProtectionProfile"/> for valid constants.</param>
  12. /// <param name="mki">valid lengths from 0 to 255.</param>
  13. public UseSrtpData(int[] protectionProfiles, byte[] mki)
  14. {
  15. if (TlsUtilities.IsNullOrEmpty(protectionProfiles) || protectionProfiles.Length >= (1 << 15))
  16. throw new ArgumentException("must have length from 1 to (2^15 - 1)", "protectionProfiles");
  17. if (mki == null)
  18. {
  19. mki = TlsUtilities.EmptyBytes;
  20. }
  21. else if (mki.Length > 255)
  22. {
  23. throw new ArgumentException("cannot be longer than 255 bytes", "mki");
  24. }
  25. this.m_protectionProfiles = protectionProfiles;
  26. this.m_mki = mki;
  27. }
  28. /// <returns>see <see cref="SrtpProtectionProfile"/> for valid constants.</returns>
  29. public int[] ProtectionProfiles
  30. {
  31. get { return m_protectionProfiles; }
  32. }
  33. /// <returns>valid lengths from 0 to 255.</returns>
  34. public byte[] Mki
  35. {
  36. get { return m_mki; }
  37. }
  38. }
  39. }
  40. #pragma warning restore
  41. #endif