public SM2KeyExchangePublicParameters(
            ECPublicKeyParameters staticPublicKey,
            ECPublicKeyParameters ephemeralPublicKey)
        {
            if (staticPublicKey == null)
            {
                throw new ArgumentNullException("staticPublicKey");
            }
            if (ephemeralPublicKey == null)
            {
                throw new ArgumentNullException("ephemeralPublicKey");
            }
            if (!staticPublicKey.Parameters.Equals(ephemeralPublicKey.Parameters))
            {
                throw new ArgumentException("Static and ephemeral public keys have different domain parameters");
            }

            this.mStaticPublicKey    = staticPublicKey;
            this.mEphemeralPublicKey = ephemeralPublicKey;
        }
        public MqvPrivateParameters(
            ECPrivateKeyParameters staticPrivateKey,
            ECPrivateKeyParameters ephemeralPrivateKey,
            ECPublicKeyParameters ephemeralPublicKey)
        {
            if (staticPrivateKey == null)
            {
                throw new ArgumentNullException("staticPrivateKey");
            }
            if (ephemeralPrivateKey == null)
            {
                throw new ArgumentNullException("ephemeralPrivateKey");
            }

            ECDomainParameters parameters = staticPrivateKey.Parameters;

            if (!parameters.Equals(ephemeralPrivateKey.Parameters))
            {
                throw new ArgumentException("Static and ephemeral private keys have different domain parameters");
            }

            if (ephemeralPublicKey == null)
            {
                ECPoint q = new FixedPointCombMultiplier().Multiply(parameters.G, ephemeralPrivateKey.D);

                ephemeralPublicKey = new ECPublicKeyParameters(q, parameters);
            }
            else if (!parameters.Equals(ephemeralPublicKey.Parameters))
            {
                throw new ArgumentException("Ephemeral public key has different domain parameters");
            }

            this.staticPrivateKey    = staticPrivateKey;
            this.ephemeralPrivateKey = ephemeralPrivateKey;
            this.ephemeralPublicKey  = ephemeralPublicKey;
        }
Beispiel #3
0
 protected bool Equals(
     ECPublicKeyParameters other)
 {
     return(q.Equals(other.q) && base.Equals(other));
 }