You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by bu...@apache.org on 2008/08/07 11:34:32 UTC

DO NOT REPLY [Bug 45586] New: Signature verification fails, C14N transform returns null

https://issues.apache.org/bugzilla/show_bug.cgi?id=45586

           Summary: Signature verification fails, C14N transform returns
                    null
           Product: Security
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Signature
        AssignedTo: security-dev@xml.apache.org
        ReportedBy: sburnwal@cisco.com


I am facing a issue with validating the xml signature. I have enveloped 
transform followed by ex-C14N. I did search xmlsec mail archive but to 
no success. Then I tried with debugging the xmlsec src code:

 The Reference object loops through all the configured transforms, in my case
it is http://www.w3.org/2000/09/xmldsig#enveloped-signature 
   transform which returns a (modified, i assume) XMLSignatureInput followed by
  C14N and it returns null! When I tried debugging, i find this:

CanonicalizerBase.engineCanonicalizeXPathNodeSetInternal() method:

           this.canonicalizeXPathNodeSet(doc,doc);
           System.out.println("canonicalizeXPathNodeSet is ok i  
 guess...");
           this._writer.close();
           if (this._writer instanceof ByteArrayOutputStream) {
              byte []  
 sol=((ByteArrayOutputStream)this._writer).toByteArray();
              if (reset) {
                ((ByteArrayOutputStream)this._writer).reset();
              }
                return sol;
           }  else if (this._writer instanceof  
 UnsyncByteArrayOutputStream) {
                 byte  
 []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
               if (reset) {
                   ((UnsyncByteArrayOutputStream)this._writer).reset();
               }
                 return result;
           }
           return null;   <------ returns this null!

 The _writer instance in this case was created in Reference.java method  
 calculateDigest. Thus the ByteArrayOutputStreams of CanonicalizeBase do not
 match with the BufferedOutputStreams of Reference class, causing it to return
 null.

           MessageDigestAlgorithm mda = this.getMessageDigestAlgorithm();

           mda.reset();
           DigesterOutputStream diOs=new DigesterOutputStream(mda);
           OutputStream os=new UnsyncBufferedOutputStream(diOs);   <---  
 not check via instanceof in CanonicalizerBase
           XMLSignatureInput  
 output=this.dereferenceURIandPerformTransforms(os);
           output.updateOutputStream(os);
           os.flush();

Pls help me in resolving this. I am attachin a sample signed SAML token file
that was generated in my app. Note that while this problem comes, we have not
yet reached the actual digest value comparision.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #9 from Satish Burnwal <sb...@cisco.com>  2008-09-19 02:21:15 PST ---
Created an attachment (id=22610)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22610)
Signed SAML token for signature verification


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586


sean.mullan@sun.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEEDINFO




