diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/crypto/generators/DHKeyGeneratorHelper.cs | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/crypto/src/crypto/generators/DHKeyGeneratorHelper.cs b/crypto/src/crypto/generators/DHKeyGeneratorHelper.cs index 756e8482a..d05c51e80 100644 --- a/crypto/src/crypto/generators/DHKeyGeneratorHelper.cs +++ b/crypto/src/crypto/generators/DHKeyGeneratorHelper.cs @@ -7,47 +7,47 @@ using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Crypto.Generators { - class DHKeyGeneratorHelper - { - internal static readonly DHKeyGeneratorHelper Instance = new DHKeyGeneratorHelper(); - - private DHKeyGeneratorHelper() - { - } - - internal BigInteger CalculatePrivate( - DHParameters dhParams, - SecureRandom random) - { - int limit = dhParams.L; - - if (limit != 0) - { - return new BigInteger(limit, random).SetBit(limit - 1); - } - - BigInteger min = BigInteger.Two; - int m = dhParams.M; - if (m != 0) - { - min = BigInteger.One.ShiftLeft(m - 1); - } - - BigInteger max = dhParams.P.Subtract(BigInteger.Two); - BigInteger q = dhParams.Q; - if (q != null) - { - max = q.Subtract(BigInteger.Two); - } - - return BigIntegers.CreateRandomInRange(min, max, random); - } - - internal BigInteger CalculatePublic( - DHParameters dhParams, - BigInteger x) - { - return dhParams.G.ModPow(x, dhParams.P); - } - } + class DHKeyGeneratorHelper + { + internal static readonly DHKeyGeneratorHelper Instance = new DHKeyGeneratorHelper(); + + private DHKeyGeneratorHelper() + { + } + + internal BigInteger CalculatePrivate( + DHParameters dhParams, + SecureRandom random) + { + int limit = dhParams.L; + + if (limit != 0) + { + return new BigInteger(limit, random).SetBit(limit - 1); + } + + BigInteger min = BigInteger.Two; + int m = dhParams.M; + if (m != 0) + { + min = BigInteger.One.ShiftLeft(m - 1); + } + + BigInteger q = dhParams.Q; + if (q == null) + { + q = dhParams.P; + } + BigInteger max = q.Subtract(BigInteger.Two); + + return BigIntegers.CreateRandomInRange(min, max, random); + } + + internal BigInteger CalculatePublic( + DHParameters dhParams, + BigInteger x) + { + return dhParams.G.ModPow(x, dhParams.P); + } + } } |