Exemple #1
0
        /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
        public bool VerifySignature(
            byte[] signature)
        {
            if (forSigning)
            {
                throw new InvalidOperationException("DSADigestSigner not initialised for verification");
            }

            byte[] hash = new byte[digest.GetDigestSize()];
            digest.DoFinal(hash, 0);

            BigInteger R, S;

            try
            {
                byte[] x = new byte[32];

                Array.Copy(signature, 32, x, 0, 32);
                R = new BigInteger(1, x);

                Array.Copy(signature, 0, x, 0, 32);
                S = new BigInteger(1, x);
            }
            catch (Exception e)
            {
                throw new SignatureException("error decoding signature bytes.", e);
            }

            return(dsaSigner.VerifySignature(hash, R, S));
        }
        /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
        public virtual bool VerifySignature(
            byte[] signature)
        {
            if (forSigning)
            {
                throw new InvalidOperationException("DSADigestSigner not initialised for verification");
            }

            byte[] hash = new byte[digest.GetDigestSize()];
            digest.DoFinal(hash, 0);

            BigInteger R, S;

            try
            {
                int blockLen = signature.Length / 2;
                R = new BigInteger(1, signature, blockLen, blockLen);
                S = new BigInteger(1, signature, 0, blockLen);
            }
            catch (Exception e)
            {
                throw new SignatureException("error decoding signature bytes.", e);
            }

            return(dsaSigner.VerifySignature(hash, R, S));
        }
Exemple #3
0
        public virtual bool VerifySignature(byte[] signature)
        {
            if (!forSigning)
            {
                byte[] array = new byte[digest.GetDigestSize()];
                digest.DoFinal(array, 0);
                try
                {
                    BigInteger[] array2 = DerDecode(signature);
                    return(dsaSigner.VerifySignature(array, array2[0], array2[1]));

IL_0055:
                    bool result;
                    return(result);
                }
                catch (IOException)
                {
                    return(false);

IL_0062:
                    bool result;
                    return(result);
                }
            }
            throw new InvalidOperationException("DSADigestSigner not initialised for verification");
        }
Exemple #4
0
        /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
        public virtual bool VerifySignature(
            byte[] signature)
        {
            if (forSigning)
            {
                throw new InvalidOperationException("DSADigestSigner not initialised for verification");
            }

            byte[] hash = new byte[digest.GetDigestSize()];
            digest.DoFinal(hash, 0);

            BigInteger R, S;

            try
            {
                if (signature.Length != 64 && signature.Length != 128)
                {
                    throw new InvalidOperationException("Unexpected signature length " + signature.Length);
                }

                int len = signature.Length / 2;                 // 32 for 256 bit key and 64 for 512 bit key.
                R = new BigInteger(1, signature, len, len);
                S = new BigInteger(1, signature, 0, len);
            }
            catch (Exception e)
            {
                throw new SignatureException("error decoding signature bytes.", e);
            }

            return(dsaSigner.VerifySignature(hash, R, S));
        }
Exemple #5
0
        public override bool VerifySignature(
            byte[] signature)
        {
            byte[] hash = new byte[digest.GetDigestSize()];
            digest.DoFinal(hash, 0);

            BigInteger R, S;

            try
            {
                var reverseSignature = (byte[])signature.Clone();
                Array.Reverse(reverseSignature);

                R = new BigInteger(1, reverseSignature, 32, 32);
                S = new BigInteger(1, reverseSignature, 0, 32);
            }
            catch (Exception e)
            {
                throw new SignatureException("error decoding signature bytes.", e);
            }

            if (dsaSigner.VerifySignature(hash, R, S))
            {
                return(true);
            }

            try
            {
                R = new BigInteger(1, signature, 32, 32);
                S = new BigInteger(1, signature, 0, 32);
            }
            catch (Exception e)
            {
                throw new SignatureException("error decoding signature bytes.", e);
            }

            return(dsaSigner.VerifySignature(hash, R, S));
        }
Exemple #6
0
 public virtual bool VerifySignature(byte[] signature)
 {
     //IL_000d: Unknown result type (might be due to invalid IL or missing references)
     if (forSigning)
     {
         throw new InvalidOperationException("DSADigestSigner not initialised for verification");
     }
     byte[] array = new byte[digest.GetDigestSize()];
     digest.DoFinal(array, 0);
     try
     {
         BigInteger[] array2 = DerDecode(signature);
         return(dsaSigner.VerifySignature(array, array2[0], array2[1]));
     }
     catch (IOException)
     {
         return(false);
     }
 }
        /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
        public bool VerifySignature(
            byte[] signature)
        {
            if (forSigning)
            {
                throw new InvalidOperationException("DSADigestSigner not initialised for verification");
            }

            byte[] hash = new byte[digest.GetDigestSize()];
            digest.DoFinal(hash, 0);

            try
            {
                BigInteger[] sig = DerDecode(signature);
                return(dsaSigner.VerifySignature(hash, sig[0], sig[1]));
            }
            catch (IOException)
            {
                return(false);
            }
        }
Exemple #8
0
        /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
        public virtual bool VerifySignature(
            byte[] signature)
        {
            if (forSigning)
            {
                throw new InvalidOperationException("DSADigestSigner not initialised for verification");
            }

            byte[] hash = BouncyCastle.Utilities.Digests.DoFinal(digest);

            try
            {
                BigInteger[] sig = DerDecode(signature);

                return(dsaSigner.VerifySignature(hash, sig[0], sig[1]));
            }
            catch (IOException)
            {
                return(false);
            }
        }
Exemple #9
0
    public virtual bool VerifySignature(byte[] signature)
    {
        if (forSigning)
        {
            throw new InvalidOperationException("DSADigestSigner not initialised for verification");
        }
        byte[] array = new byte[digest.GetDigestSize()];
        digest.DoFinal(array, 0);
        BigInteger r;
        BigInteger s;

        try
        {
            r = new BigInteger(1, signature, 32, 32);
            s = new BigInteger(1, signature, 0, 32);
        }
        catch (Exception exception)
        {
            throw new SignatureException("error decoding signature bytes.", exception);
        }
        return(dsaSigner.VerifySignature(array, r, s));
    }
Exemple #10
0
        /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
        public bool VerifySignature(
            byte[] signature)
        {
            if (forSigning)
            {
                throw new InvalidOperationException("DSADigestSigner not initialised for verification");
            }

            byte[] hash = new byte[digest.GetDigestSize()];
            digest.DoFinal(hash, 0);

            BigInteger[] sig;
            try
            {
                sig = DerDecode(signature);
            }
            catch (Exception e)
            {
                throw new SignatureException("error decoding signature bytes.", e);
            }

            return(dsaSigner.VerifySignature(hash, sig[0], sig[1]));
        }
Exemple #11
0
        public virtual bool VerifySignature(byte[] signature)
        {
            //IL_000d: Unknown result type (might be due to invalid IL or missing references)
            if (forSigning)
            {
                throw new InvalidOperationException("DSADigestSigner not initialised for verification");
            }
            byte[] array = new byte[digest.GetDigestSize()];
            digest.DoFinal(array, 0);
            BigInteger r;
            BigInteger s;

            try
            {
                r = new BigInteger(1, signature, 32, 32);
                s = new BigInteger(1, signature, 0, 32);
            }
            catch (global::System.Exception exception)
            {
                throw new SignatureException("error decoding signature bytes.", exception);
            }
            return(dsaSigner.VerifySignature(array, r, s));
        }