public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            InternalEncryptedKeyIdentifierClause kic = keyIdentifierClause as InternalEncryptedKeyIdentifierClause;

            if (kic == null)
            {
                return(false);
            }
            return(Matches(kic.GetRawBuffer()));
        }
        public override bool MatchesKeyIdentifierClause(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            LocalIdKeyIdentifierClause lkic = keyIdentifierClause as LocalIdKeyIdentifierClause;

            if (lkic != null && lkic.LocalId == Id)
            {
                return(true);
            }

            InternalEncryptedKeyIdentifierClause khic = keyIdentifierClause as InternalEncryptedKeyIdentifierClause;

            if (keyhash == null)
            {
                keyhash = SHA1.Create().ComputeHash(wrapped_key);
            }
            if (khic != null && khic.Matches(keyhash))
            {
                return(true);
            }

            return(false);
        }
		void WriteInternalEncryptedKeyIdentifierClause (
			XmlWriter w, InternalEncryptedKeyIdentifierClause ic)
		{
			w.WriteStartElement ("o", "SecurityTokenReference", Constants.WssNamespace);
			w.WriteStartElement ("o", "KeyIdentifier", Constants.WssNamespace);
			w.WriteAttributeString ("ValueType", Constants.WssKeyIdentifierEncryptedKey);
			w.WriteString (Convert.ToBase64String (ic.GetBuffer ()));
			w.WriteEndElement ();
			w.WriteEndElement ();
		}