Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion error on Sparc Solaris 11.4 #257

Open
harri-pasanen opened this issue Apr 27, 2021 · 2 comments
Open

Assertion error on Sparc Solaris 11.4 #257

harri-pasanen opened this issue Apr 27, 2021 · 2 comments

Comments

@harri-pasanen
Copy link

harri-pasanen commented Apr 27, 2021

Hi,

After installing gcc, "pip3 install pykeepass" succeeded.
Unfortunaty, importing it causes the following assertion error:

Python 3.7.4 (default, Jul 24 2019, 06:55:16)
[GCC 7.3.0] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import pykeepass
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/pykeepass/__init__.py", line 2, in <module>
    from .pykeepass import PyKeePass, create_database
  File "/usr/lib/python3.7/site-packages/pykeepass/pykeepass.py", line 23, in <module>
    from pykeepass.kdbx_parsing.kdbx import KDBX
  File "/usr/lib/python3.7/site-packages/pykeepass/kdbx_parsing/__init__.py", line 1, in <module>
    from .kdbx import KDBX
  File "/usr/lib/python3.7/site-packages/pykeepass/kdbx_parsing/kdbx.py", line 2, in <module>
    from .kdbx3 import DynamicHeader as DynamicHeader3
  File "/usr/lib/python3.7/site-packages/pykeepass/kdbx_parsing/kdbx3.py", line 10, in <module>
    from .common import (
  File "/usr/lib/python3.7/site-packages/pykeepass/kdbx_parsing/common.py", line 2, in <module>
    from .twofish import Twofish
  File "/usr/lib/python3.7/site-packages/pykeepass/kdbx_parsing/twofish.py", line 27, in <module>
    from . import pytwofish
  File "/usr/lib/python3.7/site-packages/pykeepass/kdbx_parsing/pytwofish.py", line 395, in <module>
    assert b'l\xb4V\x1c@\xbf\n\x97\x05\x93\x1c\xb6\xd4\x08\xe7\xfa' == Twofish(__testkey).encrypt(__testdat)
AssertionError
@harri-pasanen
Copy link
Author

I took a quick look at the source of pytwofish.py, and it seems that WORD_BIGENDIAN is set to 1 on Solaris, which is correct in principle, but not in practice, at least not for the self-test code that now takes a different execution path for pure python data depending on endianness, which seemed wrong. So by commenting out lines 143-144:

# if sys.byteorder == 'big':
#    WORD_BIGENDIAN = 1

it starts to work. It also seems to be working fine reading a keepass created on Windows (Intel little endian).

Is the endianness present in the KeePass database? So if I were to create one on Solaris KeePassX (assuming one exists), would that not be usable on Windows?

To me it looks like all branches where WORD_BIGENDIAN is true could be cleaned up from the code in pytwofish.py, or the self test would need to have a different data set for BIGENDIAN machines, assuming that the KeePass data really could be big-endian.

@janroelofs
Copy link

I see the same problem on zLinux (Linux on z/OS, s390x) which also has sys.byteorder = 'big'.
Commenting the 2 lines also fixed it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants