ParametersWithIV.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.Crypto.Parameters
  6. {
  7. public class ParametersWithIV
  8. : ICipherParameters
  9. {
  10. private readonly ICipherParameters parameters;
  11. private readonly byte[] iv;
  12. public ParametersWithIV(ICipherParameters parameters,
  13. byte[] iv)
  14. : this(parameters, iv, 0, iv.Length)
  15. {
  16. }
  17. public ParametersWithIV(ICipherParameters parameters,
  18. byte[] iv, int ivOff, int ivLen)
  19. {
  20. // NOTE: 'parameters' may be null to imply key re-use
  21. if (iv == null)
  22. throw new ArgumentNullException("iv");
  23. this.parameters = parameters;
  24. this.iv = Arrays.CopyOfRange(iv, ivOff, ivOff + ivLen);
  25. }
  26. public byte[] GetIV()
  27. {
  28. return (byte[])iv.Clone();
  29. }
  30. public ICipherParameters Parameters
  31. {
  32. get { return parameters; }
  33. }
  34. }
  35. }
  36. #pragma warning restore
  37. #endif