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