Пример #1
0
		/**
		 * initialise the key generator.
		 *
		 * @param param the parameters to be used for key generation
		 */
		public void Init(
			KeyGenerationParameters parameters)
		{
			if (parameters == null)
				throw new ArgumentNullException("parameters");

			this.uninitialised = false;

			engineInit(parameters);
		}
Пример #2
0
        public void Init(
            KeyGenerationParameters parameters)
        {
            if (parameters == null)
                throw new ArgumentNullException("parameters");

            // Note: If we start accepting instances of KeyGenerationParameters,
            // must apply constraint checking on strength (see DsaParametersGenerator.Init)

            this.param = (DsaKeyGenerationParameters) parameters;
        }
Пример #3
0
        /**
         * initialise the key generator.
         *
         * @param param the parameters to be used for key generation
         */
        public void Init(
            KeyGenerationParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            this.uninitialised = false;

            engineInit(parameters);
        }
Пример #4
0
 public void Init(
     KeyGenerationParameters parameters)
 {
     if (parameters is RsaKeyGenerationParameters)
     {
         this.param = (RsaKeyGenerationParameters)parameters;
     }
     else
     {
         this.param = new RsaKeyGenerationParameters(
             DefaultPublicExponent, parameters.Random, parameters.Strength, DefaultTests);
     }
 }
Пример #5
0
        public void Init(
            KeyGenerationParameters parameters)
        {
            if (parameters is ECKeyGenerationParameters)
            {
                ECKeyGenerationParameters ecP = (ECKeyGenerationParameters) parameters;

                this.publicKeyParamSet = ecP.PublicKeyParamSet;
                this.parameters = ecP.DomainParameters;
            }
            else
            {
                DerObjectIdentifier oid;
                switch (parameters.Strength)
                {
                    case 192:
                        oid = X9ObjectIdentifiers.Prime192v1;
                        break;
                    case 224:
                        oid = SecObjectIdentifiers.SecP224r1;
                        break;
                    case 239:
                        oid = X9ObjectIdentifiers.Prime239v1;
                        break;
                    case 256:
                        oid = X9ObjectIdentifiers.Prime256v1;
                        break;
                    case 384:
                        oid = SecObjectIdentifiers.SecP384r1;
                        break;
                    case 521:
                        oid = SecObjectIdentifiers.SecP521r1;
                        break;
                    default:
                        throw new InvalidParameterException("unknown key size.");
                }

                X9ECParameters ecps = FindECCurveByOid(oid);

                this.parameters = new ECDomainParameters(
                    ecps.Curve, ecps.G, ecps.N, ecps.H, ecps.GetSeed());
            }

            this.random = parameters.Random;

            if (this.random == null)
            {
                this.random = new SecureRandom();
            }
        }
Пример #6
0
 protected virtual void engineInit(
     KeyGenerationParameters parameters)
 {
     this.random   = parameters.Random;
     this.strength = (parameters.Strength + 7) / 8;
 }
Пример #7
0
		/// <summary>
		/// Initialises the key generator.
		/// </summary>
		/// <remarks>
		/// Poly1305 keys are always 256 bits, so the key length in the provided parameters is ignored.
		/// </remarks>
		protected override void engineInit(KeyGenerationParameters param)
		{
			// Poly1305 keys are always 256 bits
			this.random = param.Random;
			this.strength = 32;
		}
Пример #8
0
		protected virtual void engineInit(
			KeyGenerationParameters parameters)
		{
			this.random = parameters.Random;
			this.strength = (parameters.Strength + 7) / 8;
		}