You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.8 KiB
102 lines
2.8 KiB
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR) |
|
#pragma warning disable |
|
using System; |
|
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto; |
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math; |
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security; |
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters |
|
{ |
|
/** |
|
* Parameters for NaccacheStern public private key generation. For details on |
|
* this cipher, please see |
|
* |
|
* http://www.gemplus.com/smart/rd/publications/pdf/NS98pkcs.pdf |
|
*/ |
|
public class NaccacheSternKeyGenerationParameters : KeyGenerationParameters |
|
{ |
|
// private BigInteger publicExponent; |
|
private readonly int certainty; |
|
private readonly int countSmallPrimes; |
|
|
|
/** |
|
* Parameters for generating a NaccacheStern KeyPair. |
|
* |
|
* @param random |
|
* The source of randomness |
|
* @param strength |
|
* The desired strength of the Key in Bits |
|
* @param certainty |
|
* the probability that the generated primes are not really prime |
|
* as integer: 2^(-certainty) is then the probability |
|
* @param countSmallPrimes |
|
* How many small key factors are desired |
|
*/ |
|
public NaccacheSternKeyGenerationParameters( |
|
SecureRandom random, |
|
int strength, |
|
int certainty, |
|
int countSmallPrimes) |
|
: base(random, strength) |
|
{ |
|
if (countSmallPrimes % 2 == 1) |
|
throw new ArgumentException("countSmallPrimes must be a multiple of 2"); |
|
if (countSmallPrimes < 30) |
|
throw new ArgumentException("countSmallPrimes must be >= 30 for security reasons"); |
|
|
|
this.certainty = certainty; |
|
this.countSmallPrimes = countSmallPrimes; |
|
} |
|
|
|
/** |
|
* Parameters for a NaccacheStern KeyPair. |
|
* |
|
* @param random |
|
* The source of randomness |
|
* @param strength |
|
* The desired strength of the Key in Bits |
|
* @param certainty |
|
* the probability that the generated primes are not really prime |
|
* as integer: 2^(-certainty) is then the probability |
|
* @param cntSmallPrimes |
|
* How many small key factors are desired |
|
* @param debug |
|
* Ignored |
|
*/ |
|
|
|
public NaccacheSternKeyGenerationParameters( |
|
SecureRandom random, |
|
int strength, |
|
int certainty, |
|
int countSmallPrimes, |
|
bool debug) |
|
: this(random, strength, certainty, countSmallPrimes) |
|
{ |
|
} |
|
|
|
/** |
|
* @return Returns the certainty. |
|
*/ |
|
public int Certainty |
|
{ |
|
get { return certainty; } |
|
} |
|
|
|
/** |
|
* @return Returns the countSmallPrimes. |
|
*/ |
|
public int CountSmallPrimes |
|
{ |
|
get { return countSmallPrimes; } |
|
} |
|
|
|
|
|
public bool IsDebug |
|
{ |
|
get { return false; } |
|
} |
|
} |
|
} |
|
#pragma warning restore |
|
#endif
|
|
|