10000 Merge pull request #24 from developernotes/prerelease · PHPDOTSQL/sqlcipher@8e4d13b · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e4d13b

Browse files
committed
Merge pull request sqlcipher#24 from developernotes/prerelease
PRAGMA cipher_version
2 parents f018888 + 525243c commit 8e4d13b

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

src/crypto.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
#include "btreeInt.h"
3939
#include "crypto.h"
4040

41+
/* Generate code to return a string value */
42+
void codec_vdbe_return_static_string(Parse *pParse, const char *zLabel, const char *value){
43+
Vdbe *v = sqlite3GetVdbe(pParse);
44+
int mem = ++pParse->nMem;
45+
sqlite3VdbeAddOp4(v, OP_String, 0, mem, 0, (char*)value, P4_STATIC);
46+
sqlite3VdbeSetNumCols(v, 1);
47+
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
48+
sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
49+
}
50+
4151
int codec_set_kdf_iter(sqlite3* db, int nDb, int kdf_iter, int for_ctx) {
4252
struct Db *pDb = &db->aDb[nDb];
4353
CODEC_TRACE(("codec_set_kdf_iter: entered db=%p nDb=%d kdf_iter=%d for_ctx=%d\n", db, nDb, kdf_iter, for_ctx));

src/crypto.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737

3838
#define FILE_HEADER_SZ 16
3939

40+
#ifndef CIPHER_VERSION
41+
#define CIPHER_VERSION "2.0.5"
42+
#endif
43+
4044
#ifndef CIPHER
4145
#define CIPHER "aes-256-cbc"
4246
#endif

src/pragma.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,10 @@ void sqlite3Pragma(
15351535
}
15361536
}else
15371537
/** BEGIN CRYPTO **/
1538+
if( sqlite3StrICmp(zLeft, "cipher_version")==0 && !zRight ){
1539+
extern void codec_vdbe_return_static_string(Parse *pParse, const char *zLabel, const char *value);
1540+
codec_vdbe_return_static_string(pParse, "cipher_version", CIPHER_VERSION);
1541+
}else
15381542
if( sqlite3StrICmp(zLeft, "cipher")==0 && zRight ){
15391543
extern int codec_set_cipher_name(sqlite3*, int, const char *, int);
15401544
codec_set_cipher_name(db, iDb, zRight, 2); // change cipher for both

test/crypto.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,4 +1205,16 @@ do_test change-default-use-hmac-attach {
12051205
db close
12061206
file delete -force test.db
12071207

1208+
# verify the pragma cipher_version
1209+
# returns the currently configured
1210+
# sqlcipher version
1211+
do_test verify-pragma-cipher-version {
1212+
sqlite_orig db test.db
1213+
execsql {
1214+
PRAGMA cipher_version;
1215+
}
1216+
} {2.0.5}
1217+
db close
1218+
file delete -force test.db
1219+
12081220
finish_test

0 commit comments

Comments
 (0)
0