Exemple #1
0
        /// <summary>
        /// Verify that the passed PGP Public key is signed by the passed PGP master signature key.
        /// </summary>
        /// <param name="pgpPublicKey">The encryption PGP public to test the signature from</param>
        /// <param name="publicKeyRingMaster">The signature PGP public key to use to check the signature</param>
        /// <returns>true if the if the sigature is valid, else false</returns>
        public bool VerifySignature(PgpPublicKey pgpPublicKey, string publicKeyRingMaster)
        {
            this.exception = null;

            PgpPublicKey pgpPublicKeyMaster = PgpSignPublicKeyGetter.ReadPublicKey(publicKeyRingMaster);

            foreach (PgpSignature sig in pgpPublicKey.GetKeySignatures())
            {
                if (sig.KeyId != pgpPublicKeyMaster.KeyId)
                {
                    continue;
                }

                try
                {
                    sig.InitVerify(pgpPublicKeyMaster);

                    if (sig.SignatureType == PgpSignature.SubkeyBinding)
                    {
                        bool verify = sig.VerifyCertification(pgpPublicKeyMaster, pgpPublicKey);
                        return(verify);
                    }
                }
                catch (Exception exception)
                {
                    this.exception = exception;
                }
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Verify that the passed PGP Public key is signed by the passed PGP master signature key.
        /// </summary>
        /// <param name="publicKeyRing">The encryption  PGP public keyring to test the signature from</param>
        /// <param name="publicKeyRingMaster">The signature PGP public key to use to check the signature</param>
        /// <returns>true if the if the sigature is valid, else false</returns>
        public bool VerifySignature(string publicKeyRing, string publicKeyRingMaster)
        {
            PgpPublicKey pgpPublicKey       = PgpPublicKeyGetter.ReadPublicKey(publicKeyRing);
            PgpPublicKey pgpPublicKeyMaster = PgpSignPublicKeyGetter.ReadPublicKey(publicKeyRingMaster);
            bool         verify             = VerifySignature(pgpPublicKey, publicKeyRingMaster);

            return(verify);
        }