[pybsddb] Windows support for berkeleydb

Jesus Cea jcea at jcea.es
Mon Dec 16 02:07:59 CET 2024


On 26/11/24 20:16, Brian Matthews wrote:
> It also contains a change for src/Module/berkeleydb.c
> This changes allow the encryption password to be either a string, or a byte string.
> Bsddb3 used to allow binary keys. This restores that ability.

Brian, that patch is wrong. Berkeley DB password must be a string with 
no null characters. A generic binary key is unsafe if it contains "\0", 
because it would be truncated to the first null.

The code enforces a string for a good reason.

Legacy "bsddb3" accepts binary, but it is wrong, the key could be 
silently truncated.

I added some details in the documentation. See:

https://docs.jcea.es/berkeleydb/latest/db.html#set_encrypt
https://docs.jcea.es/berkeleydb/latest/dbenv.html#set_encrypt

If you already has a binary key with "\0" inside, that key will actually 
be truncated up to that "\0". So you can simply truncate the key there 
by yourself, check that it actually can access the database just fine 
and then maybe export/import the database with an actually strong key, 
with no \0 inside. Just to be safe and be sure it uses a full length key.

If you require being able to use a random key, I would suggest you to 
encode it using base16, base64 or something like that, to transform it 
to a regular string able to encode "\0" values.

If you have a "legacy" binary key with no "\0" inside, just encode it to 
a string as described in the links above.

Let me know if this explanation is enough for you and if I can help you 
with anything else.

I am still thinking how to integrate your patches for windows support. 
Apparently they mostly restore code I deleted in 18.1.10. Reverting that 
deletion would be enough for you?

Thanks for the compiled binary. Would be nice to be able to use a 
Windows compilation service somewhere, for free. I am not familiar with 
that area, though. Can somebody help here?

-- 
Jesús Cea Avión                         _/_/      _/_/_/        _/_/_/
jcea at jcea.es - https://www.jcea.es/    _/_/    _/_/  _/_/    _/_/  _/_/
Twitter: @jcea                        _/_/    _/_/          _/_/_/_/_/
jabber / xmpp:jcea at jabber.org  _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz


More information about the pybsddb mailing list