private void BuildDigestedReferences() { // Default the DigestMethod and Canonicalization ArrayList references = SignedInfo.References; // Reset the cache _refProcessed = new bool[references.Count]; _refLevelCache = new int[references.Count]; ReferenceLevelSortOrder sortOrder = new ReferenceLevelSortOrder(); sortOrder.References = references; // Don't alter the order of the references array list ArrayList sortedReferences = new ArrayList(); foreach (Reference reference in references) { sortedReferences.Add(reference); } sortedReferences.Sort(sortOrder); CanonicalXmlNodeList nodeList = new CanonicalXmlNodeList(); foreach (DataObject obj in m_signature.ObjectList) { nodeList.Add(obj.GetXml()); } foreach (Reference reference in sortedReferences) { // If no DigestMethod has yet been set, default it to sha1 if (reference.DigestMethod == null) { reference.DigestMethod = Reference.DefaultDigestMethod; } SignedXmlDebugLog.LogSigningReference(this, reference); reference.UpdateHashValue(_containingDocument, nodeList); // If this reference has an Id attribute, add it if (reference.Id != null) { nodeList.Add(reference.GetXml()); } } }
public static void BuildDigestedReferences(SignedXml signedXml) { ArrayList references = signedXml.SignedInfo.References; signedXml.RefProcessed = new bool[references.Count]; signedXml.RefLevelCache = new int[references.Count]; ReferenceLevelSortOrder sortOrder = new ReferenceLevelSortOrder(); sortOrder.SetReferences(references); ArrayList sortedReferences = new ArrayList(); foreach (Reference reference in references) { sortedReferences.Add(reference); } sortedReferences.Sort(sortOrder); CanonicalXmlNodeList nodeList = new CanonicalXmlNodeList(); foreach (DataObject obj in signedXml.Signature.GetObjectList()) { nodeList.Add(obj.GetXml()); } foreach (Reference reference in sortedReferences) { if (reference.DigestMethod == null) { reference.DigestMethod = XmlNameSpace.Url[NS.XmlDsigSHA256Url]; } SignedXmlDebugLog.LogSigningReference(signedXml, reference); reference.UpdateHashValue(signedXml.ContainingDocument, nodeList); if (reference.GetId() != null) { nodeList.Add(reference.GetXml()); } } }