[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-security-dev
Subject:    RE: SHA1 hash of canonicalized xml
From:       <raghav.rao () wipro ! com>
Date:       2007-08-04 8:43:10
Message-ID: 20D88322B9D55444A327FEB661C30390206DA5 () HYD-MDP-MBX01 ! wipro ! com
[Download RAW message or body]

Hi,
 
You can use the following method in DSIGSignature class :
 
        XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *createBlankSignature(
                XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc,
                canonicalizationMethod cm = CANON_C14N_NOC,
                signatureMethod sm = SIGNATURE_DSA,
                hashMethod hm = HASH_SHA1
        );

Since you only need a SHA1 HASH, pass the signatureMethod as SIGNATURE_NONE.
 
 
 
Br,
Raghu.
 
 
 
thanks Sean for your reply, i'm  using the c++ lib and was looking for the solution \
in the xml-securty-c.

So is there a way to do this using the c++ libs
thanks!!

> Date: Thu, 2 Aug 2007 15:31:43 -0400
> From: Sean.Mullan@Sun.COM
> Subject: Re: SHA1 hash of canonicalized xml
> To: security-dev@xml.apache.org
> 
> k b wrote:
> > How do i generate SHA1 hash of canonicalized xml ?
> > i just want the sha1 hash.
> > 
> > I know while signing a doc one can get the hash,
> > but in this case i just want the hash and don't want to go through the
> > signing process. is there an easier way ?
> > 
> 
> Yes, but you will have to use one of the following APIs:
> 
> 1. javax.xml.crypto.dsig.TransformService if you are using the JSR 105 API
> 
> 2. org.apache.xml.security.c14n.Canonicalizer
> 
> 
> Use one of these APIs to canonicalize the node-set, and then use a
> java.security.MessageDigest or java.security.DigestOutputStream to
> digest the resulting bytes.
> 
> --Sean




The information contained in this electronic message and any attachments to this \
message are intended for the exclusive use of the addressee(s) and may contain \
proprietary, confidential or privileged information. If you are not the intended \
recipient, you should not disseminate, distribute or copy this e-mail. Please notify \
the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check \
this email and any attachments for the presence of viruses. The company accepts no \
liability for any damage caused by any virus transmitted by this email.  
www.wipro.com


[Attachment #3 (text/html)]

<HTML dir=ltr><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#000000 size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>You can use&nbsp;the following method in DSIGSignature \
class :</FONT></DIV> <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement \
*createBlankSignature(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument \
*doc,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
canonicalizationMethod cm = \
CANON_C14N_NOC,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
signatureMethod sm = \
SIGNATURE_DSA,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
hashMethod hm = HASH_SHA1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
);<BR></FONT></DIV> <DIV><FONT face=Arial size=2>Since you only need a SHA1 HASH, \
pass the signatureMethod as SIGNATURE_NONE.</FONT></DIV> <DIV><FONT face=Arial \
size=2></FONT>&nbsp;</DIV> <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Br,</FONT></DIV>
<DIV><FONT face=Arial size=2>Raghu.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>thanks Sean for your reply, i'm&nbsp; using the c++ lib \
and was looking for the solution in the xml-securty-c.<BR><BR>So is there a way to do \
this using the c++ libs<BR>thanks!!<BR><BR>&gt; Date: Thu, 2 Aug 2007 15:31:43 \
-0400<BR>&gt; From: Sean.Mullan@Sun.COM<BR>&gt; Subject: Re: SHA1 hash of \
canonicalized xml<BR>&gt; To: security-dev@xml.apache.org<BR>&gt; <BR>&gt; k b \
wrote:<BR>&gt; &gt; How do i generate SHA1 hash of canonicalized xml ?<BR>&gt; &gt; i \
just want the sha1 hash.<BR>&gt; &gt; <BR>&gt; &gt; I know while signing a doc one \
can get the hash,<BR>&gt; &gt; but in this case i just want the hash and don't want \
to go through the<BR>&gt; &gt; signing process. is there an easier way ?<BR>&gt; &gt; \
<BR>&gt; <BR>&gt; Yes, but you will have to use one of the following APIs:<BR>&gt; \
<BR>&gt; 1. javax.xml.crypto.dsig.TransformService if you are using the JSR 105 \
API<BR>&gt; <BR>&gt; 2. org.apache.xml.security.c14n.Canonicalizer<BR>&gt; <BR>&gt; \
<BR>&gt; Use one of these APIs to canonicalize the node-set, and then use a<BR>&gt; \
java.security.MessageDigest or java.security.DigestOutputStream to<BR>&gt; digest the \
resulting bytes.<BR>&gt; <BR>&gt; --Sean<BR></DIV></FONT></BODY></HTML> \
<table><tr><td bgcolor=#ffffff><font color=#000000><br> The information contained in \
this electronic message and any attachments to this message are intended for the \
exclusive use of the addressee(s) and may contain proprietary, confidential or \
privileged information. If you are not the intended recipient, you should not \
disseminate, distribute or copy this e-mail. Please notify the sender immediately and \
destroy all copies of this message and any attachments. <br> <br>
WARNING: Computer viruses can be transmitted via email. The recipient should check \
this email and any attachments for the presence of viruses. The company accepts no \
liability for any damage caused by any virus transmitted by this email.<br>  <br>
www.wipro.com<br>
</font></td></tr></table>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic