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)); }
/// <summary>Create a generator for the passed in keyAlgorithm and hashAlgorithm codes.</summary> public PgpSignatureGenerator(PgpSignatureType signatureType, PgpPrivateKey privateKey, PgpHashAlgorithm hashAlgorithm, int version = 4, bool ignoreTrailingWhitespace = false) { // TODO: Add version 5 support if (version < 3 || version > 4) { throw new ArgumentOutOfRangeException(nameof(version)); } this.version = version; this.hashAlgorithm = hashAlgorithm; this.helper = new PgpSignatureTransformation(signatureType, hashAlgorithm, ignoreTrailingWhitespace); this.privateKey = privateKey; }