KeyParameter.cs 977 B

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