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

Pythemis does not work in virtual environment on macOS 13.3.1(a) #1000

Open
1 of 2 tasks
radetsky opened this issue May 22, 2023 · 0 comments
Open
1 of 2 tasks

Pythemis does not work in virtual environment on macOS 13.3.1(a) #1000

radetsky opened this issue May 22, 2023 · 0 comments
Labels
installation Installation of Themis core and wrapper packages W-PyThemis 🐍 Wrapper: PyThemis, Python API

Comments

@radetsky
Copy link
Contributor

Describe the bug
Impossible to use pythemis.

To Reproduce
Steps to reproduce the behavior:

  1. Use macOS 13.3.1(a), M1, python 3.9
  2. Run
python3 -m vent .python-env 
source .python-env/bin/activate 
python3 ./test.py 

test.py source:

from pythemis import skeygen, scell, smessage
from base64 import b64encode, b64decode

master_key = skeygen.GenerateSymmetricKey()

cell1 = scell.SCellSeal(key=master_key)
cell2 = scell.SCellSeal(passphrase='a password')

plaintext = b'Hello, PyThemis!'
context = b'Python context'

encrypted1 = cell1.encrypt(plaintext, context)
encrypted2 = cell2.encrypt(plaintext, context)

assert len(encrypted1) > len(plaintext)
assert len(encrypted2) > len(plaintext)

print(b64encode(master_key))
print(b64encode(encrypted1))
print(b64encode(encrypted2))

rn_symmetric_key = b'yezqKzmXTFH1/b/o1epvi1usm3dpr03USdhU1aGorhM='
rn_encrypted1 = b'AAEBQAwAAAAQAAAADgAAAAUJkENaFc1anpphYbIO/wEBabtRvjmusafDAkwQZEO2pLZmo5gtOmCT6w=='
rn_encrypted2 = b'AAEBQQwAAAAQAAAADgAAABYAAAA41fL+2Ujm7m3XS4ve4QP0p8jONocxvJpHDrPVQA0DABAAWsD16uhZ//X87oE1dA1pfhsbCQtYrFHlR4360pPL'
rn_password = b'Passphrase for Themis!'
rn_context = b'Themis context'

cell_rn1 = scell.SCellSeal(key=b64decode(rn_symmetric_key))
cell_rn2 = scell.SCellSeal(passphrase=rn_password)

decrypted1 = cell_rn1.decrypt(b64decode(rn_encrypted1), rn_context)
decrypted2 = cell_rn2.decrypt(b64decode(rn_encrypted2), rn_context)

print(f"Decrypted from RN with the key: {decrypted1}")
print(f"Decrypted from RN with the passphrase: {decrypted2}")
  1. See the following error:
Traceback (most recent call last):
  File "/Users/rad/git/playground/python/themis-venv-test/./themis_without_session.py", line 4, in <module>
    master_key = skeygen.GenerateSymmetricKey()
  File "/Users/rad/git/playground/python/themis-venv-test/.python-env/lib/python3.9/site-packages/pythemis/skeygen.py", line 71, in GenerateSymmetricKey
    res = themis.themis_gen_sym_key(None, byref(key_length))
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 379, in __getattr__
    func = self.__getitem__(name)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 384, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, themis_gen_sym_key): symbol not found

Expected behavior

b'heyFNItlkmGel9THxjZChouchzqY2EKOzRlfxn+jWc0='
b'AAEBQAwAAAAQAAAAEAAAADwof9PffphzYc1sqEhAeK3LJifMYGiVfSY33FluML3vzXsbPmDipBNt7smB'
b'AAEBQQwAAAAQAAAAEAAAABYAAADjy/nYs0irxvGjZGd6Mtk7KimMCKjHGH7icxc0QA0DABAA5gwWbybQKNmveAa/GotVzd1N6xq5MF9BVEgooRXL90U='
Decrypted from RN with the key: b'Hello, Themis!'
Decrypted from RN with the passphrase: b'Hello, Themis!'

Environment (please complete the following information):

  • OS: macOS Ventura 13.3.1(a)
  • Hardware: M1 MacBook Pro
  • Themis version: 0.14.10
  • Installation way:
    • via package manager
    • built from source

Additional context
Without using a virtual environment it works successfully on the same instance of OS.

@vixentael vixentael added W-PyThemis 🐍 Wrapper: PyThemis, Python API installation Installation of Themis core and wrapper packages labels May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation Installation of Themis core and wrapper packages W-PyThemis 🐍 Wrapper: PyThemis, Python API
Projects
None yet
Development

No branches or pull requests

2 participants