UseSrtpData.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections;
  5. using System.IO;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls
  7. {
  8. /**
  9. * RFC 5764 4.1.1
  10. */
  11. public class UseSrtpData
  12. {
  13. protected readonly int[] mProtectionProfiles;
  14. protected readonly byte[] mMki;
  15. /**
  16. * @param protectionProfiles see {@link SrtpProtectionProfile} for valid constants.
  17. * @param mki valid lengths from 0 to 255.
  18. */
  19. public UseSrtpData(int[] protectionProfiles, byte[] mki)
  20. {
  21. if (protectionProfiles == null || protectionProfiles.Length < 1
  22. || protectionProfiles.Length >= (1 << 15))
  23. {
  24. throw new ArgumentException("must have length from 1 to (2^15 - 1)", "protectionProfiles");
  25. }
  26. if (mki == null)
  27. {
  28. mki = TlsUtilities.EmptyBytes;
  29. }
  30. else if (mki.Length > 255)
  31. {
  32. throw new ArgumentException("cannot be longer than 255 bytes", "mki");
  33. }
  34. this.mProtectionProfiles = protectionProfiles;
  35. this.mMki = mki;
  36. }
  37. /**
  38. * @return see {@link SrtpProtectionProfile} for valid constants.
  39. */
  40. public virtual int[] ProtectionProfiles
  41. {
  42. get { return mProtectionProfiles; }
  43. }
  44. /**
  45. * @return valid lengths from 0 to 255.
  46. */
  47. public virtual byte[] Mki
  48. {
  49. get { return mMki; }
  50. }
  51. }
  52. }
  53. #pragma warning restore
  54. #endif