Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - Digital Signatures

Output

When you build and run the setRef code, you should get an output similar to the following. There will be differences in the key information, and therefore in the final signature values and digest values.

Notice that in the output the signature values and digest values are different for "obj1" and "obj2".

Attempting to sign the object of 'obj1'

The specified data was signed successfully.
Resultant signature:

<?xml version="1.0"?>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo>
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n
-20010315"/>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>

    <ds:Reference URI="#obj2" Type="http://www.w3.org/2000/09/xmldsig#;Object">
      <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
      <ds:DigestValue>TjR4fN1q3zgKhIrr/o7iY/la22A=</ds:DigestValue>
    </ds:Reference>
  </ds:SignedInfo>
  <ds:SignatureValue>
    lcP+UrGnWPb9b61Ny4zJmeQnzkkbOt+g+UsEXLBOaebFD38PTOKQ5YFJ8udOBtbRSsEThFia
    PbSSvzk9Hjv0udabuMkSI5EJLtM/clrvFO08XZxcNJ7c+j/eH0GnlAOgSimCVN3GquENFpss
    k39o6JUG50R/KAoJ4B5NhCJlGUk=
  </ds:SignatureValue>
  <ds:Object Id="obj1" MimeType="text/plain">Hello, World!</ds:Object>
  <ds:Object Id="obj2">Hi, everyone!</ds:Object>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyValue>
<RSAKeyValue>
<Modulus>
yQAHaJRtZledINO8A88UbmCE38cUnIi5TbqSAkH0jL8xghT45FNM+MmR5YVdfSNKqn8eeH06
HYEQxjpw007Ai+o7ZO8K3UWcYSUmSyTPF1cVdfj6VkiN0AU3BVEA3GKBnccTd2wjRb/p3CXo
puhNlmJwSZKL7sWifHqGZrOqar0=
</Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>
</KeyValue>
</KeyInfo>
</ds:Signature>

Signature verified on the data.
Attempting to sign the object of 'obj2'

The specified data was signed successfully.
Resultant signature:

<?xml version="1.0"?>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo>
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n
-20010315"/>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>

    <ds:Reference URI="#obj2" Type="http://www.w3.org/2000/09/xmldsig#;Object">
      <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
      <ds:DigestValue>UDmNPz5eONRovrmzaXoZ2vm5YJs=</ds:DigestValue>
    </ds:Reference>
  </ds:SignedInfo>
  <ds:SignatureValue>
    FcFn47QoREOwzd34S3qkhGYbp7cIMBagwp8+VurTK+ImUX9NjVRKiA02ps+2FRrd6Ixw2CpV
    ZuX1cvep9x91njy0ssWN/imkqKSEo08wlSX73hrWA5a6vedS/7+sisrkvnW+vY4BU6Y70CoR
    eztcH6ETMnBxwRafqKvwVtO+09Y=
  </ds:SignatureValue>
  <ds:Object Id="obj1" MimeType="text/plain">Hello, World!</ds:Object>
  <ds:Object Id="obj2">Hi, everyone!</ds:Object>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
  <KeyValue>
    <RSAKeyValue>
      <Modulus>
        yQAHaJRtZledINO8A88UbmCE38cUnIi5TbqSAkH0jL8xghT45FNM+MmR5YVdfSNKqn8eeH06

        HYEQxjpw007Ai+o7ZO8K3UWcYSUmSyTPF1cVdfj6VkiN0AU3BVEA3GKBnccTd2wjRb/p3CXo

        puhNlmJwSZKL7sWifHqGZrOqar0=
      </Modulus>
      <Exponent>AQAB</Exponent>
    </RSAKeyValue>
  </KeyValue>
</KeyInfo>
</ds:Signature>

Signature verified on the data.