Inheritance: AsymmetricKeyParameter
        public void Init(
            bool				forSigning,
            ICipherParameters	parameters)
        {
            if (forSigning)
            {
                if (parameters is ParametersWithRandom)
                {
                    ParametersWithRandom rParam = (ParametersWithRandom) parameters;

                    this.random = rParam.Random;
                    parameters = rParam.Parameters;
                }
                else
                {
                    this.random = new SecureRandom();
                }

                if (!(parameters is ECPrivateKeyParameters))
                    throw new InvalidKeyException("EC private key required for signing");

                this.key = (ECPrivateKeyParameters) parameters;
            }
            else
            {
                if (!(parameters is ECPublicKeyParameters))
                    throw new InvalidKeyException("EC public key required for verification");

                this.key = (ECPublicKeyParameters) parameters;
            }
        }
Exemple #2
0
 public ECKeyGenerationParameters(
     DerObjectIdentifier publicKeyParamSet,
     SecureRandom random)
     : this(ECKeyParameters.LookupParameters(publicKeyParamSet), random)
 {
     this.publicKeyParamSet = publicKeyParamSet;
 }
        public virtual void Init(bool forSigning, ICipherParameters parameters)
        {
            SecureRandom providedRandom = null;

            if (forSigning)
            {
                if (parameters is ParametersWithRandom)
                {
                    ParametersWithRandom rParam = (ParametersWithRandom)parameters;

                    providedRandom = rParam.Random;
                    parameters = rParam.Parameters;
                }

                if (!(parameters is ECPrivateKeyParameters))
                    throw new InvalidKeyException("EC private key required for signing");

                this.key = (ECPrivateKeyParameters)parameters;
            }
            else
            {
                if (!(parameters is ECPublicKeyParameters))
                    throw new InvalidKeyException("EC public key required for verification");

                this.key = (ECPublicKeyParameters)parameters;
            }

            this.random = InitSecureRandom(forSigning && !kCalculator.IsDeterministic, providedRandom);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ECKeyGenerationParameters"/> class.
 /// </summary>
 /// <param name="publicKeyParamSet">The public key param set.</param>
 /// <param name="random">The random.</param>
 /// <param name="hashAlgorithm">The hash algorithm.</param>
 /// <param name="symmetricKeyAlgorithm">The symmetric key algorithm.</param>
 public ECKeyGenerationParameters(DerObjectIdentifier publicKeyParamSet, ISecureRandom random, HashAlgorithmTag hashAlgorithm, SymmetricKeyAlgorithmTag symmetricKeyAlgorithm)
     : this(ECKeyParameters.LookupParameters(publicKeyParamSet), random)
 {
     _publicKeyParamSet     = publicKeyParamSet;
     _hashAlgorithm         = hashAlgorithm;
     _symmetricKeyAlgorithm = symmetricKeyAlgorithm;
 }
 protected bool Equals(ECKeyParameters other)
 {
     if (parameters.Equals(other.parameters))
     {
         return(Equals((AsymmetricKeyParameter)other));
     }
     return(false);
 }
Exemple #6
0
 public ECKey(byte[] vch, bool isPrivate)
 {
     if(isPrivate)
         _Key = new ECPrivateKeyParameters(new Org.BouncyCastle.Math.BigInteger(1, vch), DomainParameter);
     else
     {
         var q = Secp256k1.Curve.DecodePoint(vch);
         _Key = new ECPublicKeyParameters("EC", q, DomainParameter);
     }
 }
 protected ECKeyParameters(string algorithm, bool isPrivate, ECDomainParameters parameters) : base(isPrivate)
 {
     if (algorithm == null)
     {
         throw new ArgumentNullException("algorithm");
     }
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     this.algorithm  = ECKeyParameters.VerifyAlgorithmName(algorithm);
     this.parameters = parameters;
 }
 protected ECKeyParameters(string algorithm, bool isPrivate, DerObjectIdentifier publicKeyParamSet) : base(isPrivate)
 {
     if (algorithm == null)
     {
         throw new ArgumentNullException("algorithm");
     }
     if (publicKeyParamSet == null)
     {
         throw new ArgumentNullException("publicKeyParamSet");
     }
     this.algorithm         = ECKeyParameters.VerifyAlgorithmName(algorithm);
     this.parameters        = ECKeyParameters.LookupParameters(publicKeyParamSet);
     this.publicKeyParamSet = publicKeyParamSet;
 }
 protected bool Equals(
     ECKeyParameters other)
 {
     return(parameters.Equals(other.parameters) && base.Equals(other));
 }
 protected bool Equals(ECKeyParameters other)
 {
     return _parameters.Equals(other.Parameters) && base.Equals(other);
 }
 protected bool Equals(ECKeyParameters other)
 {
     return(parameters.Equals(other.parameters) && Equals((AsymmetricKeyParameter)other));
 }
Exemple #12
0
 protected bool Equals(ECKeyParameters other) =>
 (this.parameters.Equals(other.parameters) && base.Equals((AsymmetricKeyParameter)other));