DSAParameterGenerationParameters.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.Parameters
  6. {
  7. public class DsaParameterGenerationParameters
  8. {
  9. public const int DigitalSignatureUsage = 1;
  10. public const int KeyEstablishmentUsage = 2;
  11. private readonly int l;
  12. private readonly int n;
  13. private readonly int certainty;
  14. private readonly SecureRandom random;
  15. private readonly int usageIndex;
  16. /**
  17. * Construct without a usage index, this will do a random construction of G.
  18. *
  19. * @param L desired length of prime P in bits (the effective key size).
  20. * @param N desired length of prime Q in bits.
  21. * @param certainty certainty level for prime number generation.
  22. * @param random the source of randomness to use.
  23. */
  24. public DsaParameterGenerationParameters(int L, int N, int certainty, SecureRandom random)
  25. : this(L, N, certainty, random, -1)
  26. {
  27. }
  28. /**
  29. * Construct for a specific usage index - this has the effect of using verifiable canonical generation of G.
  30. *
  31. * @param L desired length of prime P in bits (the effective key size).
  32. * @param N desired length of prime Q in bits.
  33. * @param certainty certainty level for prime number generation.
  34. * @param random the source of randomness to use.
  35. * @param usageIndex a valid usage index.
  36. */
  37. public DsaParameterGenerationParameters(int L, int N, int certainty, SecureRandom random, int usageIndex)
  38. {
  39. this.l = L;
  40. this.n = N;
  41. this.certainty = certainty;
  42. this.random = random;
  43. this.usageIndex = usageIndex;
  44. }
  45. public virtual int L
  46. {
  47. get { return l; }
  48. }
  49. public virtual int N
  50. {
  51. get { return n; }
  52. }
  53. public virtual int UsageIndex
  54. {
  55. get { return usageIndex; }
  56. }
  57. public virtual int Certainty
  58. {
  59. get { return certainty; }
  60. }
  61. public virtual SecureRandom Random
  62. {
  63. get { return random; }
  64. }
  65. }
  66. }
  67. #pragma warning restore
  68. #endif