Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Regarding rey key

Received: by 10.236.165.98 with SMTP id d62mr8307813yhl.40.1343745507020;
        Tue, 31 Jul 2012 07:38:27 -0700 (PDT)
X-BeenThere: sqlcipher@googlegroups.com
Received: by 10.236.113.178 with SMTP id a38ls496777yhh.9.gmail; Tue, 31 Jul
 2012 07:38:25 -0700 (PDT)
Received: by 10.236.79.2 with SMTP id h2mr3156265yhe.22.1343745505214;
        Tue, 31 Jul 2012 07:38:25 -0700 (PDT)
Received: by 10.236.79.2 with SMTP id h2mr3156263yhe.22.1343745505196;
        Tue, 31 Jul 2012 07:38:25 -0700 (PDT)
Return-Path: <npar...@zetetic.net>
Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180])
        by gmr-mx.google.com with ESMTPS id n2si21716anp.3.2012.07.31.07.38.25
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 31 Jul 2012 07:38:25 -0700 (PDT)
Received-SPF: pass (google.com: domain of npar...@zetetic.net designates 209.85.161.180 as permitted sender) client-ip=209.85.161.180;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of npar...@zetetic.net designates 209.85.161.180 as permitted sender) smtp.mail=npar...@zetetic.net
Received: by ggnf1 with SMTP id f1so5376248ggn.25
        for <sqlcipher@googlegroups.com>; Tue, 31 Jul 2012 07:38:24 -0700 (PDT)
        d=google.com; s=20120113;
        h=message-id:date:from:user-agent:mime-version:to:cc:subject
         :references:in-reply-to:x-enigmail-version:content-type
         :x-gm-message-state;
        bh=DcaJ9cE5MTcdMRo+Z3f1UmtVW/gtJUtSUaABXq08b6I=;
        b=NLZjvaezNq6W/Etj3yeK9DWSy+9jCC+Meq2LZ7v4OXTxu9WNiaTGUnLH8DLtrZWyul
         nZpC9L6iQR/t4b77yNJpG6LXFzoepfnQJVc7sgnd1PFxsY1NJzy+qunpV//R5Ls5kCJ3
         5z1AZEoEiXK0+Q0EkO8VgtyP4mzU3+832k8KyqkAcdhzVndL7wEhY8FffHhDEVh9QILA
         tmS6m2Vt/pcCL5DxTfQmbtLHsttu97TlRPKB53SZDiI0nUZZSpqVlOhE+f37WbdiIy8I
         xOEUp5uScJbFFP5TBxt3Z8uUaHF66P2upiNtGTAxyJRxMW05VNFyvnODucX7CHCJUbXM
         GF/A==
Received: by 10.50.104.168 with SMTP id gf8mr2082138igb.62.1343745504301;
        Tue, 31 Jul 2012 07:38:24 -0700 (PDT)
Return-Path: <npar...@zetetic.net>
Received: from work.local (173-18-189-145.client.mchsi.com. [173.18.189.145])
        by mx.google.com with ESMTPS id wp10sm420830igb.6.2012.07.31.07.38.23
        (version=SSLv3 cipher=OTHER);
        Tue, 31 Jul 2012 07:38:23 -0700 (PDT)
Message-ID: <5017EDDE.20...@zetetic.net>
Date: Tue, 31 Jul 2012 09:38:22 -0500
From: Nick Parker <npar...@zetetic.net>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0
MIME-Version: 1.0
To: ashiq sayyad <ashiqsay...@gmail.com>
CC: "sqlcipher@googlegroups.com" <sqlcipher@googlegroups.com>
Subject: Re: Regarding rey key
References: <148e2ed9-dd5c-4efd-93b6-4b3b647a5f4a@googlegroups.com> <50168760.6020...@zetetic.net> <CACE+enNbo8tp524jd=SgaAiaR8m6fm0i9MYA_znX_gkio1V...@mail.gmail.com> <5016B4FB.6060...@zetetic.net> <CACE+enNK8__sYhvMCyQb0ZWW7b5NEk96i3vx2X9H8iwaCs1...@mail.gmail.com>
In-Reply-To: <CACE+enNK8__sYhvMCyQb0ZWW7b5NEk96i3vx2X9H8iwaCs1...@mail.gmail.com>
X-Enigmail-Version: 1.4.3
Content-Type: multipart/alternative;
 boundary="------------090806090603000108060505"
X-Gm-Message-State: ALoCoQlJKkpjiw55KqnR4rmfkMvrUMdonVQidFdHSSbToDPoaQ8TTkAtz2gFVoAXTBEsMU8XIL6k

