Return-Path: Delivered-To: apmail-xml-security-dev-archive@www.apache.org Received: (qmail 3169 invoked from network); 6 Aug 2008 18:03:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Aug 2008 18:03:22 -0000 Received: (qmail 76959 invoked by uid 500); 6 Aug 2008 18:03:21 -0000 Delivered-To: apmail-xml-security-dev-archive@xml.apache.org Received: (qmail 76656 invoked by uid 500); 6 Aug 2008 18:03:20 -0000 Mailing-List: contact security-dev-help@xml.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: security-dev@xml.apache.org List-Id: Delivered-To: mailing list security-dev@xml.apache.org Received: (qmail 76645 invoked by uid 99); 6 Aug 2008 18:03:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2008 11:03:20 -0700 X-ASF-Spam-Status: No, hits=2.8 required=10.0 tests=SPF_PASS,WEIRD_QUOTING X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jdmarshall@gmail.com designates 74.125.44.156 as permitted sender) Received: from [74.125.44.156] (HELO yx-out-1718.google.com) (74.125.44.156) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2008 18:02:25 +0000 Received: by yx-out-1718.google.com with SMTP id 36so19924yxh.28 for ; Wed, 06 Aug 2008 11:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=i2MhBL1zrQD4wNu/KUB6d+2hs9IUQMZ5xRIjV5QYIbw=; b=S2Wi7+LF89klfuvLBpVpt70BmmjWbCx7OOLakzMOApsTrfBl59XmK6XPdBAYo+Czi0 YSIhJT9Qk8Z/db0FBJwZU+0Red9QDnQ4ssCz5xHu9TM45t+zIE59FybZz9zsChu4D8gM qzs039IOdGRgutrqUBulHFBqmnTfRQ5gKcx7w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=HkNgRv90OIrrqKOAohhN32XUtrknVJTXnraYzrXaJ6eKXYwCZT7LDfchar7STZuOqk h44NgT2xHcESeH2GNkSeyrjXrB15myFc979rbsYcBGWOrqj5UQYW4eaNHk3GgwnOr5Ya yWWqNmyYq85CFEYpN2kiNH/jinte2jTchrHuE= Received: by 10.150.202.8 with SMTP id z8mr3827138ybf.34.1218045754761; Wed, 06 Aug 2008 11:02:34 -0700 (PDT) Received: by 10.150.229.9 with HTTP; Wed, 6 Aug 2008 11:02:34 -0700 (PDT) Message-ID: <3cf41bb90808061102p11991f04tf88adc43496989e0@mail.gmail.com> Date: Wed, 6 Aug 2008 11:02:34 -0700 From: "jason marshall" To: security-dev@xml.apache.org Subject: Re: Remote private key In-Reply-To: <3BDF182267B38B419F95D30CDCB7849F9416B4@svrcorreoeo.sadiel.es> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <3BDF182267B38B419F95D30CDCB7849F8ED0E8@svrcorreoeo.sadiel.es> <3BDF182267B38B419F95D30CDCB7849F8ED12B@svrcorreoeo.sadiel.es> <3BDF182267B38B419F95D30CDCB7849F9416B4@svrcorreoeo.sadiel.es> X-Virus-Checked: Checked by ClamAV on apache.org Perhaps it goes without saying, but I'm a sucker for pointing out the supposedly obvious (mostly because of how often it turns out not to have been so obvious). If you have your keys on one machine, and your signed material on another, how are you getting the data between them without someone altering it? One thing you might consider doing is applying a temporary signature on the machine that has the source material, and then send the signed XML document back to the machine holding the real key to add a second signature (the one third parties will honor). That should prove easier to pull off than trying to trick the XML-Sec library into signing something without calculating the digests itself first. I tried to do this with 1.3 and had no luck. I would be interested in hearing if you guys figure out how to do this, however not for remote signing (rather for re-signing to replace an expiring cert). -Jason On Tue, Aug 5, 2008 at 11:12 PM, Lopez Cantero, Sergio wrote: > This is because before you sign it, you have to encode in DER the digest > with something like: > > (Using bouncycastle classes) > > public static byte[] doDER(byte[] data) throws IOException { > > //This OID is for SHA1 only > > String hashOID =3D 1.3.14.3.2.26; > > DigestInfo dInfo =3D new DigestInfo(new AlgorithmIdentifier( > > new DERObjectIdentifier(hashOID), null), data); > > return dInfo.getEncoded(ASN1Encodable.DER); > > } > > I recommend sending the digested hash, not the entire byte secuence, so y= ou > can do DER it and sign it with "NONEwithRSA" algorithm afterwards. > > De: Legido Mart=EDnez, Isidoro [mailto:islegmar@gmail.com] > Enviado el: martes, 05 de agosto de 2008 23:21 > Para: security-dev@xml.apache.org > Asunto: Re: Remote private key > > > > Hi: > > I'm still having problems. After building the Signature element (everythi= ng > but the SignatureValue element) I execute: > > [Server side] > XMLSignature sig =3D .... -> It uses > http://www.w3.org/2000/09/xmldsig#rsa-sha1 as signature method > sig.getSignedInfo().generateDigestValues(); > byte[] data2Sign =3D sig.getSignedInfo().getCanonicalizedOctetStream(); > > then, the Server sends 'data2Sign' to the Client (encoded) and the client > executes > > [Client side] > PrivateKey pKey =3D .... > Signature signature =3D Signature.getInstance("SHA1withRSA"); > signature.initSign(privateKey); > signature.update(data2Sign); --> data2Sign is the decoded data received > from the Server > byte[] dataSigned =3D signature.sign(); > > then, the Client sends back to the Server 'dataSigned' (encoded) and the > server adds it to the SignatureValue element (decoded). > > But the signature build this way is not valid :-( If I execute > XMLSignature.sign() directly, the signature I get is different. What I'm > doing wrong? > > As you can see, the server sends directly the C14N data, not the digested > one. I have also tried digesting it before with the same result. In fact,= I > am doing the same that XMLSignature.sign()'s method, so I can't see where > the problem is. > > Does anybody have an idea? > > Thanks a lot > > Isi > > > 2008/7/29 Lopez Cantero, Sergio > > As far as I know, yes, you have to digest them "by hand" > > > > I hope to have helped you. > > > > Sergio > > > > > > De: Legido Mart=EDnez, Isidoro [mailto:islegmar@gmail.com] > Enviado el: martes, 29 de julio de 2008 8:41 > > Para: security-dev@xml.apache.org > > Asunto: Re: Remote private key > > > > Thanks > > So, how can I get the digested value? Do I have to digest them "by hand"? > > Thanks > > Isi > > 2008/7/29 Lopez Cantero, Sergio > > Hi Isidoro, > > getCanonicalizedOctetStream returns the bytes you have to digest, not the > digested data, so that's the difference. > > Concerning the way to put back the signature, you can get the signature > element and search through the DOM for the SignatureValue Element to fill > its contents. > > I'm doing something like that ;) > > > > Sergio > > > > De: Legido Mart=EDnez, Isidoro [mailto:islegmar@gmail.com] > Enviado el: lunes, 28 de julio de 2008 21:45 > Para: security-dev@xml.apache.org > Asunto: Remote private key > > > > Hi everybody: > > Firs, I will try to explain my current situation (sorry in advanced for m= y > poor English :-( ). My signing system is splitted in two pieces: a > lightweith client that owns the private key and ONLY can sign (no digest) > and the server side that does everything else EXCEPT signing (digest, add > Manifest elements or aditional References). > My initial idea was: the server side builds the SignedInfo elements, get = its > digest and send it to the client. The client signs and send the result to > the server, which adds this to the SignedInfo. Is that possible withe the > current implementation? > I expected that > > SignedInfo si.generateDigestValues(); > String digest =3D Base64.encode(si.getCanonicalizedOctetStream()); > > 'digest' would contain the digest value in Base64, but what I get is > something different. How can I get the digest? After signing, is there an= y > way for adding it to SignInfo. > > Thanks a lot > > Isi > > > -- > ,-""""""-. > /\j__/\ ( \`--. > \`@_@'/ _) >--.`. > _{.:Y:_}_{{_,' ) ) > {_}`-^{_} ``` (_/ > > > -- > ,-""""""-. > /\j__/\ ( \`--. > \`@_@'/ _) >--.`. > _{.:Y:_}_{{_,' ) ) > {_}`-^{_} ``` (_/ --=20 - Jason