1
0
Fork 0

Add new test for PRAGMA cipher_status (new in 4.12.0)

This commit is contained in:
Miguel Jacq 2025-12-09 15:25:37 +11:00
parent a921cbf6b8
commit 2aafefafb2
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9

View file

@ -105,6 +105,18 @@ function cipherIntegrityOk(PDO $dbh): bool {
return ($row === false); // no rows == OK
}
/**
* cipher_status returns:
* - 1 (ok)
* https://www.zetetic.net/sqlcipher/sqlcipher-api/#cipher_status
*/
function cipherStatus(PDO $dbh): bool {
$stmt = $dbh->query("PRAGMA cipher_status;");
if (!$stmt) return false; // query failed -> not OK
$row = $stmt->fetch(PDO::FETCH_NUM);
return ($row[0] == "1");
}
// ---------------------------- Main actions ----------------------------
function createAndPopulate(string $path, string $passphrase, string $marker): void {
@ -128,6 +140,10 @@ function createAndPopulate(string $path, string $passphrase, string $marker): vo
$ok = cipherIntegrityOk($dbh);
check("cipher_integrity_check", $ok, $ok ? "no rows (OK)" : "reported errors");
// Status check should be OK (new in 4.12.0 - returns 1 if ok)
$ok = cipherStatus($dbh);
check("cipher_status", $ok, $ok ? "row result = 1 (OK)" : "reported errors");
// Capture page_size (for entropy sampling)
$pageSize = (int)(pragmaOne($dbh, "page_size") ?? 4096);
$dbh = null; // close