This is a multi-part message in MIME format.
--------------090806090603000108060505
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi Ashiq,

You need to verify that your 'db' instance is referencing an open
connection to the unencrypted database before you perform this process. 
An example of doing this is provided in our test suite here [1] that you
can run.

1. 
https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/src/main/java/net/zetetic/tests/ImportUnencryptedDatabaseTest.java

On 7/31/12 4:45 AM, ashiq sayyad wrote:
> I exported the plain text database to encrypted database using
> following commands--
>
> String str = "ATTACH DATABASE
> '/data/data/com.salciphersampleapp/databases/encrypted' AS encrypted
> KEY 'testkey'";
> db.rawExecSQL(str);
> str ="SELECT sqlcipher_export('encrypted')"; 
> db.rawExecSQL(str);
> str =  "DETACH DATABASE encrypted"; 
> db.rawExecSQL(str);
>
> It created database with name encrypted But it does not have any data
> exported from old plain text database...
>
> On 30 July 2012 21:53, Nick Parker <npar...@zetetic.net
> <mailto:npar...@zetetic.net>> wrote:
>
>     Hi Ashiq,
>
>     No, you can of course delete the old unencrypted database once the
>     export has completed to minimize disk space usage.
>
>
>     On 7/30/12 10:31 AM, ashiq sayyad wrote:
>>     Thanks Nick.
>>     I have created database initially using sqlcipher APIS only using
>>     empty string.Now I want  to rekey it with some password.
>>
>>
>>     I tried exporting option.It works but it will create new db which
>>     will copy data from plain text db into the new encrypted db.
>>     Is there any way to encrypt the same db without creating new
>>     one?????????
>>
>>     On 30 July 2012 18:38, Nick Parker <npar...@zetetic.net
>>     <mailto:npar...@zetetic.net>> wrote:
>>
>>         Hi,
>>
>>         PRAMA rekey can not be used to encrypt a standard SQLite
>>         database, which is what you have when you issued your PRAGMA
>>         key with a blank password.  You would need to use
>>         sqlcipher_export() [1] to perform that type of conversion.
>>
>>         1.  http://sqlcipher.net/sqlcipher-api/#sqlcipher_export
>>
>>
>>         On 7/29/12 6:42 AM, A sayyad wrote:
>>>         I created one database with empty string("").It works fine &
>>>         database created is unencrypted.
>>>
>>>         Then I rekeyed the database with some password new.
>>>
>>>         String password ="";
>>>         String str = "PRAGMA key = "+"'"+password+"'";
>>>         db.rawExecSQL(str);
>>>         str = "PRAGMA rekey = "+"'"+"new"+"'";
>>>         db.rawExecSQL(str);
>>>
>>>         Now when I again open the database with new password, I am
>>>         getting exception as below
>>>
>>>         net.sqlcipher.database.SQLiteException: file is encrypted or
>>>         is not a database
>>>         .
>>>
>>>         However if I open the database with empty string.It works fine--
>>>
>>>         Note - This is happening only when I create  the  database
>>>         with empty string then try to rekey it with some password.
>>>
>>>         If I create the database initially with some password & then
>>>         try to rekey it with some other password, it works perfectly
>>>         fine..
>>>
>>
>>         -- 
>>         Nick Parker
>>
>>
>
>     -- 
>     Nick Parker
>
>

-- 
Nick Parker


--------------090806090603000108060505
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Ashiq,<br>
    <br>
    You need to verify that your 'db' instance is referencing an open
    connection to the unencrypted database before you perform this
    process.&nbsp; An example of doing this is provided in our test suite
    here [1] that you can run.<br>
    <br>
    1.&nbsp;
<a class="moz-txt-link-freetext" href="https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/src/main/java/net/zetetic/tests/ImportUnencryptedDatabaseTest.java">https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/src/main/java/net/zetetic/tests/ImportUnencryptedDatabaseTest.java</a><br>
    <br>
    <div class="moz-cite-prefix">On 7/31/12 4:45 AM, ashiq sayyad wrote:<br>
    </div>
    <blockquote
