Questions tagged [xml-signature]

XML Signatures provide integrity, message authentication, and/or signer authentication services for data of any type, whether located within the XML that includes the signature or elsewhere.

XML Signatures can be Enveloped, Enveloping or Detached.

Enveloped XML signature is when the the signature element resides within the root element of the document which contains or refers to the data to be signed.

Enveloping XML signature is when the data to be signed resides or is referenced inside the signature element itself.

Detached XML signature is when the xml data to be signed and the signature are two separate documents.

A Signature in general contains the following elements :

  • Signature - Root Element.
  • SignedInfo - Contains information on what elements should be signed and how they should be signed.
  • CanonicalizationMethod - Defines the canonicalization algorithm to be used before calculating the signature of the SignedInfo element.
  • SignatureMethod - Defines the Signature Method that should be used to sign the SignedInfo Element.
  • Reference - Points to the external document or the internal parts of the document that should be signed.
  • Transforms - Contains various transformations that are to be performed on the data to be signed before calculating the digest.
  • DigestMethod - Contains the the digest algorithm that should be used to calculate the digest of the output of the transformations.
  • DigestValue - Contains the value of the digest calculated using the algorithm specified in the DigestMethod element.
  • SignatureValue - Contains the output after calculating the signature of the whole SignedInfo element after canonicalizing it using the algorithm specified in the CanonicalizationMethod element.

Example of an Enveloped Signature.

<?xml version="1.0" encoding="ISO-8859-1"?>
<Document>
              <Pan>1234</Pan>
              <Name>Qwerty</Name>      
              <MobileNo>12335566</MobileNo>
              <Income-Salary>23000</Income-Salary>
              <Income-Other>12000</Income-Other>
              <TotalAmount>5000</TotalAmount>

              <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
               <SignedInfo>
                <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                <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"/>
                 <Transform Algorithm="http://www.w3.org/TR/1999/REC-xslt-19991116">
                    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
                    <xsl:output method="text"/>
                    <xsl:template match="/">
                    Pan : <xsl:copy-of select="//Pan"/>

                    MobileNo : <xsl:copy-of select="//MobileNo"/>

                    TotalAmount : <xsl:copy-of select="//TotalAmount"/>
                    </xsl:template>
                    </xsl:stylesheet>
                 </Transform>
                </Transforms>
                <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                   <DigestValue>q5RNFTQLSOlNs2GHe+35UsT2aVMMXpsHNDR1LkjuxuQ=</DigestValue>
                </Reference>
                </SignedInfo>
                <SignatureValue>QW/kE0WFj6kfJvY4+xrLzn+uRgmPvTrWEP66he0JH7WtCqmWX1CbDhb2dUQj4nhzpG0KJMZzvV/2
                                Qsrh5kiE40s6IOHIFtlM33LxRTo3bF/lo5kHb0m1GZtY7HQXN0P1cQUw9+BeyI7rFz75flVGLlkv
                                 erjENwxwCD+5DQ+VipY=
                </SignatureValue>
                </Signature>

</Document>

From the above signature element specification and the above example you must have noticed that the signature element includes a Transforms element. A list of transformations are specified in this element. A transformation defines how the data should be extracted and converted before calculating the digest. The output of the Transform is the input for the digest operation.

XML Signatures have been subject to legal disputes. When a human signs an XML document (as opposed to a machine), it is required that the data to be signed be first transformed using xslt (see the above example). If there are more than one transformations, XSLT Transformation should be the last transformation. Then this satisfies the property "What you See is What you Sign" and is thus legally valid.

420 questions
0
votes
0 answers

How to calculate digestvalue for XML in php with enveloped-signature

I am trying to calculate digest value for an digitally signed XML, but I am not able to match the digest value mentioned in DigestValue tag. I am trying to validate XML signature in PHP. First part of the validation is to check digest. I am using…
Ashwani K
  • 7,880
  • 19
  • 63
  • 102
0
votes
1 answer

How to sign a pdf with XML signature

I'm working on an Java application for digital signature and timestamping PDFs, using iText and BouncyCastle. The problem is that we have to make a timestamp with a XML signature received from a web service. Anyone know if this is possible to do…
pericales
  • 33
  • 1
  • 4
