KeyGenerationParameters.cs 1.5 KB

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