cite="mid:CACE+enNK8__sYhvMCyQb0ZWW7b5NEk96i3vx2X9H8iwaCs1...@mail.gmail.com"
      type="cite">I exported the plain text database to encrypted
      database using following commands--
      <div><br>
      </div>
      <div>
        <div>String str = "ATTACH DATABASE
          '/data/data/com.salciphersampleapp/databases/encrypted' AS
          encrypted KEY 'testkey'";</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>db.rawExecSQL(str);</div>
        <div>
          <div>str ="SELECT sqlcipher_export('encrypted')";&nbsp;</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>db.rawExecSQL(str);</div>
        </div>
        <div>
          <div>str = &nbsp;"DETACH DATABASE encrypted";&nbsp;</div>
          <div><span class="Apple-tab-span" style="white-space:pre"> </span>db.rawExecSQL(str);</div>
        </div>
        <div><br>
        </div>
        <div>It created database with name encrypted But it does not
          have any data exported from old plain text database...</div>
        <br>
        <div class="gmail_quote">On 30 July 2012 21:53, Nick Parker <span
            dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:npar...@zetetic.net" target="_blank">npar...@zetetic.net</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> Hi Ashiq,<br>
              <br>
              No, you can of course delete the old unencrypted database
              once the export has completed to minimize disk space
              usage.
              <div>
                <div class="h5"><br>
                  <br>
                  <div>On 7/30/12 10:31 AM, ashiq sayyad wrote:<br>
                  </div>
                  <blockquote type="cite">Thanks Nick.
                    <div>I have created database initially using
                      sqlcipher APIS only using empty string.Now I want
                      &nbsp;to rekey it with some password.</div>
                    <div><br>
                    </div>
                    <div><br>
                    </div>
                    <div>I tried exporting option.It works but it will
                      create new db which will copy data from plain text
                      db into the new encrypted db.</div>
                    <div>Is there any way to encrypt the same db without
                      creating new one?????????<br>
                      <br>
                      <div class="gmail_quote">On 30 July 2012 18:38,
                        Nick Parker <span dir="ltr">&lt;<a
                            moz-do-not-send="true"
                            href="mailto:npar...@zetetic.net"
                            target="_blank">npar...@zetetic.net</a>&gt;</span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000"> Hi,<br>
                            <br>
                            PRAMA rekey can not be used to encrypt a
                            standard SQLite database, which is what you
                            have when you issued your PRAGMA key with a
                            blank password.&nbsp; You would need to use
                            sqlcipher_export() [1] to perform that type
                            of conversion.<br>
                            <br>
                            1.&nbsp; <a moz-do-not-send="true"
                              href="http://sqlcipher.net/sqlcipher-api/#sqlcipher_export"
                              target="_blank">http://sqlcipher.net/sqlcipher-api/#sqlcipher_export</a>
                            <div>
                              <div><br>
                                <br>
                                <div>On 7/29/12 6:42 AM, A sayyad wrote:<br>
                                </div>
                                <blockquote type="cite">I created one
                                  database with empty string("").It
                                  works fine &amp; database created is
                                  unencrypted.
                                  <div><br>
                                  </div>
                                  <div>Then I rekeyed the database with
                                    some password new.</div>
                                  <div><br>
                                  </div>
                                  <div>
                                    <div>String password ="";</div>
                                    <div><span
                                        style="white-space:pre-wrap"> </span>String


                                      str = "PRAGMA key =
                                      "+"'"+password+"'";</div>
                                    <div><span
                                        style="white-space:pre-wrap"> </span>db.rawExecSQL(str);</div>
                                    <div><span
                                        style="white-space:pre-wrap"> </span>str


                                      = "PRAGMA rekey = "+"'"+"new"+"'";</div>
                                    <div><span
                                        style="white-space:pre-wrap"> </span>db.rawExecSQL(str);</div>
                                  </div>
                                  <div><br>
                                  </div>
                                  <div>Now when I again open the
                                    database with new password, I am
                                    getting exception as below</div>
                                  <div><br>
                                  </div>
                                  <div>net.sqlcipher.database.SQLiteException:
                                    file is encrypted or is not a
                                    database<br>
                                  </div>
                                  <div>.</div>
                                  <div><br>
                                  </div>
                                  <div>However if I open the database
                                    with empty string.It works fine--</div>
                                  <div><br>
                                  </div>
                                  <div>Note - This is happening only
                                    when I create &nbsp;the &nbsp;database with
                                    empty string then try to rekey it
                                    with some password.</div>
                                  <div><br>
                                  </div>
                                  <div>If I create the database
                                    initially with some password &amp;
                                    then try to rekey it with some other
                                    password, it works perfectly fine..</div>
                                  <div><br>
                                  </div>
                                </blockquote>
                                <br>
                              </div>
                            </div>
                            <span><font color="#888888">
                                <pre cols="72">-- 
Nick Parker</pre>
                              </font></span></div>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                  </blockquote>
                  <br>
                </div>
              </div>
              <span class="HOEnZb"><font color="#888888">
                  <pre cols="72">-- 
Nick Parker</pre>
                </font></span></div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Nick Parker</pre>
  </body>
</html>

--------------090806090603000108060505--