From 349ef328c7278d359db5acbfc3709f138a6b88ae Mon Sep 17 00:00:00 2001 From: Marcel Ball Date: Wed, 6 Mar 2019 21:01:08 -0400 Subject: [PATCH] Updated documentation to cover new configuration options --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 413d8786a..d19568439 100644 --- a/README.md +++ b/README.md @@ -7303,6 +7303,30 @@ try clearDBQueue.inDatabase { db in // Now the copy is done, and the clear-text database can be deleted. ``` +**Advanced configuration options for SQLCipher** +There are two advanced configuration options that you can set for configuring SQLCipher that control aspects of the encryption and key generation process. + +```swift +var configuartion = Configuration() +configuration.passphrase = "secret" +configuration.cipherPageSize = .pageSize4K +configuration.KDFIterations = 128000 +let dbQueue = try DatabaseQueue(path: "...", configuration: configuration) +``` +***cipherPageSize*** +The `cipherPageSize` is used to adjust the page size for the encrypted database (this corresponds to the SQLCipher `PRAGMA cipher_page_size` configuration option). Increasing the page size can noticeably improve performance for certain queries that access large numbers of pages. + +WARNING: The same `cipherPageSize` must be supplied every time that the database file is open; attempting to access the database without setting the proper `cipherPageSize` will result in the `SQLite error 26: file is encrypted or is not a database` error being thrown. + +The default `cipherPageSize` in the current version of SQLCipher used in GRDB.swift is `.pageSize1K`. + +***KDFIterations*** +The `KDFIterations` value is used to adjust the number of iterations that the PBKDF2 key derivation is run to derive the key from the `passphrase` supplied (this corresponds to the SQLCipher `PRAGMA kdf_iter` configuration option). + +WARNING: The same `KDFIterations` must be supplied every time that the database file is open; attempting to access the database without setting the proper `KDFIterations` will result in the `SQLite error 26: file is encrypted or is not a database` error being thrown. + +The default `KDFIterations` in the current version of SQLCipher used in GRDB.swift is `64000`. It is not recommend to reduce the number of iterations used from the default. + ## Backup