AEADParameters.cs 1.4 KB

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