--- Comment #4 from sean.mullan@sun.com  2008-09-16 05:46:05 PST ---
(In reply to comment #3)
> As suggested, I am dumping the pre-digested input just before signing. 

This isn't the pre-digested input. The signature is still inside
the assertion which means the enveloped transform has not been processed yet.

> I did
> debug the signing code as well. Actually during signing itself, while applying
> the all the transforms, in my case which is
> http://www.w3.org/2000/09/xmldsig#enveloped-signature 
> followed by ex-C14N, it returns null. Thus digest seems to be computed for null
> content. 

This is expected behavior. The code is optimized for performance,
such that the bytes are canonicalized and then digested in a streaming manner.
The byte array is not available to be returned, thus null is returned.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586


sean.mullan@sun.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO




--- Comment #2 from sean.mullan@sun.com  2008-08-15 10:06:46 PST ---
I have marked this as NEEDINFO. Here's my analysis that I also 
posted to the mailing list:

Returning null is intentional and is a performance optimization as
Raul mentions. The c14ned bytes are still being written to the output
stream.

I validated the signature with the JSR 105 API, and it is invalid. The
reference digests don't match. Here's some debugging info:

Expected digest: SVUf+cO2NKZpSOHHhPfQjLQNhiE= 
Actual digest: Us20IPzJot+nTKMGap+rv81TVOo=

Pre-digested input (likely skewed by the email app):

<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" 
AssertionID="c63cc59337d833aeb06186e4d19556b2" Id="id-23761097" 
IssueInstant="2008-08-01T08:28:40.298Z" Issuer="SmartInternetTechnology" 
MajorVersion="1" MinorVersion="0"><Conditions
xmlns="urn:oasis:names:tc:SAML:1.0:assertion" 
NotBefore="2008-08-01T08:27:58.688Z" 
NotOnOrAfter="2008-08-01T09:27:58.688Z"></Conditions><AuthenticationStatemen
t
xmlns="urn:oasis:names:tc:SAML:1.0:assertion" 
AuthenticationInstant="2008-08-01T08:27:58.688Z" 
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password"><Subject><Nam
eIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIde
ntifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0
:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject></Auth
enticationStatement><AttributeStatement
xmlns="urn:oasis:names:tc:SAML:1.0:assertion"><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIde
ntifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0
:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject><Attri
bute
AttributeName="telephoneNumber" 
AttributeNamespace="telephoneNumber"><AttributeValue>a</AttributeValue></Att
ribute></AttributeStatement></saml:Assertion>

I suggest you dump the pre-digested input when signing and compare byte for
byte to see what broke the signature.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586


sean.mullan@sun.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEEDINFO




--- Comment #6 from sean.mullan@sun.com  2008-09-17 12:47:10 PST ---
(In reply to comment #5)
> I am little confused when you say pre-digested input. 

By pre-digested input, I mean the bytes that are input to the MessageDigest
algorithm. These are the bytes that are digested and become the DigestValue of
each Reference element. Being able to dump these bytes are usually critical to
debugging XML Signature validation failures. You need to obtain the
pre-digested bytes when you are both signing and validating the XML Signature.
Then you can compare them and look for the differences (i.e. which is causing
the signature not to validate and the digests not to match).

Often, it is caused by the following problems:

- namespaces are leaking into the signed content
- serializing the signature from DOM to xml and back to DOM has introduced
something that breaks the signature, maybe additional whitespace or default
namespaces due to legacy xml, etc

In the Apache XMLSec implementation, there is logging code that dumps the
pre-digested bytes in the org.apache.xml.security.utils.DigesterOutputStream
class:

        if (log.isDebugEnabled()) {
            log.debug("Pre-digested input:");
            StringBuffer sb = new StringBuffer(arg2);
            for (int i=arg1; i<(arg1+arg2); i++) {
                sb.append((char) arg0[i]);
            }
            log.debug(sb.toString());
        }

Please enable this logging and attach this output when you are generating the
signature.

> But looking at the code
> in TransformEnvelopedSignature.java of xmlsec which is:
> 
> if (input.isElement()) {
>                 XMLSignatureInput result = new
> XMLSignatureInput(input.getSubNode());
>                 result.setExcludeNode(signatureElement);
>                 result.setExcludeComments(input.isExcludeComments());
>                 return result;
>          }
> 
> So excluding the sign elt and the comments, I get this:

It is not enough to do that. There is another transform following the enveloped
transform that canonicalizes the nodeset result of the enveloped transform. The
bytes resulting from that are the pre-digested input. But you can just use the
logging code above to dump the bytes.

Also, I am assuming that you used the Apache XMLSec implementation to generate
the signature. If you used some other XML Signature implementation to generate
the signature, then you must use that implementation to dump the pre-digested
bytes. You may need to ask the developers if there is a hook or debug mechanism
to do that (hopefully there is). If there isn't a way to do that, then there
isn't much else I can do with this report and will have to close it. I would
like to help find out the problem, but without this minimal information, it is
impossible since I have nothing to start with.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #1 from Satish Burnwal <sb...@cisco.com>  2008-08-07 02:36:43 PST ---
Created an attachment (id=22400)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22400)
Sample Signed SAML token for verification


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #12 from Satish Burnwal <sb...@cisco.com>  2008-09-23 05:36:19 PST ---
Brent,
You may be right in your assessment but I do not see any way to set the value
for Signature/SignedInfo/CanonicalizationMethod. Looking at the documentation
for the constructor XMLSignature(Document doc, String BaseURI, String
SignatureMethodURI), I see that Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS algo
should be used which is required by the spec and that is what I am also
following (xmlsec examples also use that). I do not see any method either in
XMLSignature or in SignedInfo class to set the c14n algo. Do you know any way
to do that? Can I set the excl c14n algo using the other constructors of
XMLSignature ?


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #15 from Brent Putman <pu...@georgetown.edu>  2008-09-23 13:52:52 PST ---
I'm afraid I haven't worked much with enveloping so I don't know about special
issues there.  I would venture a guess that if the signing and validation are
done in the same XML contexts, then the standard inclusive c14n 1.0 is likely
ok.  However, if you want to take an enveloping Signature element and embed it
in some other document, then you've got issues there, I imagine.

Note also that there is a newer 1.1 version of the inclusive C14N algorithm. 
I'm not up on the differences with 1.0, just fyi.

http://www.w3.org/TR/xml-c14n11/

I believe it's supposed to be supported by the latest Apache Java xmlsec
(1.4.2).


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #10 from Satish Burnwal <sb...@cisco.com>  2008-09-19 02:30:25 PST ---
I have re-posted the signed saml token (see the file attached today) as I
believe the original file I had posted was a bit tampered (sorry for that - I
had played with the Id attr while debugging the issue). In the new attachment,
you can see that pre-digest inputs match, digests also match but signature
validation fails. Can you pls verify this yourself ? 


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586


Satish Burnwal <sb...@cisco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |ASSIGNED




--- Comment #7 from Satish Burnwal <sb...@cisco.com>  2008-09-18 04:17:09 PST ---
As per your suggestion, I have obtained and compared the pre-digest inputs
before signing and before validating the signature - they are identical. In
fact during the signature verification, I observed that the class
org.apache.xml.security.signature.Reference does prints        "Verification
successful for URI #id-29762786". FYI - there were 4 spaces which are present
in both the pre-digested inputs at the end of the line.

Before signing:
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
AssertionID="a8d403e706c3a178cc312f9ec97fe771" Id="id-24044096"
IssueInstant="2008-09-18T08:58:11.321Z" Issuer="SmartInternetTechnology"
MajorVersion="1" MinorVersion="1"><Conditions
xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
NotBefore="2008-09-18T08:58:11.102Z"
NotOnOrAfter="2008-09-18T09:58:11.102Z"></Conditions><AuthenticationStatement
xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
AuthenticationInstant="2008-09-18T08:58:11.102Z"
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password"><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIdentifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject></AuthenticationStatement><AttributeStatement
xmlns="urn:oasis:names:tc:SAML:1.0:assertion"><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIdentifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject><Attribute
AttributeName="telephone"
AttributeNamespace="telephoneNumber"><AttributeValue>a</AttributeValue></Attribute></AttributeStatement></saml:Assertion>


Before validating sign:
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
AssertionID="a8d403e706c3a178cc312f9ec97fe771" Id="id-24044096"
IssueInstant="2008-09-18T08:58:11.321Z" Issuer="SmartInternetTechnology"
MajorVersion="1" MinorVersion="1"><Conditions
xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
NotBefore="2008-09-18T08:58:11.102Z"
NotOnOrAfter="2008-09-18T09:58:11.102Z"></Conditions><AuthenticationStatement
xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
AuthenticationInstant="2008-09-18T08:58:11.102Z"
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password"><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIdentifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject></AuthenticationStatement><AttributeStatement
xmlns="urn:oasis:names:tc:SAML:1.0:assertion"><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIdentifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject><Attribute
AttributeName="telephone"
AttributeNamespace="telephoneNumber"><AttributeValue>a</AttributeValue></Attribute></AttributeStatement></saml:Assertion> 


Also as you wanted to know - there is exc14n tranform after enveloped transform
and we are using the apache xmlsec impl only for signing.

Thanks
-Satish


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586


Satish Burnwal <sb...@cisco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




--- Comment #16 from Satish Burnwal <sb...@cisco.com>  2008-09-25 23:16:08 PST ---
Sean, Brent:
Thank you very much for helping me resolve this.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586


Satish Burnwal <sb...@cisco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sburnwal@cisco.com
             Status|NEEDINFO                    |ASSIGNED




--- Comment #3 from Satish Burnwal <sb...@cisco.com>  2008-09-16 04:58:11 PST ---
As suggested, I am dumping the pre-digested input just before signing. I did
debug the signing code as well. Actually during signing itself, while applying
the all the transforms, in my case which is
http://www.w3.org/2000/09/xmldsig#enveloped-signature 
followed by ex-C14N, it returns null. Thus digest seems to be computed for null
content. Below is the input that is being signed. You can verify that after
signing, signature verification fails. 

<?xml version="1.0"?>
<saml:Assertion AssertionID="b5b4e2ec57d9fb038ec1f45637bc8799" Id="id-6074555"
IssueInstant="2008-09-16T11:48:21.160Z" Issuer="SmartInternetTechnology"
MajorVersion="1" MinorVersion="1" xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"><Conditions
NotBefore="2008-09-16T11:48:20.800Z"
NotOnOrAfter="2008-09-16T12:48:20.800Z"/><AuthenticationStatement
AuthenticationInstant="2008-09-16T11:48:20.800Z"
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password"><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIdentifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject></AuthenticationStatement><AttributeStatement><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIdentifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject><Attribute
AttributeName="telephone"
AttributeNamespace="telephoneNumber"><AttributeValue>a</AttributeValue></Attribute></AttributeStatement><ds:Signature
xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:CanonicalizationMethod
Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:Reference URI="#id-6074555" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Data xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Certificate xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
MIIDdjCCAl6gAwIBAgIKUp60agACAAAA0zANBgkqhkiG9w0BAQUFADAuMRYwFAYDVQQKEw1DaXNj
byBTeXN0ZW1zMRQwEgYDVQQDEwtDQVAtUlRQLTAwMzAeFw0wNTAzMDIxNzUzMDJaFw0xNTAzMDIx
ODAzMDJaMBQxEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
yiU+P4QcZzOcoF2gmCEomDppV+oOJ7I+RJyk+SUiuhxO50o3KiNtLBFEpDKlHJe8552gH0BWOB3f
Dd1DS/+fT0DXo3aixtvMp/Z6MNPxXHqZFA+9BKDvlNvFFI0xReve2DDq4Na2wP+6+fPZxp2Cwt0f
pXUeZTaFz50oo4ydXqcCAwEAAaOCATIwggEuMA4GA1UdDwEB/wQEAwIFoDAdBgNVHQ4EFgQUKwPh
YnELbDtH0lRZWds8+kwgVIQwHwYDVR0jBBgwFoAUEBevY1HgigL/os3QrD36oRawm0gwRgYDVR0f
BD8wPTA7oDmgN4Y1aHR0cDovL3d3dy5jaXNjby5jb20vc2VjdXJpdHkvcGtpL2NybC9DQVAtUlRQ
LTAwMy5jcmwwUwYIKwYBBQUHAQEERzBFMEMGCCsGAQUFBzAChjdodHRwOi8vd3d3LmNpc2NvLmNv
bS9zZWN1cml0eS9wa2kvY2VydHMvQ0FQLVJUUC0wMDMuY2VyMD8GCSsGAQQBgjcUAgQyHjAASQBQ
AFMARQBDAEkAbgB0AGUAcgBtAGUAZABpAGEAdABlAE8AZgBmAGwAaQBuAGUwDQYJKoZIhvcNAQEF
BQADggEBADckYVldCRW6MYtN9hmdH7GnROo/0o9LE70qXyGn1vrGtyW06ceePLq6v3svjPp70Emg
hFoFc+/tX5i1vx9teI8HnfjGEx9BhNbumkXNgrWR8ELB7oozLQ4YRE2BgEklJEhwed4MBSEEQ+3x
DStNrXzj7F8QLLYHy8vKWMoGqnPptmjB7x6LvBCkGa11rEsS8bQs7ShGciily/8Hu5DT0ssFwxCg
psJYjjNuF4MwNLP0u6SFpKDWNH2FUFMrvPB/1pkY/GnRFR0/P+WP3Jw45+Hw6WPxfAS6Fy1Vp9un
CbFIOHt4qotRJu/ArdzP2N5oIRu4uKSTH2un+42StzlrYOA=
</ds:X509Certificate>
</ds:X509Data>
<ds:KeyValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:RSAKeyValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Modulus xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
yiU+P4QcZzOcoF2gmCEomDppV+oOJ7I+RJyk+SUiuhxO50o3KiNtLBFEpDKlHJe8552gH0BWOB3f
Dd1DS/+fT0DXo3aixtvMp/Z6MNPxXHqZFA+9BKDvlNvFFI0xReve2DDq4Na2wP+6+fPZxp2Cwt0f
pXUeZTaFz50oo4ydXqc=
</ds:Modulus>
<ds:Exponent xmlns:ds="http://www.w3.org/2000/09/xmldsig#">AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
</ds:Signature>
</saml:Assertion>

-----------------------
Thanks in adv,
Satish.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #8 from sean.mullan@sun.com  2008-09-18 05:34:02 PST ---
(In reply to comment #7)
> As per your suggestion, I have obtained and compared the pre-digest inputs
> before signing and before validating the signature - they are identical. In
> fact during the signature verification, I observed that the class
> org.apache.xml.security.signature.Reference does prints        "Verification
> successful for URI #id-29762786". 

Does the signature validate successfully? If it does, I'm not sure what the bug
is. When I validated the signature that you originally posted, I was getting a
validation failure due to a reference digesting failure, which is why I asked
for you to obtain the pre-digested bytes when signing, so that I could see why
the digests are different. If the pre-digested bytes are now the same, it seems
that there is no longer a problem ...


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #11 from Brent Putman <pu...@georgetown.edu>  2008-09-19 10:38:55 PST ---
I think your problem is not with the Reference, but with the SignedInfo.  You
are not using exclusive c14n in the
Signature/SignedInfo/CanonicalizationMethod.

That's pretty much required if you are going to sign the Assertion in a
standalone context and then embed in another context where it will be verified
(e.g. inside a SOAP Envelope).

Most likely, the namespaces defined in the SOAP element parents are leaking
into the inclusively canonicalized SignedInfo, causing validation to fail.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #14 from Satish Burnwal <sb...@cisco.com>  2008-09-23 10:26:51 PST ---
Sean, Brent etc:
With Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS signature gets verified.
Since I am going to use this logic in a product, can you shed some light on
which c14n algo should be used when ? Do you think in case of Enveloping
signature, we would be fine with Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS ?


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586


Satish Burnwal <sb...@cisco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |ASSIGNED




--- Comment #5 from Satish Burnwal <sb...@cisco.com>  2008-09-16 22:30:48 PST ---
I am little confused when you say pre-digested input. But looking at the code
in TransformEnvelopedSignature.java of xmlsec which is:

if (input.isElement()) {
                XMLSignatureInput result = new
XMLSignatureInput(input.getSubNode());
                result.setExcludeNode(signatureElement);
                result.setExcludeComments(input.isExcludeComments());
                return result;
         }

So excluding the sign elt and the comments, I get this:
<saml:Assertion AssertionID="b5b4e2ec57d9fb038ec1f45637bc8799" Id="id-6074555"
IssueInstant="2008-09-16T11:48:21.160Z" Issuer="SmartInternetTechnology"
MajorVersion="1" MinorVersion="1" xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"><Conditions
NotBefore="2008-09-16T11:48:20.800Z"
NotOnOrAfter="2008-09-16T12:48:20.800Z"/><AuthenticationStatement
AuthenticationInstant="2008-09-16T11:48:20.800Z"
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password"><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIdentifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject></AuthenticationStatement><AttributeStatement><Subject><NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">arun</NameIdentifier><SubjectConfirmation><ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</ConfirmationMethod></SubjectConfirmation></Subject><Attribute
AttributeName="telephone"
AttributeNamespace="telephoneNumber"><AttributeValue>a</AttributeValue></Attribute></AttributeStatement></saml:Assertion>

Of course, after applying the next transformation (exc14n), what is returned is
null which you is fine.

Am I still missing sth?


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 45586] Signature verification fails, C14N transform returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45586





--- Comment #13 from sean.mullan@sun.com  2008-09-23 06:52:58 PST ---
(In reply to comment #12)
> Brent,
> You may be right in your assessment but I do not see any way to set the value
> for Signature/SignedInfo/CanonicalizationMethod. Looking at the documentation
> for the constructor XMLSignature(Document doc, String BaseURI, String
> SignatureMethodURI), I see that Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS algo
> should be used which is required by the spec and that is what I am also
> following (xmlsec examples also use that). I do not see any method either in
> XMLSignature or in SignedInfo class to set the c14n algo. Do you know any way
> to do that? Can I set the excl c14n algo using the other constructors of
> XMLSignature ?
> 

There's another constructor that takes the C14N algorithm as a uri:

    public XMLSignature(Document doc, String BaseURI, String
SignatureMethodURI,
        String CanonicalizationMethodURI)

Try that, and specify Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS as the URI.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.