public override bool VerifySignature(byte[] p_data, byte[] p_signature)
        {
            if (o_hash_name == null || o_key == null)
            {
                throw new
                      CryptographicException("Qelesi dhe Hash Algoritmi duhet te caktohen!");
            }
            else
            {
                HashAlgorithm x_hash_alg = HashAlgorithm.Create(o_hash_name);

                byte[] x_pkcs = ElGamalSignatureFormatHelper.CreateEMSA_PKCS1_v1_5_ENCODE(p_data, x_hash_alg, o_key.KeyStruct.P.bitCount());

                return(o_key.VerifySignature(x_pkcs, p_signature));
            }
        }
        public override bool VerifySignature(byte[] p_data, byte[] p_signature)
        {
            if (o_hash_name == null || o_key == null)
            {
                throw new
                      CryptographicException("Key and Hash Algorithm must be set");
            }
            else
            {
                // create the hashing algorithm
                HashAlgorithm x_hash_alg = HashAlgorithm.Create(o_hash_name);
                // create a PKCS1 formatted block from the data
                byte[] x_pkcs
                    = ElGamalSignatureFormatHelper.CreateEMSA_PKCS1_v1_5_ENCODE(
                          p_data, x_hash_alg, o_key.KeyStruct.P.bitCount());

                // create and return the signature
                return(o_key.VerifySignature(x_pkcs, p_signature));
            }
        }
Esempio n. 3
0
        private void btnVerify_Click(object sender, EventArgs e)
        {
            x_plaintextForSignature = Encoding.UTF8.GetBytes(txtSignPlaintext.Text);

            ElGamal x_verify_alg = new ElGamalManaged();

            x_verify_alg.FromXmlString(x_alg_signature.ToXmlString(false));

            bool IsValid = x_verify_alg.VerifySignature(x_plaintextForSignature, x_signature);

            if (IsValid)
            {
                pbIsValid.Visible = true;
                pbIsValid.Image   = Resources.Valid;
            }
            else
            {
                pbIsValid.Visible = true;
                pbIsValid.Image   = Resources.InValid;
            }
        }