KeyParameter.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
  6. {
  7. public class KeyParameter
  8. : ICipherParameters
  9. {
  10. private readonly byte[] key;
  11. public KeyParameter(
  12. byte[] key)
  13. {
  14. if (key == null)
  15. throw new ArgumentNullException("key");
  16. this.key = (byte[]) key.Clone();
  17. }
  18. public KeyParameter(
  19. byte[] key,
  20. int keyOff,
  21. int keyLen)
  22. {
  23. if (key == null)
  24. throw new ArgumentNullException("key");
  25. if (keyOff < 0 || keyOff > key.Length)
  26. throw new ArgumentOutOfRangeException("keyOff");
  27. if (keyLen < 0 || keyLen > (key.Length - keyOff))
  28. throw new ArgumentOutOfRangeException("keyLen");
  29. this.key = new byte[keyLen];
  30. Array.Copy(key, keyOff, this.key, 0, keyLen);
  31. }
  32. public byte[] GetKey()
  33. {
  34. return (byte[]) key.Clone();
  35. }
  36. }
  37. }
  38. #pragma warning restore
  39. #endif