Skip to content

Commit

Permalink
Comment out sqlcipher and continue running on error
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerbinns committed Jun 2, 2024
1 parent 28ad0e7 commit b7242bd
Showing 1 changed file with 39 additions and 32 deletions.
71 changes: 39 additions & 32 deletions apsw/mcall.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
},
}

# sqlcipher unusable due to https://github.com/utelle/SQLite3MultipleCiphers/issues/160
del ciphers["sqlcipher"]

all_params: set[str] = set()
for v in ciphers.values():
Expand Down Expand Up @@ -99,41 +101,46 @@ def permutations() -> Generator[tuple[str, tuple[str, int], tuple[str, int]], No


def run():
con = apsw.Connection("mcall")
con.execute("create table x(y); insert into x values(randomblob(65536))")

for cipher, good, bad in permutations():
con.pragma("cipher", cipher)
for name, val in bad:
if con.pragma(name, val) == str(val):
breakpoint()
1 / 0
for name, val in good:
if con.pragma(name, val) != str(val):
breakpoint()
1 / 0
d = {"cipher": cipher}
d.update({name: val for name, val in good})
print(d)
retry = False
try:
con.pragma("hexrekey", random.randbytes(random.randrange(100)).hex())
except apsw.SQLError as exc:
for ok in ok_messages:
if ok in str(exc):
retry = True
print(str(exc))
break
else:
raise
while True:
cleanup()
con = apsw.Connection("mcall")
con.execute("create table x(y); insert into x values(randomblob(65536))")

for cipher, good, bad in permutations():
con.pragma("cipher", cipher)
for name, val in bad:
if con.pragma(name, val) == str(val):
breakpoint()
1 / 0
for name, val in good:
if con.pragma(name, val) != str(val):
breakpoint()
1 / 0
d = {"cipher": cipher}
d.update({name: val for name, val in good})
print(d)
retry = False
try:
con.pragma("hexrekey", random.randbytes(random.randrange(100)).hex())
except apsw.SQLError as exc:
for ok in ok_messages:
if ok in str(exc):
retry = True
print(str(exc))
break
else:
raise

if retry:
continue
if retry:
continue

con.execute("insert into x values(randomblob(?))", (random.randrange(0, 100000),))
con.execute("delete from x where y in (select min(y) from x)")
try:
con.execute("insert into x values(randomblob(?))", (random.randrange(0, 100000),))
con.execute("delete from x where y in (select min(y) from x)")
except Exception as exc:
print(f"****** Unexpected exception {exc} - starting again)")
break


random.seed(0)
cleanup()
run()

0 comments on commit b7242bd

Please sign in to comment.