/// <summary>
 /// Create a new DigestSha256Signature with a copy of the fields in the given
 /// signature object.
 /// </summary>
 ///
 /// <param name="signature">The signature object to copy.</param>
 public DigestSha256Signature(DigestSha256Signature signature)
 {
     this.signature_   = new Blob();
     this.changeCount_ = 0;
     signature_        = signature.signature_;
 }
 /// <summary>
 /// Create a new DigestSha256Signature with a copy of the fields in the given
 /// signature object.
 /// </summary>
 ///
 /// <param name="signature">The signature object to copy.</param>
 public DigestSha256Signature(DigestSha256Signature signature)
 {
     this.signature_ = new Blob();
     this.changeCount_ = 0;
     signature_ = signature.signature_;
 }
        /// <summary>
        /// Append a SignatureInfo for DigestSha256 to the Interest name, digest the
        /// name components and append a final name component with the signature bits
        /// (which is the digest).
        /// </summary>
        ///
        /// <param name="interest"></param>
        /// <param name="wireFormat">A WireFormat object used to encode the input.</param>
        public void signInterestWithSha256(Interest interest,
				WireFormat wireFormat)
        {
            DigestSha256Signature signature = new DigestSha256Signature();
            // Append the encoded SignatureInfo.
            interest.getName().append(wireFormat.encodeSignatureInfo(signature));

            // Append an empty signature so that the "signedPortion" is correct.
            interest.getName().append(new Name.Component());
            // Encode once to get the signed portion.
            SignedBlob encoding = interest.wireEncode(wireFormat);

            // Digest and set the signature.
            byte[] signedPortionDigest = net.named_data.jndn.util.Common.digestSha256(encoding.signedBuf());
            signature.setSignature(new Blob(signedPortionDigest, false));

            // Remove the empty signature and append the real one.
            interest.setName(interest.getName().getPrefix(-1)
                    .append(wireFormat.encodeSignatureValue(signature)));
        }