Exemplo n.º 1
0
        public bool Verify(PgpKey publicKey, Stream stream, bool ignoreTrailingWhitespace = false)
        {
            var helper = new PgpSignatureTransformation(SignatureType, HashAlgorithm, ignoreTrailingWhitespace);

            new CryptoStream(stream, helper, CryptoStreamMode.Read).CopyTo(Stream.Null);
            helper.Finish(sigPck.Version, sigPck.KeyAlgorithm, sigPck.CreationTime, sigPck.GetHashedSubPackets());
            return(publicKey.Verify(helper.Hash !, sigPck.GetSignature(), helper.HashAlgorithm));
        }
Exemplo n.º 2
0
        public byte[] GetSignature()
        {
            MPInteger[] sigValues = sigPck.GetSignature();
            byte[]      signature;

            if (sigValues != null)
            {
                if (sigValues.Length == 1)                    // an RSA signature
                {
                    signature = sigValues[0].Value.ToByteArrayUnsigned();
                }
                else
                {
                    try
                    {
                        signature = new DerSequence(
                            new DerInteger(sigValues[0].Value),
                            new DerInteger(sigValues[1].Value)).GetEncoded();
                    }
                    catch (IOException e)
                    {
                        throw new PgpException("exception encoding DSA sig.", e);
                    }
                }
            }
            else
            {
                signature = sigPck.GetSignatureBytes();
            }

            return(signature);
        }
Exemplo n.º 3
0
        public byte[] GetSignature()
        {
            MPInteger[] sigValues = sigPck.GetSignature();
            byte[]      signature;
            if (sigValues.Length == 1)    // an RSA signature
            {
                byte[] sBytes = sigValues[0].Value.ToByteArray();

                if (sBytes[0] == 0)
                {
                    signature = new byte[sBytes.Length - 1];
                    Array.Copy(sBytes, 1, signature, 0, signature.Length);
                }
                else
                {
                    signature = sBytes;
                }
            }
            else
            {
                try
                {
                    signature = new DerSequence(
                        new DerInteger(sigValues[0].Value),
                        new DerInteger(sigValues[1].Value)).GetEncoded();
                }
                catch (IOException e)
                {
                    throw new PgpException("exception encoding DSA sig.", e);
                }
            }

            return(signature);
        }
Exemplo n.º 4
0
 public byte[] GetSignature()
 {
     MPInteger[] signature = sigPck.GetSignature();
     if (signature != null)
     {
         if (signature.Length == 1)
         {
             return(signature[0].Value.ToByteArrayUnsigned());
         }
         try
         {
             return(new DerSequence(new DerInteger(signature[0].Value), new DerInteger(signature[1].Value)).GetEncoded());
         }
         catch (IOException exception)
         {
             throw new PgpException("exception encoding DSA sig.", exception);
         }
     }
     return(sigPck.GetSignatureBytes());
 }
Exemplo n.º 5
0
 public byte[] GetSignature()
 {
     //IL_005b: Expected O, but got Unknown
     MPInteger[] signature = sigPck.GetSignature();
     if (signature != null)
     {
         if (signature.Length == 1)
         {
             return(signature[0].Value.ToByteArrayUnsigned());
         }
         try
         {
             return(new DerSequence(new DerInteger(signature[0].Value), new DerInteger(signature[1].Value)).GetEncoded());
         }
         catch (IOException val)
         {
             IOException exception = val;
             throw new PgpException("exception encoding DSA sig.", (global::System.Exception)(object) exception);
         }
     }
     return(sigPck.GetSignatureBytes());
 }