Verify Signed XML document in compact framework

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: dani (dani_at_writeme.com)
Date: 02/16/05


Date: 16 Feb 2005 13:26:50 -0800

I want to convert following VB.Net code to cf Code:

Is there any way to do this? Please help me. Do not say only
System.Security.Cryptography.Xml is not included in cf..

Here is the working code in vb.Net:
(the public key is included in the xml file)

    Public Function VerifyXMLDocument(ByVal sXMLFileName As String, _
                                      ByVal sXMLPublicKey As String)
As Boolean

        ' Load the signed XML file.
        Dim xmldoc As New XmlDocument
        xmldoc.Load(sXMLFileName)

        ' Create an RSA crypto service provider from the embedded
        ' XML document resource (the public key).
        Dim csp As New RSACryptoServiceProvider
        csp.FromXmlString(sXMLPublicKey)

        ' Create the signed XML object.
        Dim sxml As New SignedXml(xmldoc)

        ' Verify the signature.
        If sxml.CheckSignature(csp) Then
            Return True
        Else
            Return False
        End If

    End Function

Here is the signed XML File:

<?xml version="1.0" encoding="utf-16"?>
<license>
  <ComputerName>
  </ComputerName>
  <ComputerMAC>0030BD61F98A</ComputerMAC>
  <CompanyName>
  </CompanyName>
  <UserName>
  </UserName>
  <IsServerLicense>False</IsServerLicense>
  <MaxUser>0</MaxUser>
  <Info>License InetConnector Proxy 1.0.1.1</Info>
  <Guid>c51bfefcdfce4260923e98038fe737644967464699484c6bab54b8dcf6841b4d</Guid>
  <PublicKey>
    <RSAKeyValue>
      <Modulus>wOP27h39Vi5oL92X9kJH4gHOlvOIQRXJZrM32pzLGlwNMm1+Ewi0o5NWmZFHTjHamRjGUQyLEOaGyBixFL7nFvOf+CwM8l1Psi4l5uCZ9deDxcfoH/w9a7KDxNDJhdd5joTvSFSupHYd+GEEpV68RQDeRy4npzcgQtfQYSXFUOc=</Modulus>
      <Exponent>AQAB</Exponent>
    </RSAKeyValue>
  </PublicKey>
  <Tool>
    <ToolName>InetConnector Proxy</ToolName>
    <DateCreated>20050111</DateCreated>
    <DateExpire>99991231</DateExpire>
    <IsTrial>False</IsTrial>
    <IsLicensed>True</IsLicensed>
    <SerialNumber>
    </SerialNumber>
    <DongleWithMAC>
    </DongleWithMAC>
    <Project>
    </Project>
    <Segment>
    </Segment>
    <ToolInfo>1.0.1.1</ToolInfo>
  </Tool>
  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
      <CanonicalizationMethod
Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
      <SignatureMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
      <Reference URI="">
        <Transforms>
          <Transform
Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
        </Transforms>
        <DigestMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        <DigestValue>4lgI4IIJ4aDWn6dutwvtZcXR1sk=</DigestValue>
      </Reference>
    </SignedInfo>
    <SignatureValue>jlraLE6t3iUb5+96pjIRLA3NX/B7l6nMuh7cnObVrdHDnkZcb2DGNQfENeBy6IspvThb1mZtNJK4LwUyU5EE7b3SLiC+0l3Hk7kpCKWSYFth4+ElsSBAROCWPHVWRRQQLpQNmfC4eOZ79gqNXLhQVPE9sssLTwDKuzneqgORYQ8=</SignatureValue>
  </Signature>
</license>



Relevant Pages

  • XML signature validation
    ... I try to implement a XML data signature validation using the ... Differently to the examples provided with the download, my public key is ... not included in the xml file. ...
    (comp.lang.java.programmer)
  • XML signature validation
    ... I try to implement a XML data signature validation using the javax.xml.crypto.* packages from SUN, ... Differently to the examples provided with the download, my public key is not included in the xml file. ...
    (comp.lang.java.programmer)
  • Re: Verify Signed XML document in compact framework
    ... it isn't included in the current release of the .NET CF SP2. ... >> (the public key is included in the xml file) ... >> Public Function VerifyXMLDocument(ByVal sXMLFileName As String, ... >> Here is the signed XML File: ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Verify Signed XML document in compact framework
    ... "dani" wrote in message ... > (the public key is included in the xml file) ... > Public Function VerifyXMLDocument(ByVal sXMLFileName As String, ... > Here is the signed XML File: ...
    (microsoft.public.dotnet.framework.compactframework)
  • Extraction of signed .NET assembly public key
    ... SignedXML class in the .NET Framework. ... same Private key that I digitally sign my assembly with to sign an XML file ... and then within the application check that the XML file will verify with the ... public key that is embedded within the assembly. ...
    (microsoft.public.dotnet.languages.vb)