void ComputeHash(out AsymmetricAlgorithm privateKey, out SignatureDescription description, out HashAlgorithm hash) { privateKey = this.Certificate.PrivateKey; description = CryptoConfig.CreateFromName(this.SHA1SignatureName) as SignatureDescription; if (description == null) { throw new CompactSignatureSecurityException(string.Format( CultureInfo.CurrentCulture, "Error creating SignatureDescription from the signature name {0}", this.SHA1SignatureName)); } hash = description.CreateDigest(); if (hash == null) { throw new CompactSignatureSecurityException(string.Format( CultureInfo.CurrentCulture, "Error creating HashAlgorithm from the signature name {0}", this.SHA1SignatureName)); } HashStream hashStream = this.TakeHashStream(hash); // Create the references StringBuilder sb = new StringBuilder(); if (!String.IsNullOrEmpty(this.InclusivePrefixesList)) { for (int i = 0; i < this.references.Count; i++) { sb.Append(string.Format(SignatureProcessor.ExtendedSignatureReferenceWithPrefixes, this.references[i].Id, this.InclusivePrefixesList, Convert.ToBase64String(this.references[i].Digest))); } } else { for (int i = 0; i < this.references.Count; i++) { sb.Append(string.Format(SignatureProcessor.ExtendedSignatureReferenceNoPrefixes, this.references[i].Id, Convert.ToBase64String(this.references[i].Digest))); } } string expandedSignature = string.Format( ExpandedSignatureScheleton, // Replace the references sb.ToString()); byte[] bytes = Encoding.UTF8.GetBytes(expandedSignature); hashStream.Write(bytes, 0, bytes.Length); hashStream.FlushHash(); }