Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal signal 11 after set rekey for unencrypted database #42

Closed
denwist opened this issue Jun 3, 2021 · 1 comment
Closed

Fatal signal 11 after set rekey for unencrypted database #42

denwist opened this issue Jun 3, 2021 · 1 comment

Comments

@denwist
Copy link

denwist commented Jun 3, 2021

Hello!
When using Sqleet in Sqlite, I encountered the problem of encrypting the database through PRAGMA rekey=NewPassword. Occurs when I import an unencrypted database and try to set a new password for it (the old password is empty). Drops on next error:

A/libc: Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7c69ef8fb0 in tid 24406 (AsyncTask #2), pid 24259

/**
 * Changing the database password 
 * */
public void changeDatabaseEncryptionPassword(String password) throws Exception {
    try {
        // Encrypts open password
        String encryptionPassword = encryptPassword(password);
        SQLiteDatabase db = getWritableDatabase(); // 17Mb of unencrypted database 
        db.execSQL("PRAGMA rekey = " + DatabaseUtils.sqlEscapeString(encryptionPassword)); // the problem is here 
    } catch (Exception e) {
        throw new Exception(e);
    }
}

@Override
public void onConfigure(SQLiteDatabase db) {
    String encryptionPassword = getEncryptionPassword(currentContext);
    db.execSQL("PRAGMA key = " + DatabaseUtils.sqlEscapeString(encryptionPassword));
    super.onConfigure(db);
}

In general, I am satisfied with the library. The database can be either encrypted or decrypted by specifying an empty password. And for databases with low weight, everything works both in the direction of encryption and decryption.
Encrypt db

Questions arise:

  1. What could this problem be related to and how to fix it?
  2. Are there any restrictions on the size of the encrypted database? In some cases, the process of encrypting and decrypting the database goes without problems. And when I import an unencrypted database backup and try to encrypt it, it crashes on an error "Fatal signal 11..."
  3. Is there enough RAM for the Android device to perform this operation, especially for weighty databases?
  4. Is there a way to encrypt / decrypt large databases (several gigabytes) at the file structure level by reading them piece by piece?
@denwist
Copy link
Author

denwist commented Jun 5, 2021

The solution was found. This fixed the problem.
Solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant