Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is the EditorConfig (http://editorconfig.org/) coding style file for
# SQLite3 Multiple Ciphers.

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[makefile.*]
indent_style = tab
indent_size = 8
74 changes: 73 additions & 1 deletion libsql-ffi/bundled/SQLite3MultipleCiphers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,70 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.9.0] - 2024-10-22

### Changed

- Based on SQLite version 3.47.0
- Changed signature of cipher scheme method `GenerateKey` (affects only developers of dynamic cipher schemes)

### Fixed

- Using differing KDF and HMAC algorithms resulted in databases incompatible with the original SQLCipher library. Setting the parameter `hmac_algorithm_compat` to 0 restores the (incompatible) behaviour.

## [1.8.7] - 2024-08-14

### Changed

- Based on SQLite version 3.46.1

## [1.8.6] - 2024-06-14

### Changed

- Removed extern keyword in function declarations
- Cleaned up white space
- Added SQLITE_PRIVATE for several internal functions
- The cipher configuration parameter `legacy_page_size` now accepts only valid page sizes
- The cipher configuration parameter `plaintext_header_size` now accepts only values that are multiples of 16

### Fixed

- Fixed issue [#156](../../issues/156)) - corrupted database if MMAP_SIZE > 0 was used
- Fixed issue [#158](../../issues/158)) - add check to verify compatibility of source and target database in backup operation
- Fixed issue [#160](../../issues/160)) - fix accessing memory out of array bounds
- Fixed issue [#162](../../issues/162)) - fix loading/storing misaligned data
- Fixed issue [#164](../../issues/164)) - fix return of error messages from rekey
- Fixed issue [#165](../../issues/165)) - fix rekey function by enforcing page size and number of reserved bytes per page
- Fixed issue [#166](../../issues/166)) - missing attribute SQLITE_PRIVATE for several internal functions
- Fixed issue [#167](../../issues/167)) - improve VFS error reporting
- Fixed issue [#168](../../issues/168)) - add check for encryption support

## [1.8.5] - 2024-05-24

### Changed

- Based on SQLite version 3.46.0

## [1.8.4] - 2024-03-14

### Changed

- Based on SQLite version 3.45.2
- Disable user authentication extension by default

## [1.8.3] - 2024-01-31

### Changed

- Based on SQLite version 3.45.1

## [1.8.2] - 2024-01-16

### Changed

- Based on SQLite version 3.45.0

## [1.8.1] - 2023-12-02

### Changed
Expand Down Expand Up @@ -469,7 +533,15 @@ The following ciphers are supported:
- AES 256 Bit CBC - SHA1/SHA256/SHA512 HMAC ([SQLCipher](https://www.zetetic.net/sqlcipher/), database versions 1, 2, 3, and 4)
- RC4 - No HMAC ([System.Data.SQLite](http://system.data.sqlite.org))

[Unreleased]: ../../compare/v1.8.0...HEAD
[Unreleased]: ../../compare/v1.9.0...HEAD
[1.9.0]: ../../compare/v1.8.7...v1.9.0
[1.8.7]: ../../compare/v1.8.6...v1.8.7
[1.8.6]: ../../compare/v1.8.5...v1.8.6
[1.8.5]: ../../compare/v1.8.4...v1.8.5
[1.8.4]: ../../compare/v1.8.3...v1.8.4
[1.8.3]: ../../compare/v1.8.2...v1.8.3
[1.8.2]: ../../compare/v1.8.1...v1.8.2
[1.8.1]: ../../compare/v1.8.0...v1.8.1
[1.8.0]: ../../compare/v1.7.4...v1.8.0
[1.7.4]: ../../compare/v1.7.3...v1.7.4
[1.7.3]: ../../compare/v1.7.2...v1.7.3
Expand Down
9 changes: 1 addition & 8 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ OPTION(SQLITE_ENABLE_JSON1 "Enable extension 'json1'" ON)
OPTION(SQLITE_ENABLE_RTREE "Enable extension 'rtree'" ON)
OPTION(SQLITE_ENABLE_UUID "Enable extension 'uuid'" ON)
OPTION(SQLITE_USE_URI "Enable the URI filename process logic" ON)
OPTION(SQLITE_USER_AUTHENTICATION "Enable extension 'user authentication'" ON)
OPTION(SQLITE_USER_AUTHENTICATION "Enable extension 'user authentication'" OFF)
OPTION(SQLITE_ENABLE_PREUPDATE_HOOK "Enable preupdate hooks" OFF)
OPTION(SQLITE_ENABLE_SESSION "Enable session extension" OFF)
OPTION(SQLITE_SHELL_IS_UTF8 "Shell command line arguments in UTF-8 encoding" ON)
Expand Down Expand Up @@ -64,7 +64,6 @@ OPTION(SQLITE3MC_USE_SQLCIPHER_LEGACY "Use sqlcipher legacy mode as default" OFF

# Additional memory security (filling freed memory allocations with zeros or random data)
OPTION(SQLITE3MC_SECURE_MEMORY "Enable pragma to secure freed memory" OFF)
OPTION(SQLITE3MC_USE_RANDOM_FILL_MEMORY "Fill freed memory with random data" OFF)

# Omit AES hardware support
OPTION(SQLITE3MC_OMIT_AES_HARDWARE_SUPPORT "Omit AES hardware support" OFF)
Expand Down Expand Up @@ -182,12 +181,6 @@ if(SQLITE3MC_SECURE_MEMORY)
SQLITE3MC_SECURE_MEMORY=1
)
endif()
if(SQLITE3MC_USE_RANDOM_FILL_MEMORY)
set(SQLITE3MC_BASE_DEFINITIONS
${SQLITE3MC_BASE_DEFINITIONS}
SQLITE3MC_USE_RANDOM_FILL_MEMORY=1
)
endif()

if(SQLITE3MC_USE_MINIZ OR _SQLITE3MC_REQUIRE_ZLIB)
if(_SQLITE3MC_REQUIRE_ZLIB)
Expand Down
2 changes: 1 addition & 1 deletion libsql-ffi/bundled/SQLite3MultipleCiphers/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2020 Ulrich Telle
Copyright (c) 2019-2024 Ulrich Telle

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ACLOCAL_AMFLAGS = -I admin/m4
AM_CXXFLAGS = -I$(top_srcdir)/src
AM_CFLAGS = -I$(top_srcdir)/src

AM_CFLAGS += -std=c99 -DSQLITE_THREADSAFE=1 -DSQLITE_DQS=0 -DSQLITE_MAX_ATTACHED=10 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_DESERIALIZE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_ENABLE_SESSION=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_EXTFUNC=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DSQLITE_ENABLE_CSV=1 -DSQLITE_ENABLE_SHA3=1 -DSQLITE_ENABLE_CARRAY=1 -DSQLITE_ENABLE_FILEIO=1 -DSQLITE_ENABLE_SERIES=1 -DSQLITE_ENABLE_UUID=1 -DSQLITE_ENABLE_REGEXP=1 -DSQLITE_TEMP_STORE=2 -DSQLITE_USE_URI=1 -DSQLITE_USER_AUTHENTICATION=1 $(X86_FLAGS) $(ARM_FLAGS)
AM_CFLAGS += -std=c99 -DSQLITE_THREADSAFE=1 -DSQLITE_DQS=0 -DSQLITE_MAX_ATTACHED=10 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_DESERIALIZE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_ENABLE_SESSION=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_EXTFUNC=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DSQLITE_ENABLE_CSV=1 -DSQLITE_ENABLE_SHA3=1 -DSQLITE_ENABLE_CARRAY=1 -DSQLITE_ENABLE_FILEIO=1 -DSQLITE_ENABLE_SERIES=1 -DSQLITE_ENABLE_UUID=1 -DSQLITE_ENABLE_REGEXP=1 -DSQLITE_TEMP_STORE=2 -DSQLITE_USE_URI=1 -DSQLITE_USER_AUTHENTICATION=0 $(X86_FLAGS) $(ARM_FLAGS)

if HOST_WINDOWS
AM_CFLAGS += -DSQLITE_API=__declspec\(dllexport\)
Expand Down Expand Up @@ -138,7 +138,7 @@ sqlite3shell_SOURCES = \
src/sqlite3mc.c \
src/shell.c

sqlite3shell_CFLAGS = -I$(top_srcdir)/src -std=c99 -D_GNU_SOURCE -DSQLITE_THREADSAFE=1 -DSQLITE_DQS=0 -DSQLITE_MAX_ATTACHED=10 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_DESERIALIZE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_ENABLE_SESSION=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_EXTFUNC=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DSQLITE_ENABLE_CSV=1 -DSQLITE_ENABLE_CARRAY=1 -DSQLITE_ENABLE_UUID=1 -DSQLITE_TEMP_STORE=2 -DSQLITE_USE_URI=1 -DSQLITE_USER_AUTHENTICATION=1 -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_STMTVTAB=1 -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION=1 $(X86_FLAGS) $(ARM_FLAGS)
sqlite3shell_CFLAGS = -I$(top_srcdir)/src -std=c99 -D_GNU_SOURCE -DSQLITE_THREADSAFE=1 -DSQLITE_DQS=0 -DSQLITE_MAX_ATTACHED=10 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_DESERIALIZE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_ENABLE_SESSION=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_EXTFUNC=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DSQLITE_ENABLE_CSV=1 -DSQLITE_ENABLE_CARRAY=1 -DSQLITE_ENABLE_UUID=1 -DSQLITE_TEMP_STORE=2 -DSQLITE_USE_URI=1 -DSQLITE_USER_AUTHENTICATION=0 -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_STMTVTAB=1 -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION=1 $(X86_FLAGS) $(ARM_FLAGS)

if HOST_WINDOWS
sqlite3shell_LDADD =
Expand Down
4 changes: 2 additions & 2 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/configure.ac
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
dnl Process this script with autoconf to create configure for sqlite3mc library
dnl
dnl Copyright (C) 2019-2023 Ulrich Telle <ulrich@telle-online.de>
dnl Copyright (C) 2019-2024 Ulrich Telle <ulrich@telle-online.de>
dnl
dnl This file is covered by the same licence as the entire SQLite3 Multiple Ciphers package.

AC_INIT([sqlite3mc], [1.8.1], [ulrich@telle-online.de])
AC_INIT([sqlite3mc], [1.9.0], [ulrich@telle-online.de])

dnl This is the version tested with, might work with earlier ones.
AC_PREREQ([2.69])
Expand Down
16 changes: 6 additions & 10 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ project "sqlite3mc_lib"
-- "SQLITE_ENABLE_SQLAR=1"
-- "SQLITE_ENABLE_ZIPFILE=1"
"SQLITE3MC_SECURE_MEMORY=$(SQLITE3MC_SECURE_MEMORY)",
-- "SQLITE3MC_USE_RANDOM_FILL_MEMORY=$(SQLITE3MC_USE_RANDOM_FILL_MEMORY)",
"SQLITE_TEMP_STORE=2",
"SQLITE_USE_URI=1",
"SQLITE_USER_AUTHENTICATION=1",
"SQLITE_USER_AUTHENTICATION=0",
-- Compatibility with official SQLite3 shell
"SQLITE_ENABLE_DBPAGE_VTAB=1",
"SQLITE_ENABLE_DBSTAT_VTAB=1",
Expand Down Expand Up @@ -190,10 +189,9 @@ project "sqlite3mc_dll"
-- "SQLITE_ENABLE_SQLAR=1"
-- "SQLITE_ENABLE_ZIPFILE=1"
"SQLITE3MC_SECURE_MEMORY=$(SQLITE3MC_SECURE_MEMORY)",
-- "SQLITE3MC_USE_RANDOM_FILL_MEMORY=$(SQLITE3MC_USE_RANDOM_FILL_MEMORY)",
"SQLITE_TEMP_STORE=2",
"SQLITE_USE_URI=1",
"SQLITE_USER_AUTHENTICATION=1"
"SQLITE_USER_AUTHENTICATION=0"
}

-- Intermediate directory
Expand Down Expand Up @@ -251,7 +249,7 @@ project "sqlite3mc_shell"
"SQLITE_SHELL_IS_UTF8=1",
"SQLITE_ENABLE_SESSION=1",
"SQLITE_ENABLE_DBPAGE_VTAB=1",
"SQLITE_USER_AUTHENTICATION=1"
"SQLITE_USER_AUTHENTICATION=0"
}

-- Intermediate directory
Expand Down Expand Up @@ -342,10 +340,9 @@ project "sqlite3mc_libicu"
-- "SQLITE_ENABLE_SQLAR=1"
-- "SQLITE_ENABLE_ZIPFILE=1"
"SQLITE3MC_SECURE_MEMORY=$(SQLITE3MC_SECURE_MEMORY)",
-- "SQLITE3MC_USE_RANDOM_FILL_MEMORY=$(SQLITE3MC_USE_RANDOM_FILL_MEMORY)",
"SQLITE_TEMP_STORE=2",
"SQLITE_USE_URI=1",
"SQLITE_USER_AUTHENTICATION=1",
"SQLITE_USER_AUTHENTICATION=0",
-- Compatibility with official SQLite3 shell
"SQLITE_ENABLE_DBPAGE_VTAB=1",
"SQLITE_ENABLE_DBSTAT_VTAB=1",
Expand Down Expand Up @@ -453,10 +450,9 @@ project "sqlite3mc_dllicu"
-- "SQLITE_ENABLE_SQLAR=1"
-- "SQLITE_ENABLE_ZIPFILE=1"
"SQLITE3MC_SECURE_MEMORY=$(SQLITE3MC_SECURE_MEMORY)",
-- "SQLITE3MC_USE_RANDOM_FILL_MEMORY=$(SQLITE3MC_USE_RANDOM_FILL_MEMORY)",
"SQLITE_TEMP_STORE=2",
"SQLITE_USE_URI=1",
"SQLITE_USER_AUTHENTICATION=1"
"SQLITE_USER_AUTHENTICATION=0"
}

-- Intermediate directory
Expand Down Expand Up @@ -526,7 +522,7 @@ project "sqlite3mc_shellicu"
"SQLITE_SHELL_IS_UTF8=1",
"SQLITE_ENABLE_SESSION=1",
"SQLITE_ENABLE_DBPAGE_VTAB=1",
"SQLITE_USER_AUTHENTICATION=1"
"SQLITE_USER_AUTHENTICATION=0"
}

-- Intermediate directory
Expand Down
8 changes: 4 additions & 4 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ The code was mainly developed under Windows, but was tested under Linux as well.

## Version information

* 1.8.1 - *December 2023*
- Based on SQLite version 3.44.2
- Fixed issue #133 - missing API symbols
- Applied several modifications to improve support for [SQLite3 WASM](https://sqlite.org/wasm/)
* 1.9.0 - *October 2024*
- Based on SQLite version 3.47.0
- Changed signature of cipher scheme method `GenerateKey` (affects only developers of dynamic cipher schemes)
- Using differing KDF and HMAC algorithms resulted in databases incompatible with the original SQLCipher library. Setting the parameter `hmac_algorithm_compat` to 0 restores the (incompatible) behaviour.

For further version information please consult the [CHANGELOG](CHANGELOG.md).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ die() {
exit 2
}

sed -e '/^ oputf("SQLite version/{n;N;d}' "$INPUT" \
sed -e '/^ sputf(stdout, "SQLite version/{n;N;d}' "$INPUT" \
| sed '/#ifdef SQLITE_CUSTOM_INCLUDE/!{p;d;};n;n;n;a #if SQLITE3MC_USE_MINIZ != 0 && !defined(SQLITE_ENABLE_COMPRESS)\n#include "miniz.c"\n#ifdef SQLITE_HAVE_ZLIB\n#undef SQLITE_HAVE_ZLIB\n#endif\n#define SQLITE_HAVE_ZLIB 1\n#endif\n' \
| sed '/#include <zlib.h>/c #include "zlibwrap.h"' \
| sed '/^ oputf("SQLite version/c \ extern char* sqlite3mc_version();\n oputf("SQLite version \%s \%.19s%s" \/\*extra-version-info\*\/\n " (\%s)\\n" \/\*SQLite3-Multiple-Ciphers-version-info\*\/\n "Enter \\".help\\" for usage hints.\\n\",\n sqlite3_libversion(), sqlite3_sourceid(), SHELL_CIO_CHAR_SET, sqlite3mc_version());'
| sed '/^ sqlite3_fprintf(stdout,$/c \ extern char* sqlite3mc_version();\n sqlite3_fprintf(stdout,' \
| sed '/^ "SQLite version/c \ "SQLite version \%s \%.19s%s" \/\*extra-version-info\*\/\n " (\%s)\\n" \/\*SQLite3-Multiple-Ciphers-version-info\*\/' \
| sed '/^ sqlite3_libversion(), sqlite3_sourceid(), SHELL_CIO_CHAR_SET);/c \ sqlite3_libversion(), sqlite3_sourceid(), SHELL_CIO_CHAR_SET, sqlite3mc_version());' \
| sed '/^ sqlite3_libversion(), sqlite3_sourceid());/a \ extern char* sqlite3mc_version();\n sqlite3_fprintf(p->out, "\%s\\n", sqlite3mc_version());'
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ die() {
# 1) Intercept VFS pragma handling
# 2) Add handling of KEY parameter in ATTACH statements
sed 's/sqlite3_file_control\(.*SQLITE_FCNTL_PRAGMA\)/sqlite3mcFileControlPragma\1/' "$INPUT" \
| sed '/\#endif \/\* SQLITE3\_H \*\//a \ \n\/\* Function prototypes of SQLite3 Multiple Ciphers \*\/\nSQLITE_PRIVATE int sqlite3mcCheckVfs(const char*);\nSQLITE_PRIVATE int sqlite3mcFileControlPragma(sqlite3*, const char*, int, void*);\nSQLITE_PRIVATE int sqlite3mcHandleAttachKey(sqlite3*, const char*, const char*, sqlite3_value*, char**);\nSQLITE_PRIVATE int sqlite3mcHandleMainKey(sqlite3*, const char*);\ntypedef struct PgHdr PgHdrMC;\nSQLITE_PRIVATE void* sqlite3mcPagerCodec(PgHdrMC* pPg);\ntypedef struct Pager PagerMC;\nSQLITE_PRIVATE int sqlite3mcPagerHasCodec(PagerMC* pPager);\nSQLITE_PRIVATE void sqlite3mcInitMemoryMethods();' \
| sed '/\#endif \/\* SQLITE3\_H \*\//a \ \n\/\* Function prototypes of SQLite3 Multiple Ciphers \*\/\nSQLITE_PRIVATE int sqlite3mcCheckVfs(const char*);\nSQLITE_PRIVATE int sqlite3mcFileControlPragma(sqlite3*, const char*, int, void*);\nSQLITE_PRIVATE int sqlite3mcHandleAttachKey(sqlite3*, const char*, const char*, sqlite3_value*, char**);\nSQLITE_PRIVATE int sqlite3mcHandleMainKey(sqlite3*, const char*);\ntypedef struct PgHdr PgHdrMC;\nSQLITE_PRIVATE void* sqlite3mcPagerCodec(PgHdrMC* pPg);\ntypedef struct Pager PagerMC;\nSQLITE_PRIVATE int sqlite3mcPagerHasCodec(PagerMC* pPager);\nSQLITE_PRIVATE void sqlite3mcInitMemoryMethods();\nSQLITE_PRIVATE int sqlite3mcIsBackupSupported(sqlite3*, const char*, sqlite3*, const char*);' \
| sed '/\#define MAX\_PATHNAME 512/c #if SQLITE3MC\_MAX\_PATHNAME \> 512\n#define MAX_PATHNAME SQLITE3MC\_MAX\_PATHNAME\n#else\n#define MAX_PATHNAME 512\n#endif' \
| sed '/pData = pPage->pData;/c \ if( (pData = sqlite3mcPagerCodec(pPage))==0 ) return SQLITE_NOMEM_BKPT;' \
| sed '/pData = p->pData;/c \ if( (pData = sqlite3mcPagerCodec(p))==0 ) return SQLITE_NOMEM;' \
Expand All @@ -26,4 +26,5 @@ sed 's/sqlite3_file_control\(.*SQLITE_FCNTL_PRAGMA\)/sqlite3mcFileControlPragma\
| sed '/sqlite3_free_filename(zOpen);/i \\n \/\* Handle encryption related URI parameters. \*\/\n if( rc==SQLITE_OK ){\n rc = sqlite3mcHandleMainKey(db, zOpen);\n }' \
| sed '/^ if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;/a \ if( sqlite3mcPagerHasCodec(pPager) != 0 ) return 0;' \
| sed '/^ }else if( USEFETCH(pPager) ){/c \ }else if( USEFETCH(pPager) && sqlite3mcPagerHasCodec(pPager) == 0 ){' \
| sed '/^ if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));/a \\n \/\* Initialize wrapper for memory management.\*\/\n if( rc==SQLITE_OK ) {\n sqlite3mcInitMemoryMethods();\n }\n'
| sed '/^ if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));/a \\n \/\* Initialize wrapper for memory management.\*\/\n if( rc==SQLITE_OK ) {\n sqlite3mcInitMemoryMethods();\n }\n' \
| sed '/Lock the source database handle./i \ \/\* Check whether databases are compatible with backup \*\/\n if (!sqlite3mcIsBackupSupported(pSrcDb, zSrcDb, pDestDb, zDestDb)){\n sqlite3ErrorWithMsg(pDestDb, SQLITE_ERROR, \"backup is not supported with incompatible source and target databases\");\n return NULL;\n }\n'
12 changes: 6 additions & 6 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/src/aes_hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ aesGenKeyEncrypt(const unsigned char* userKey, const int bits, unsigned char* ke
{
int numberOfRounds = (bits == 128) ? 10 : (bits == 192) ? 12 : (bits == 256) ? 14 : 0;
int rc = (!userKey || !keyData) ? -1 : (numberOfRounds > 0) ? 0 : -2;

if (rc == 0)
{
__m128i tempKey[_MAX_ROUNDS + 1];
Expand Down Expand Up @@ -347,7 +347,7 @@ aesDecryptCBC(const unsigned char* in,
int offset;
--numBlocks;
offset = numBlocks * 16;

/* Decrypt the last plain block. */
last_in = _mm_loadu_si128(&((__m128i*) in)[numBlocks]);
data = _mm_xor_si128(last_in, key[numberOfRounds - 0]);
Expand Down Expand Up @@ -477,7 +477,7 @@ aesGenKeyEncryptInternal(const unsigned char* userKey, const int bits, uint8x16_
int i;
int j;
int numberOfRounds = (bits == 128) ? 10 : (bits == 192) ? 12 : (bits == 256) ? 14 : 0;
int keyWords = bits / 32;
int keyWords = bits / 32;
int schedWords = (numberOfRounds + 1) * 4;

/*
Expand Down Expand Up @@ -538,7 +538,7 @@ aesGenKeyEncrypt(const unsigned char* userKey, const int bits, unsigned char* ke
{
int numberOfRounds = (bits == 128) ? 10 : (bits == 192) ? 12 : (bits == 256) ? 14 : 0;
int rc = (!userKey || !keyData) ? -1 : (numberOfRounds > 0) ? 0 : -2;

if (rc == 0)
{
uint8x16_t tempKey[_MAX_ROUNDS + 1];
Expand Down Expand Up @@ -648,7 +648,7 @@ aesEncryptCBC(const unsigned char* in,
}
feedback = vaeseq_u8(feedback, key[numberOfRounds-1]);
feedback = veorq_u8(feedback, key[numberOfRounds]); \

vst1q_u8(&out[(numBlocks-1)*16], feedback);

memcpy(&out[numBlocks*16], lastblock, lenFrag);
Expand Down Expand Up @@ -689,7 +689,7 @@ aesDecryptCBC(const unsigned char* in,
int offset;
--numBlocks;
offset = numBlocks * 16;

/* Decrypt the last plain block. */
last_in = vld1q_u8(&in[numBlocks*16]);

Expand Down
4 changes: 3 additions & 1 deletion libsql-ffi/bundled/SQLite3MultipleCiphers/src/ascon/aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ forceinline void ascon_adata(ascon_state_t* s, const uint8_t* ad,
ASCON_P(s, nr);
}
/* domain separation */
s->x[4] ^= 1;
s->x[4] ^= ASCON_DSEP();
ascon_printstate("domain separation", s);
}

Expand Down Expand Up @@ -197,6 +197,7 @@ forceinline void ascon_final(ascon_state_t* s, const ascon_key_t* key) {
ascon_printstate("final 2nd key xor", s);
}

SQLITE_PRIVATE
int ascon_aead_encrypt(uint8_t* ctext,
uint8_t tag[ASCON_AEAD_TAG_LEN],
const uint8_t* mtext, uint64_t mlen,
Expand All @@ -220,6 +221,7 @@ int ascon_aead_encrypt(uint8_t* ctext,
return 0;
}

SQLITE_PRIVATE
int ascon_aead_decrypt(uint8_t* mtext,
const uint8_t* ctext, uint64_t clen,
const uint8_t* ad, uint64_t adlen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#ifndef CRYPTO_AEAD_H
#define CRYPTO_AEAD_H

#ifndef SQLITE_PRIVATE
#define SQLITE_PRIVATE
#endif

#include <stddef.h>

/*
Expand All @@ -27,6 +31,7 @@
** \param nonce Buffer with nonce data
** \param k Buffer with key data
*/
SQLITE_PRIVATE
int ascon_aead_encrypt(uint8_t* ctext, uint8_t tag[ASCON_AEAD_TAG_LEN],
const uint8_t* mtext, uint64_t mlen,
const uint8_t* ad, uint64_t adlen,
Expand All @@ -45,6 +50,7 @@ int ascon_aead_encrypt(uint8_t* ctext, uint8_t tag[ASCON_AEAD_TAG_LEN],
** \param nonce Buffer with nonce data
** \param k Buffer with key data
*/
SQLITE_PRIVATE
int ascon_aead_decrypt(uint8_t* mtext, const uint8_t* ctext, uint64_t clen,
const uint8_t* ad, uint64_t adlen,
const uint8_t tag[ASCON_AEAD_TAG_LEN],
Expand Down
Loading
Loading