Exemplo n.º 1
0
		private AsymmetricAlgorithm CheckSignatureInternal (AsymmetricAlgorithm key)
		{
			pkEnumerator = null;

			if (key != null) {
				// check with supplied key
				if (!CheckSignatureWithKey (key))
					return null;
			} else {
				if (Signature.KeyInfo == null)
					return null;
				// no supplied key, iterates all KeyInfo
				while ((key = GetPublicKey ()) != null) {
					if (CheckSignatureWithKey (key)) {
						break;
					}
				}
				pkEnumerator = null;
				if (key == null)
					return null;
			}

			// some parts may need to be downloaded
			// so where doing it last
			if (!CheckReferenceIntegrity (m_signature.SignedInfo.References))
				return null;

			if (manifests != null) {
				// do not use foreach as a manifest could contain manifests...
				for (int i=0; i < manifests.Count; i++) {
					Manifest manifest = new Manifest ((manifests [i] as XmlDocument).DocumentElement);
					if (! CheckReferenceIntegrity (manifest.References))
						return null;
				}
			}
			return key;
		}
Exemplo n.º 2
0
        private AsymmetricAlgorithm CheckSignatureInternal(AsymmetricAlgorithm key)
        {
            pkEnumerator = null;

            if (key != null)
            {
                // check with supplied key
                if (!CheckSignatureWithKey(key))
                {
                    return(null);
                }
            }
            else
            {
#if NET_2_0
                if (Signature.KeyInfo == null)
                {
                    return(null);
                }
#else
                if (Signature.KeyInfo == null)
                {
                    throw new CryptographicException("At least one KeyInfo is required.");
                }
#endif
                // no supplied key, iterates all KeyInfo
                while ((key = GetPublicKey()) != null)
                {
                    if (CheckSignatureWithKey(key))
                    {
                        break;
                    }
                }
                pkEnumerator = null;
                if (key == null)
                {
                    return(null);
                }
            }

            // some parts may need to be downloaded
            // so where doing it last
            if (!CheckReferenceIntegrity(m_signature.SignedInfo.References))
            {
                return(null);
            }

            if (manifests != null)
            {
                // do not use foreach as a manifest could contain manifests...
                for (int i = 0; i < manifests.Count; i++)
                {
                    Manifest manifest = new Manifest((manifests [i] as XmlDocument).DocumentElement);
                    if (!CheckReferenceIntegrity(manifest.References))
                    {
                        return(null);
                    }
                }
            }
            return(key);
        }