Org.BouncyCastle.Crypto.Signers.ECGost3410Signer.Init C# (CSharp) Method

Init() public method

public Init ( bool forSigning, ICipherParameters parameters ) : void
forSigning bool
parameters ICipherParameters
return void
        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;
            }
        }

Usage Example

Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs ea)
        {
            ECGost3410Signer signer = new ECGost3410Signer();

            ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
                "ECGOST3410",
                new FpPoint(curve,
                new FpFieldElement(mod_p, TextBoxToBigInteger16(tbValPublicX)), // x
                new FpFieldElement(mod_p, TextBoxToBigInteger16(tbValPublicY))), // y
                parameters);

            BigInteger H = TextBoxToBigInteger16(tbH);
            BigInteger rs = TextBoxToBigInteger16(tbrs);
            BigInteger ss = TextBoxToBigInteger16(tbss);
            BigInteger q = parameters.N;

            //FpPoint G = (FpPoint)parameters.G;
            //FpPoint Q = new FpPoint(curve, new FpFieldElement(mod_p, TextBoxToBigInteger16(tbValPublicX)), new FpFieldElement(mod_p, TextBoxToBigInteger16(tbValPublicY)));

            BigInteger e = H.Mod(q);
            byte[] ee = e.ToByteArray();
            byte[] message = H.ToByteArray();
            Array.Reverse(message);

            signer.Init(false, pubKey);

            MessageBox.Show(signer.VerifySignature(message, rs, ss).ToString(), "Проверка подписи");

            //FpPoint C = (FpPoint)(G.Multiply(e.ModInverse(q).Multiply(ss).Mod(q)).Subtract(Q.Multiply(e.ModInverse(q).Multiply(rs).Mod(q))));
            //BigInteger x = C.X.ToBigInteger();
        }
All Usage Examples Of Org.BouncyCastle.Crypto.Signers.ECGost3410Signer::Init