Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:53:57+00:00 2026-06-02T08:53:57+00:00

I used sqlcipher_export() , exactly as specified here , to encrypt an existing Sqlite

  • 0

I used sqlcipher_export(), exactly as specified here, to encrypt an existing Sqlite database. It all went fine – no errors, the resulting database is created and has a reasonable size. However, I am not able to open the encrypted database, even though I specify the correct key using PRAGMA key. Unencrypted databases open without problems.

Moreover, the encrypted database looks strange; the header seems to be encrypted, but not the data. See https://i.stack.imgur.com/HaBpS.png, it’s an image showing binary comparison between encrypted (left) and unencrypted (right) databases.

In the debugger I can see that, during the encryption, the program goes through sqlcipher_page_cipher(), but most of the time (every time except for 2 invocations) the following clause is executed, and the function returns early:

  /* just copy raw data from in to out when key size is 0
   * i.e. during a rekey of a plaintext database */ 
  if(c_ctx->key_sz == 0) {
    memcpy(out, in, size);
    return SQLITE_OK;
  }

SQL issued during encryption:

ATTACH DATABASE 'encrypted.db' AS encrypted KEY '12345'; 
SELECT sqlcipher_export('encrypted'); 
DETACH DATABASE encrypted; 

SQL issued during opening:

// open database
PRAGMA key = '12345'; 
// try to read database - "file is encrypted or not a database"

CODEC_TRACE logs generated during encryption and decryption are here.

(In case it is important how I compiled Sqlcipher: I created an Sqlcipher amalgamation on a Linux machine, copied the resulting C file to a Windows machine, compiled it in Visual C++ Express, and linked to a precompiled OpenSSL DLL.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:53:59+00:00Added an answer on June 2, 2026 at 8:53 am

    Root cause: Calls to OpenSSL’s HMAC_Init_ex() in sqlcipher_page_hmac() corrupted memory that belonged to c_ctx->key_sz, setting it to zero. c_ctx->key_sz was adjacent to a parameter passed to HMAC_Init_ex(). (Details can be found in one of the comments to the original post.) This caused sqlcipher_page_cipher() to write plaintext pages to the encrypted file, instead of encrypted pages. Which didn’t make sense and made the resulting database unusable.

    Upgrading OpenSSL from 0.9.8k to 1.0.0i fixed the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used a tool a few months ago that scanned a specified website and
I used the following code to display the event details fetched from the database.
I used this code which found on forum without errors in 4.0.2a and now
I used CouchDB 1.1.1 with self-signed certs fine for some time. Then, I purchased
I used to work with eclipse for nearly all the languages I need. I'm
It used to be that you could load Typus routes exactly where you needed
I used Rijndael algorithm to encrypt/decrypt my data. But it is not FIPS compatible.
I used one of the ubuntu package manager commands to install all of the
I used twitter Oauth and it worked perfectly fine.I was able to login using
I used log4net in a sample application based on tutorial here . It works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.