Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 25868 invoked from network); 2 Jun 2006 02:11:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Jun 2006 02:11:55 -0000 Received: (qmail 85503 invoked by uid 500); 2 Jun 2006 02:11:55 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 85290 invoked by uid 500); 2 Jun 2006 02:11:54 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 85279 invoked by uid 99); 2 Jun 2006 02:11:54 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jun 2006 19:11:54 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=RCVD_IN_SORBS_WEB,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of suresh.thalamati@gmail.com designates 64.233.184.226 as permitted sender) Received: from [64.233.184.226] (HELO wr-out-0506.google.com) (64.233.184.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jun 2006 19:11:53 -0700 Received: by wr-out-0506.google.com with SMTP id 71so426072wri for ; Thu, 01 Jun 2006 19:11:32 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=G74L8U+XishgGIZZxR7dwoCb0Ia1JELU7jWigXLqcb1ENtasavLs3XEPmZUDAt3xPizwR1xesw8eARilGm+ZDMeTY9QOOKTq1IP8gRFEtBOP5xnUIdowobQ5naEAGO4TXeo9VhRyb/XuyvlYRDjm3K2ZSFz3zyRjhVDHyH4qFbY= Received: by 10.54.160.6 with SMTP id i6mr1336742wre; Thu, 01 Jun 2006 19:11:32 -0700 (PDT) Received: from ?9.30.38.151? ( [129.42.184.35]) by mx.gmail.com with ESMTP id 34sm2308201wra.2006.06.01.19.11.31; Thu, 01 Jun 2006 19:11:32 -0700 (PDT) Message-ID: <447F9E51.2000709@gmail.com> Date: Thu, 01 Jun 2006 19:11:29 -0700 From: Suresh Thalamati User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: derby-dev@db.apache.org Subject: Re: Problem using encrypted databases with jar subprotocol References: <1c5747850605301546p74dd497fpf118e077403364e3@mail.gmail.com> In-Reply-To: <1c5747850605301546p74dd497fpf118e077403364e3@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Mathias, Good Catch, this might be broken in 10.1 branch too. Please file a Jira entry for the problem and attach your patch; that way we won't lose it in the e-mails. I think the verifyKey file can be read by wrapping the file InputStream with a DataInputStream instead of reading it as RandomAccessFile in the JCECipherFactory itself. If that works then there is no need to add InputStreamRandomAccessFile.java class. Thanks -suresh Mathias Herberts wrote: > The current trunk (410361) does not allow to have encrypted databases > using encryptionKey with the jar subprotocol (and probably also the > http/https and classpath subprotocols also). > > The problem lies in the method run from JCECipherFactory. The call to > getRandomAccessFile returns null when the verifyKeyFile is an instance > of InputStreamFile and the key verification therefore fails. > > Included in this email is a new class InputStreamRandomAccessFile in > package org.apache.derby.impl.io. This class provides simple > implementations of readInt and readFully so the key verification > process succeeds. > > Also included in this email is a patch to > org/apache/derby/impl/io/InputStreamFile.java so the > getRandomAccessFile creates an instance of InputStreamRandomAccessFile > instead of returning null. > > I have tested my patch with an encrypted db accessed via the jar > subprotocol, it has not been tested with any other subprotocol. > > Regards, > > Mathias. > > > ------------------------------------------------------------------------ > > package org.apache.derby.impl.io; > > import java.io.DataInput; > import java.io.DataOutput; > import java.io.EOFException; > import java.io.FileNotFoundException; > import java.io.IOException; > import java.io.InputStream; > > import org.apache.derby.io.StorageRandomAccessFile; > > public class InputStreamRandomAccessFile implements DataInput, DataOutput, > StorageRandomAccessFile { > > private InputStream is = null; > > public InputStreamRandomAccessFile (InputStreamFile isf) throws FileNotFoundException { > this.is = isf.getInputStream(); > } > ...