0
votes
1 answer

XML signature different on Domino server

Description We are trying to set up communications with a service provider that requires that we sign the XML we send. This is done on a Lotus Domino platform using Java 1.6. The problem is that the signature that gets generated is different when…
SamSon
  • 33
  • 1
  • 5
0
votes
0 answers

Verify an XML signature from SiteMinder with Ruby on Rails

I'm having trouble verifying an XML signed document that was created by SiteMinder with Ruby on Rails xmldsig gem. I cloned the gem and ran through it with the debugger, and I can't find anything wrong. It fails both [:digest_value, :signature].…
Chloe
  • 25,162
  • 40
  • 190
  • 357
0
votes
1 answer

SAML token Digital Signature issue (WSO2 version vs Standalone jars of xml signature)

I use WSO2 to digitally sign and encrypt a message: The web service is deployed on weblogic and is expecting a SAML token, and the body and headers and to be signed and ecrypted. Scenario 1 : Use stand along axis api's (1.6.2 +) to generate a web…
Abdul
  • 694
  • 4
  • 14
  • 29
0
votes
1 answer

Signing XML with XADES-BES using Java

I could not find a way to sign an XML document by using xades4j library in java. What is the way of creating a signed XML document from an unsigned one? First of all, I am new in Java programming and I don't know how to create the parameters and the…
JoshuaJeanThree
  • 1,382
  • 2
  • 22
  • 41
0
votes
1 answer

Which result Verifies a signed XML - Core validation,Signature validation and reference Validation

I have signed an xml document and am trying to verify the signature. I have been going through sample code given in XML API as below After checking for validation, It says core valdiation failed Signature validation failed , but reference validity…
juan
  • 343
  • 3
  • 5
  • 16
0
votes
1 answer

Invalid Signature Reading XML from Http Response

Preface: I've been trying to do XML signature verification on an HTTP response, and I need help! All code is .NET 4.0 using C#. So here's what I'm trying to accomplish: Create a signed XML document on the server Send the signed XML as body of an…
Daniel Simpkins
  • 674
  • 5
  • 18
0
votes
2 answers

Java & XMLDSig: Reference with no URI

I'm trying to sign some text using XMLDSig with javax.xml.crypto.dsig.* package. I need to make a reference to some content being signed. And according to project requirements this reference should not have any URI, it means not
Bobby_Bob
  • 33
  • 6
0
votes
1 answer

Verifiying a xades message with previously embedded xades message

We are validating message which have several embedded xades (BES) messages embedded. Which previously have been vaildated as valid. (Also the signature is embedded.) ...Change location A...
0
votes
1 answer

Enveloping and Detached XML signatures using Apache XML Security C++ (XSec)

What is a correct way of implementing Enveloping and Detached Signatures using Apache XML Security Library (xsec) version 3.1.1? I was searching for some good examples but couldn't find any. The apache website too has listed an example, but it is…
sg1
  • 477
  • 1
  • 4
  • 21
0
votes
2 answers

How to validate signature with phpseclib, in a XML signature message?

I tested the final XML signature file and it sends, "invalid signatures", why? Information: I have prepared this inf. to be signed with XML signature:
user1873420
  • 101
  • 1
  • 2
  • 7
0
votes
1 answer

Why does KeyValue take a public key?

I am trying to sign an XML document using Java and I'm following along with this tutorial. I was trying to sign the document using my private key, but when I looked at the API it says KeyValue only takes a PublicKey as the parameter. Also in the…
snowe
  • 1,312
  • 1
  • 20
  • 41
0
votes
0 answers

XML-File Integrity Check Standard

I have a need to incorporate some kind of integrity check of XML file into it's structure. Considering an XmlDSig as a standard, I wonder is there any way to get rid of asymmetric key (authentication) feature? Or maybe there is some other standard…
frtnum
  • 177
  • 14
0
votes
1 answer

From where the Digest in xmlSig is created?

From where the Digest in xmlSig is created? Its only a checksum/hash from the soap header? have some special treatment on this? thanks
1 2 3
27
28