KeyGenerationParameters.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto
  6. {
  7. /**
  8. * The base class for parameters to key generators.
  9. */
  10. public class KeyGenerationParameters
  11. {
  12. private SecureRandom random;
  13. private int strength;
  14. /**
  15. * initialise the generator with a source of randomness
  16. * and a strength (in bits).
  17. *
  18. * @param random the random byte source.
  19. * @param strength the size, in bits, of the keys we want to produce.
  20. */
  21. public KeyGenerationParameters(
  22. SecureRandom random,
  23. int strength)
  24. {
  25. if (random == null)
  26. throw new ArgumentNullException("random");
  27. if (strength < 1)
  28. throw new ArgumentException("strength must be a positive value", "strength");
  29. this.random = random;
  30. this.strength = strength;
  31. }
  32. /**
  33. * return the random source associated with this
  34. * generator.
  35. *
  36. * @return the generators random source.
  37. */
  38. public SecureRandom Random
  39. {
  40. get { return random; }
  41. }
  42. /**
  43. * return the bit strength for keys produced by this generator,
  44. *
  45. * @return the strength of the keys this generator produces (in bits).
  46. */
  47. public int Strength
  48. {
  49. get { return strength; }
  50. }
  51. }
  52. }
  53. #pragma warning restore
  54. #endif