예제 #1
0
        /// <summary>
        /// Verify the signature as certifying the passed in public key as associated
        /// with the passed in user attributes.
        /// </summary>
        /// <param name="userAttributes">User attributes the key was stored under.</param>
        /// <param name="key">The key to be verified.</param>
        /// <returns>True, if the signature matches, false otherwise.</returns>
        public bool VerifyCertification(IPgpUserAttributeSubpacketVector userAttributes, IPgpPublicKey key)
        {
            UpdateWithPublicKey(key);

            //
            // hash in the userAttributes
            //
            try
            {
                using (var bOut = new MemoryStream())
                {
                    foreach (var packet in userAttributes.ToSubpacketArray())
                    {
                        packet.Encode(bOut);
                    }
                    UpdateWithIdData(0xd1, bOut.ToArray());
                }
            }
            catch (IOException e)
            {
                throw new PgpException("cannot encode subpacket array", e);
            }

            this.Update(_sigPck.GetSignatureTrailer());

            return(_sig.VerifySignature(this.GetSignature()));
        }
예제 #2
0
        /// <summary>Allows enumeration of signatures associated with the passed in user attributes.</summary>
        /// <param name="userAttributes">The vector of user attributes to be matched.</param>
        /// <returns>An <c>IEnumerable</c> of <c>PgpSignature</c> objects.</returns>
        public IEnumerable <IPgpSignature> GetSignaturesForUserAttribute(IPgpUserAttributeSubpacketVector userAttributes)
        {
            for (var i = 0; i != _ids.Count; i++)
            {
                if (userAttributes.Equals(_ids[i]))
                {
                    return(_idSigs[i]);
                }
            }

            return(null);
        }
        /// <summary>Allows enumeration of signatures associated with the passed in user attributes.</summary>
        /// <param name="userAttributes">The vector of user attributes to be matched.</param>
        /// <returns>An <c>IEnumerable</c> of <c>PgpSignature</c> objects.</returns>
        public IEnumerable<IPgpSignature> GetSignaturesForUserAttribute(IPgpUserAttributeSubpacketVector userAttributes)
        {
            for (var i = 0; i != _ids.Count; i++)
            {
                if (userAttributes.Equals(_ids[i]))
                {
                    return _idSigs[i];
                }
            }

            return null;
        }
 /// <summary>Remove a certification associated with a given user attributes on a key.</summary>
 /// <param name="key">The key the certifications are to be removed from.</param>
 /// <param name="userAttributes">The user attributes that the certfication is to be removed from.</param>
 /// <param name="certification">The certification to be removed.</param>
 /// <returns>The re-certified key, or null if the certification was not found.</returns>
 public static PgpPublicKey RemoveCertification(IPgpPublicKey key, IPgpUserAttributeSubpacketVector userAttributes, PgpSignature certification)
 {
     return RemoveCert(key, userAttributes, certification);
 }
예제 #5
0
 /// <summary>Remove a certification associated with a given user attributes on a key.</summary>
 /// <param name="key">The key the certifications are to be removed from.</param>
 /// <param name="userAttributes">The user attributes that the certfication is to be removed from.</param>
 /// <param name="certification">The certification to be removed.</param>
 /// <returns>The re-certified key, or null if the certification was not found.</returns>
 public static PgpPublicKey RemoveCertification(IPgpPublicKey key, IPgpUserAttributeSubpacketVector userAttributes, PgpSignature certification)
 {
     return(RemoveCert(key, userAttributes, certification));
 }
        /// <summary>
        /// Verify the signature as certifying the passed in public key as associated
        /// with the passed in user attributes.
        /// </summary>
        /// <param name="userAttributes">User attributes the key was stored under.</param>
        /// <param name="key">The key to be verified.</param>
        /// <returns>True, if the signature matches, false otherwise.</returns>
        public bool VerifyCertification(IPgpUserAttributeSubpacketVector userAttributes, IPgpPublicKey key)
        {
            UpdateWithPublicKey(key);

            //
            // hash in the userAttributes
            //
            try
            {
                using (var bOut = new MemoryStream())
                {
                    foreach (var packet in userAttributes.ToSubpacketArray())
                    {
                        packet.Encode(bOut);
                    }
                    UpdateWithIdData(0xd1, bOut.ToArray());
                }
            }
            catch (IOException e)
            {
                throw new PgpException("cannot encode subpacket array", e);
            }

            this.Update(_sigPck.GetSignatureTrailer());

            return _sig.VerifySignature(this.GetSignature());
        }