AEADParameters.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
  5. {
  6. public class AeadParameters
  7. : ICipherParameters
  8. {
  9. private readonly byte[] associatedText;
  10. private readonly byte[] nonce;
  11. private readonly KeyParameter key;
  12. private readonly int macSize;
  13. /**
  14. * Base constructor.
  15. *
  16. * @param key key to be used by underlying cipher
  17. * @param macSize macSize in bits
  18. * @param nonce nonce to be used
  19. */
  20. public AeadParameters(KeyParameter key, int macSize, byte[] nonce)
  21. : this(key, macSize, nonce, null)
  22. {
  23. }
  24. /**
  25. * Base constructor.
  26. *
  27. * @param key key to be used by underlying cipher
  28. * @param macSize macSize in bits
  29. * @param nonce nonce to be used
  30. * @param associatedText associated text, if any
  31. */
  32. public AeadParameters(
  33. KeyParameter key,
  34. int macSize,
  35. byte[] nonce,
  36. byte[] associatedText)
  37. {
  38. this.key = key;
  39. this.nonce = nonce;
  40. this.macSize = macSize;
  41. this.associatedText = associatedText;
  42. }
  43. public virtual KeyParameter Key
  44. {
  45. get { return key; }
  46. }
  47. public virtual int MacSize
  48. {
  49. get { return macSize; }
  50. }
  51. public virtual byte[] GetAssociatedText()
  52. {
  53. return associatedText;
  54. }
  55. public virtual byte[] GetNonce()
  56. {
  57. return nonce;
  58. }
  59. }
  60. }
  61. #pragma warning restore
  62. #endif