Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 26A679006 for ; Wed, 4 Jul 2012 19:11:51 +0000 (UTC) Received: (qmail 93509 invoked by uid 500); 4 Jul 2012 19:11:49 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 93478 invoked by uid 500); 4 Jul 2012 19:11:49 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 93470 invoked by uid 99); 4 Jul 2012 19:11:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jul 2012 19:11:49 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of albin.stigo@gmail.com designates 209.85.161.180 as permitted sender) Received: from [209.85.161.180] (HELO mail-gg0-f180.google.com) (209.85.161.180) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jul 2012 19:11:45 +0000 Received: by ggnf1 with SMTP id f1so7318540ggn.11 for ; Wed, 04 Jul 2012 12:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :content-type:content-transfer-encoding; bh=Et8Plwc1nlWWKcLjnjFaDHmmuxy7AWZ2bIlXw970Ysw=; b=BKbuClyDr1I4RwQNGVcT7/A2aviaybGORB7gDhLzri/r89uJikizDhpo/j31hQIwaR RHAV88+/KNexYPU//qExYxb5TE4iFyq/Ml+gc++bR5Js8DE/ZPo3BkVNGenzeWXBAgbO 8Ws7ZG5xWYuC2dgEkh9O9YHtJ6x3iqliCbhBKea9bpasqTAFjwZtN9LRH+Ubuimy3y6C mQeD/9UBZtsVzN+jFQUEUzZcejyDBlO9Z56IRrgJCdx2mM7G0Il3i5qgeBLR2/ffRwyF a35PN0Z8iGfnqa7pu3T0U7TE02ImQQR5F7I6va5w1c+0HUoUF1YoIysXOFgB348UboUW GxBA== Received: by 10.236.108.196 with SMTP id q44mr17340508yhg.68.1341429079427; Wed, 04 Jul 2012 12:11:19 -0700 (PDT) References: <79061073-7E58-4CBC-9DC1-8A98C6811796@sri.com> <0848BFC4-1340-4FF9-A04D-EE6D205A90A0@couchbase.com> From: =?ISO-8859-1?Q?Albin_Stig=F6?= In-Reply-To: Mime-Version: 1.0 (1.0) Date: Wed, 4 Jul 2012 21:11:07 +0200 Message-ID: <-3046869085809654149@unknownmsgid> Subject: Re: Cryptograhically signed docs... To: "user@couchdb.apache.org" Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Yes, I agree with you, it can probably be done in JavaScript in a normal validation function.. The only problem is how to maintain a list of keys.. For a test version you can just have them stored along with the code in the validation doc using ie couchapp's !json macro.. But I think it would be really neat with a _keys db.. Another way of doing it, that I think could be implemented quite efficiently, is to have a separate worker process listening to changes stream and have a validation doc that marks all new docs with "verified: false. The worker process could then change this to true after it checked the signature. Sorry if I'm a bit brief but I'm typing this on an iPhone. Sendt fra min iPhone Den 04/07/2012 kl. 21.00 skrev Bernhard Gschwantner = : > I've been following this thread and like the idea. I may be na=EFve or > completely wrong, but all this sounds quite easy to solve in a design > document and with pure javascript, although probably not very performant. > Just take jens' structure proposal and modify openpgp.js a little bit, pu= t > the stuff into a validate_doc_update function, add the allowed public key= s > to a design doc (easy with a couchapp), et voil=E0: you get a completely > replicable and transparent signature checker ;-) > > If I find the time tomorrow, I'll take a shot on a proof of concept. The > building blocks are there already... > > Cheers, > Bernhard > > Am Mittwoch, 4. Juli 2012 schrieb Albin Stig=F6 : > >> Sounds interesting.. I think I will take this to the developers mailing >> list and see if I will be able to generate some interest in the idea.. >> >> Albin >> >> onsdag den 4. juli 2012 skrev Jan Bot : >> >>> Hi, >>> >>> This would really be a great feature: I'm using CouchDB to manage grid >>> compute jobs and having the ability to sign a document using a private >> key >>> and check it server side with the public key could really make couchdb >> part >>> of the grid infrastructure. >>> >>> Cheers, >>> >>> Jan >>> >>> On Wed, Jul 4, 2012 at 11:17 AM, Albin Stig=F6 >> > >>> wrote: >>> >>>> Hi, >>>> >>>> Jens, thanks for the link. Did you ever finish the app where you were >>>> using these techniques? >>>> >>>> First I naively thought that it would be enough to hash the body of >>>> what you are going to PUT/POST and then sign that hash and include the >>>> signature as a custom http header. I guess this would work for >>>> verifying the data on the first post but you would not be able to >>>> verify the signature later if couchdb does any parsing of the >>>> transported data. >>>> >>>> What you are suggesting using a canonical representation of of JSON >>>> seems like a much better idea it also apparently what oauth uses. >>>> >>>> I guess this would require some hacking on couchdb. It would be really >>>> neat to have a _keys database much like the _users and for for >>>> documents to have a _signature field. What do you thin..? >>>> >>>> --Albin >>>> >>>> >>>> >>>> On Wed, Jul 4, 2012 at 3:07 AM, Jens Alfke >> > >>> wrote: >>>>> >>>>> On Jul 3, 2012, at 10:01 AM, Jim Klo wrote: >>>>> >>>>>> Yes, and as a matter of fact, i just got digital signature >> validation >>>> using OpenPGP within a map function working a few minutes ago! >>>>>> Here's a link to the relevant code: >>>> >>> >> https://github.com/jimklo/TheCollector/blob/master/dataservices/thecolle= ctor-resources/views/lib/sig_utils.js >>>>> >>>>> As far as I can tell, this code uses a data schema where the signed >>>> contents are wrapped in some kind of OpenPGP encoding: >>>>> >>>>>> var msg_list =3D >>>> openpgp.read_message(doc.digital_signature.signature); >>>>>> for (var i=3D0; i>>>>> isValid |=3D msg_list[i].verifySignature(); >>>>>> } >>>>> >>>>> It looks like msg_list is the actual document payload, which has to >> be >>>> decoded using openpgp.read_message. >>>>> >>>>> This is IMHO not a very good solution because it hides the document >>>> contents away =97 for example, all the map functions and any app logic >> that >>>> uses documents will have to know to call read_message, which will also >>> make >>>> them slower. >>>>> >>>>> The schema I implemented (see my previous message) doesn't alter the >>>> basic document format. The signature is in a nested object but applies >> to >>>> the entire document contents (minus the signature itself of course). >>>> There's no need to change any code that reads documents; the only time >>> you >>>> have to know about the signature scheme is while verifying the >> signature. >>>> It's even possible to have multiple signatures on a document. >>>>> >>>>> =97Jens >>>> >>> >> > > > -- > > Bernhard Gschwantner > Unser Wein G&U OG > Kirchengasse 13/7, 1070 Wien > > mobil: +43 (6991) 971 32 96 > tel: +43 (1) 971 32 95 > e-mail: bernhard@unserwein.at > twitter: @bernharduw > web: www.unserwein.at