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

1.5.15: circular imports and issue with get_PYKCS11LIB module on testing #115

Open
kloczek opened this issue May 17, 2024 · 9 comments
Open
Assignees

Comments

@kloczek
Copy link

kloczek commented May 17, 2024

On building documentation sphinx shows warnings about circular imports

+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v7.3.7
making output directory... done
[autosummary] generating autosummary for: api.rst, index.rst, license.rst, samples.rst
WARNING: Failed to import PyKCS11.
Possible hints:
* ImportError: cannot import name '_LowLevel' from partially initialized module 'PyKCS11' (most likely due to a circular import) (/home/tkloczko/rpmbuild/BUILD/PyKCS11-1.5.15/PyKCS11/__init__.py)
* KeyError: 'PyKCS11'
building [mo]: targets for 0 po files that are out of date
writing output...
building [man]: all manpages
updating environment: [new config] 4 added, 0 changed, 0 removed
reading sources... [100%] samples
WARNING: autodoc: failed to import module 'PyKCS11'; the following exception was raised:
cannot import name '_LowLevel' from partially initialized module 'PyKCS11' (most likely due to a circular import) (/home/tkloczko/rpmbuild/BUILD/PyKCS11-1.5.15/PyKCS11/__init__.py)
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
writing... python-pykcs11.3 { api samples license } done
build succeeded, 2 warnings.

And looks like test suite needs get_PYKCS11LIB module but I cannot find on pypi what provides it.

+ /usr/bin/pytest -ra -m 'not network' --import-mode=importlib
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/tkloczko/rpmbuild/BUILD/PyKCS11-1.5.15
configfile: pyproject.toml
collected 70 items / 1 error

========================================================================================== ERRORS ===========================================================================================
_______________________________________________________________________________ ERROR collecting run_test.py ________________________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/PyKCS11-1.5.15/run_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
run_test.py:11: in <module>
    import get_PYKCS11LIB
E   ModuleNotFoundError: No module named 'get_PYKCS11LIB'
================================================================================== short test summary info ==================================================================================
ERROR run_test.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 1 error in 0.19s ======================================================================================

May I ask for some hint? 🤔

@kloczek
Copy link
Author

kloczek commented May 18, 2024

Just found get_PYKCS11LIB in source root directory 😋
Nevertheless that location is not well suited for parts of the test suite..
Probably the best would be just integrate that into run_test.py.

@LudovicRousseau
Copy link
Owner

To build the documentation use:

docs/generate.sh

To run the tests:

  1. build and install PyKCS11 as documented in https://github.com/LudovicRousseau/PyKCS11?tab=readme-ov-file#unix-build-howto
  2. and run:
./run_test.py

@kloczek
Copy link
Author

kloczek commented May 18, 2024

You are using unittest and correctly written test suite i correctly handled by pytest.
Conclusion: your test suite is not correct even for unittest. It would be good to fix that.

Building: every module should be compliant with PEP517 methodology.
As you see that methodology build procedurę shows warnings.

@LudovicRousseau
Copy link
Owner

For the tests:

export $(./get_PYKCS11LIB.py)
pytest -ra -m 'not network'

works for me.

Feel free to propose a patch if you need something more/else.

@kloczek
Copy link
Author

kloczek commented May 19, 2024

For the tests:

export $(./get_PYKCS11LIB.py)
pytest -ra -m 'not network'

works for me.

For me it does not work because that script is not checking arch dependent libdir.
Other thing is that instead using env variable better would be detect on build stage where this library is and than generate PyKCS11/init.py to hardcode that path into that file.

Just tested with export PYKCS11LIB=/usr/lib64/softhsm/libsofthsm2.so and test suite still fails

Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network' --import-mode=importlib test
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/tkloczko/rpmbuild/BUILD/PyKCS11-1.5.15
configfile: pyproject.toml
plugins: hypothesis-6.100.0, asyncio-0.23.6, mock-3.14.0, typeguard-4.2.1
asyncio: mode=strict
collected 70 items

test/test_CK.py ...                                                                                                                                                                   [  4%]
test/test_LowLevel.py F                                                                                                                                                               [  5%]
test/test_asymetric.py FFFFFFFFFFF                                                                                                                                                    [ 21%]
test/test_asymetric_ECC.py FF                                                                                                                                                         [ 24%]
test/test_asymetric_gost.py F                                                                                                                                                         [ 25%]
test/test_ckbytelist.py ..............                                                                                                                                                [ 45%]
test/test_derive.py F                                                                                                                                                                 [ 47%]
test/test_digest.py FF                                                                                                                                                                [ 50%]
test/test_exception.py ........                                                                                                                                                       [ 61%]
test/test_gc.py F                                                                                                                                                                     [ 62%]
test/test_info.py FFFFF                                                                                                                                                               [ 70%]
test/test_init.py FFFF                                                                                                                                                                [ 75%]
test/test_load.py .                                                                                                                                                                   [ 77%]
test/test_objects.py FFFFF                                                                                                                                                            [ 84%]
test/test_pin.py FFFFF                                                                                                                                                                [ 91%]
test/test_random.py FF                                                                                                                                                                [ 94%]
test/test_symetric.py F                                                                                                                                                               [ 95%]
test/test_wrap.py FFF                                                                                                                                                                 [100%]

========================================================================================= FAILURES ==========================================================================================
__________________________________________________________________________________ TestUtil.test_LowLevel ___________________________________________________________________________________

self = <test.test_LowLevel.TestUtil testMethod=test_LowLevel>

    def test_LowLevel(self):
        a = PyKCS11.LowLevel.CPKCS11Lib()
        self.assertIsNotNone(a)

        # File not found
        self.assertEqual(a.Load("NoFile"), -1)

        # C_GetFunctionList() not found
        if platform.system() == 'Linux':
            # GNU/Linux
            lib = "libc.so.6"
        elif platform.system() == 'Darwin':
            # macOS
            lib = "/usr/lib/libSystem.B.dylib"
        else:
            # Windows
            lib = "WinSCard.dll"
        self.assertEqual(a.Load(lib), -4)

        info = PyKCS11.LowLevel.CK_INFO()
        self.assertIsNotNone(info)

        slotInfo = PyKCS11.LowLevel.CK_SLOT_INFO()
        self.assertIsNotNone(slotInfo)

        lib = os.getenv("PYKCS11LIB")
        if lib is None:
            raise (Exception("Define PYKCS11LIB"))

        session = PyKCS11.LowLevel.CK_SESSION_HANDLE()
        self.assertIsNotNone(session)

        sessionInfo = PyKCS11.LowLevel.CK_SESSION_INFO()
        self.assertIsNotNone(sessionInfo)

        tokenInfo = PyKCS11.LowLevel.CK_TOKEN_INFO()
        self.assertIsNotNone(tokenInfo)

        slotList = PyKCS11.LowLevel.ckintlist()
        self.assertIsNotNone(slotList)

        a.Load(lib)

>       self.assertEqual(a.C_GetInfo(info), PyKCS11.LowLevel.CKR_OK)
E       AssertionError: 400 != 0

test/test_LowLevel.py:52: AssertionError
__________________________________________________________________________________ TestUtil.test_RSA_OAEP ___________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_RSA_OAEP>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d59360b0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_______________________________________________________________________________ TestUtil.test_RSA_OAEPwithAAD _______________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_RSA_OAEPwithAAD>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d57ece80>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________________________________ TestUtil.test_RSA_PSS_SHA1 _________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_RSA_PSS_SHA1>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d51a51e0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_______________________________________________________________________________ TestUtil.test_RSA_PSS_SHA256 ________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_RSA_PSS_SHA256>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d59488b0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________________________________ TestUtil.test_encrypt_PKCS _________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_encrypt_PKCS>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d58ca260>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________________________________ TestUtil.test_encrypt_X509 _________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_encrypt_X509>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d51a7910>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________________ TestUtil.test_pubKey ____________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_pubKey>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53009a0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
__________________________________________________________________________________ TestUtil.test_sign_PKCS __________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_sign_PKCS>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d586d2a0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
______________________________________________________________________________ TestUtil.test_sign_PKCS_SHA256 _______________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_sign_PKCS_SHA256>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d59a4fa0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
__________________________________________________________________________________ TestUtil.test_sign_X509 __________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_sign_X509>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d57b1360>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________________________________ TestUtil.test_sign_integer _________________________________________________________________________________

self = <test.test_asymetric.TestUtil testMethod=test_sign_integer>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d5301ab0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________________________________ TestUtil.test_sign_integer _________________________________________________________________________________

self = <test.test_asymetric_ECC.TestUtil testMethod=test_sign_integer>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric_ECC.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d58c89d0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
__________________________________________________________________________________ TestUtil.test_sign_text __________________________________________________________________________________

self = <test.test_asymetric_ECC.TestUtil testMethod=test_sign_text>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric_ECC.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d57efcd0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
____________________________________________________________________________________ TestUtil.test_gost _____________________________________________________________________________________

self = <test.test_asymetric_gost.TestUtil testMethod=test_gost>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_asymetric_gost.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53efa90>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________ TestUtil.test_deriveKey_ECDH1_DERIVE ____________________________________________________________________________

self = <test.test_derive.TestUtil testMethod=test_deriveKey_ECDH1_DERIVE>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_derive.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d586e4a0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________________ TestUtil.test_digest ____________________________________________________________________________________

self = <test.test_digest.TestUtil testMethod=test_digest>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_digest.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53013c0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________________________________ TestUtil.test_digestSession ________________________________________________________________________________

self = <test.test_digest.TestUtil testMethod=test_digestSession>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_digest.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d587d6c0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_____________________________________________________________________________________ TestUtil.test_gc ______________________________________________________________________________________

self = <test.test_gc.TestUtil testMethod=test_gc>

    def test_gc(self):
        res = list()
        # we must use at least 2 sessions
        for n in range(2):
>           p11, session = self.createSession()

test/test_gc.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/test_gc.py:23: in createSession
    pkcs11.load()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53eece0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________________ TestUtil.test_getInfo ___________________________________________________________________________________

self = <test.test_info.TestUtil testMethod=test_getInfo>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_info.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53c7730>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
______________________________________________________________________________ TestUtil.test_getMechanismList _______________________________________________________________________________

self = <test.test_info.TestUtil testMethod=test_getMechanismList>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_info.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53b5570>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_______________________________________________________________________________ TestUtil.test_getSessionInfo ________________________________________________________________________________

self = <test.test_info.TestUtil testMethod=test_getSessionInfo>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_info.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d586d6f0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_________________________________________________________________________________ TestUtil.test_getSlotInfo _________________________________________________________________________________

self = <test.test_info.TestUtil testMethod=test_getSlotInfo>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_info.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53c7940>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________________________________ TestUtil.test_getTokenInfo _________________________________________________________________________________

self = <test.test_info.TestUtil testMethod=test_getTokenInfo>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_info.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53b7be0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________________ TestUtil.test_initPin ___________________________________________________________________________________

self = <test.test_init.TestUtil testMethod=test_initPin>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_init.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d586e680>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
__________________________________________________________________________________ TestUtil.test_initToken __________________________________________________________________________________

self = <test.test_init.TestUtil testMethod=test_initToken>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_init.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53ed9f0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_______________________________________________________________________________ TestUtil.test_initToken_utf8 ________________________________________________________________________________

self = <test.test_init.TestUtil testMethod=test_initToken_utf8>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_init.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d58ca530>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________________ TestUtil.test_setPin ____________________________________________________________________________________

self = <test.test_init.TestUtil testMethod=test_setPin>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_init.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d51a79d0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________________ TestUtil.test_objects ___________________________________________________________________________________

self = <test.test_objects.TestUtil testMethod=test_objects>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_objects.py:12:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53b6140>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_____________________________________________________________________ TestGetSetAttributeValues.test_getAttributeValue ______________________________________________________________________

self = <test.test_objects.TestGetSetAttributeValues testMethod=test_getAttributeValue>

    def setUp(self) -> None:

        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_objects.py:102:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d586e7a0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________ TestGetSetAttributeValues.test_setAttributeValue_with_a_list_of_attributes _________________________________________________________

self = <test.test_objects.TestGetSetAttributeValues testMethod=test_setAttributeValue_with_a_list_of_attributes>

    def setUp(self) -> None:

        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_objects.py:102:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d58c9600>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________ TestGetSetAttributeValues.test_setAttributeValue_with_label_attribute ___________________________________________________________

self = <test.test_objects.TestGetSetAttributeValues testMethod=test_setAttributeValue_with_label_attribute>

    def setUp(self) -> None:

        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_objects.py:102:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d57b0190>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_______________________________________________________ TestGetSetAttributeValues.test_setAttributeValue_with_single_binary_attribute _______________________________________________________

self = <test.test_objects.TestGetSetAttributeValues testMethod=test_setAttributeValue_with_single_binary_attribute>

    def setUp(self) -> None:

        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_objects.py:102:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d594ae90>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________________ TestUtil.test_binary ____________________________________________________________________________________

self = <test.test_pin.TestUtil testMethod=test_binary>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_pin.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d57ec610>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_________________________________________________________________________________ TestUtil.test_ckbytelist __________________________________________________________________________________

self = <test.test_pin.TestUtil testMethod=test_ckbytelist>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_pin.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d586c640>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
____________________________________________________________________________________ TestUtil.test_login ____________________________________________________________________________________

self = <test.test_pin.TestUtil testMethod=test_login>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_pin.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d51a4a90>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
____________________________________________________________________________________ TestUtil.test_null _____________________________________________________________________________________

self = <test.test_pin.TestUtil testMethod=test_null>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_pin.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53b52d0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
____________________________________________________________________________________ TestUtil.test_wrong ____________________________________________________________________________________

self = <test.test_pin.TestUtil testMethod=test_wrong>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_pin.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d587f4f0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_______________________________________________________________________________ TestUtil.test_generateRandom ________________________________________________________________________________

self = <test.test_random.TestUtil testMethod=test_generateRandom>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_random.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d5300550>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
_________________________________________________________________________________ TestUtil.test_seedRandom __________________________________________________________________________________

self = <test.test_random.TestUtil testMethod=test_seedRandom>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_random.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d57ed180>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
__________________________________________________________________________________ TestUtil.test_symetric ___________________________________________________________________________________

self = <test.test_symetric.TestUtil testMethod=test_symetric>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_symetric.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d587cc10>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________________ TestUtil.test_wrapKey ___________________________________________________________________________________

self = <test.test_wrap.TestUtil testMethod=test_wrapKey>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_wrap.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d53c43a0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
________________________________________________________________________________ TestUtil.test_wrapKey_OAEP _________________________________________________________________________________

self = <test.test_wrap.TestUtil testMethod=test_wrapKey_OAEP>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_wrap.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d57edab0>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
___________________________________________________________________________ TestUtil.test_wrapKey_UNWRAP_TEMPLATE ___________________________________________________________________________

self = <test.test_wrap.TestUtil testMethod=test_wrapKey_UNWRAP_TEMPLATE>

    def setUp(self):
        self.pkcs11 = PyKCS11.PyKCS11Lib()
>       self.pkcs11.load()

test/test_wrap.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <PyKCS11.PyKCS11Lib object at 0x7fe4d586d480>, pkcs11dll_filename = '/usr/lib64/softhsm/libsofthsm2.so', init_string = (), rv = 5

    def load(self, pkcs11dll_filename=None, *init_string):
        """
        load a PKCS#11 library

        :type pkcs11dll_filename: string
        :param pkcs11dll_filename: the library name.
          If this parameter is not set then the environment variable
          `PYKCS11LIB` is used instead
        :returns: a :class:`PyKCS11Lib` object
        :raises: :class:`PyKCS11Error` (-1): when the load fails
        """
        if pkcs11dll_filename is None:
            pkcs11dll_filename = os.getenv("PYKCS11LIB")
            if pkcs11dll_filename is None:
                raise PyKCS11Error(-1, "No PKCS11 library specified (set PYKCS11LIB env variable)")

        # remember the lib file name
        self.pkcs11dll_filename = pkcs11dll_filename

        # if the lib is already in use: reuse it
        if pkcs11dll_filename in PyKCS11Lib._loaded_libs:
            self.lib.Duplicate(PyKCS11Lib._loaded_libs[pkcs11dll_filename]["ref"])
        else:
            # else load it
            rv = self.lib.Load(pkcs11dll_filename)
            if rv != CKR_OK:
>               raise PyKCS11Error(rv, pkcs11dll_filename)
E               PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)

../../BUILDROOT/python-PyKCS11-1.5.15-2.fc37.x86_64/usr/lib64/python3.10/site-packages/PyKCS11/__init__.py:518: PyKCS11Error
================================================================================== short test summary info ==================================================================================
FAILED test/test_LowLevel.py::TestUtil::test_LowLevel - AssertionError: 400 != 0
FAILED test/test_asymetric.py::TestUtil::test_RSA_OAEP - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_RSA_OAEPwithAAD - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_RSA_PSS_SHA1 - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_RSA_PSS_SHA256 - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_encrypt_PKCS - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_encrypt_X509 - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_pubKey - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_sign_PKCS - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_sign_PKCS_SHA256 - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_sign_X509 - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric.py::TestUtil::test_sign_integer - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric_ECC.py::TestUtil::test_sign_integer - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric_ECC.py::TestUtil::test_sign_text - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_asymetric_gost.py::TestUtil::test_gost - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_derive.py::TestUtil::test_deriveKey_ECDH1_DERIVE - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_digest.py::TestUtil::test_digest - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_digest.py::TestUtil::test_digestSession - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_gc.py::TestUtil::test_gc - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_info.py::TestUtil::test_getInfo - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_info.py::TestUtil::test_getMechanismList - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_info.py::TestUtil::test_getSessionInfo - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_info.py::TestUtil::test_getSlotInfo - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_info.py::TestUtil::test_getTokenInfo - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_init.py::TestUtil::test_initPin - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_init.py::TestUtil::test_initToken - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_init.py::TestUtil::test_initToken_utf8 - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_init.py::TestUtil::test_setPin - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_objects.py::TestUtil::test_objects - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_objects.py::TestGetSetAttributeValues::test_getAttributeValue - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_objects.py::TestGetSetAttributeValues::test_setAttributeValue_with_a_list_of_attributes - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_objects.py::TestGetSetAttributeValues::test_setAttributeValue_with_label_attribute - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_objects.py::TestGetSetAttributeValues::test_setAttributeValue_with_single_binary_attribute - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_pin.py::TestUtil::test_binary - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_pin.py::TestUtil::test_ckbytelist - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_pin.py::TestUtil::test_login - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_pin.py::TestUtil::test_null - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_pin.py::TestUtil::test_wrong - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_random.py::TestUtil::test_generateRandom - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_random.py::TestUtil::test_seedRandom - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_symetric.py::TestUtil::test_symetric - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_wrap.py::TestUtil::test_wrapKey - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_wrap.py::TestUtil::test_wrapKey_OAEP - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
FAILED test/test_wrap.py::TestUtil::test_wrapKey_UNWRAP_TEMPLATE - PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005)
=============================================================================== 44 failed, 26 passed in 2.19s ===============================================================================

@LudovicRousseau
Copy link
Owner

libsofthsm2 is just ONE PKCS#11 library that can be used with PyKCS11.
I use it for testing but in "the real life" you would use another PKCS#11 library and a smart card.

You need to setup your software libsofthsm2 token using https://github.com/LudovicRousseau/PyKCS11/blob/master/test/reset_softHSM.sh

Why are you using PyKCS11?

@kloczek
Copy link
Author

kloczek commented May 23, 2024

You need to setup your software libsofthsm2 token using https://github.com/LudovicRousseau/PyKCS11/blob/master/test/reset_softHSM.sh

Looks like it can be done from non-root account so it can be done as well in pytest session as part of it.

Why are you using PyKCS11?

Quote from opening this ticket:

On building documentation sphinx shows warnings about circular imports

@LudovicRousseau
Copy link
Owner

Can you propose a patch?

@kloczek
Copy link
Author

kloczek commented May 25, 2024

Can you propose a patch?

First would be good to resolve all those PyKCS11.PyKCS11Error: CKR_GENERAL_ERROR (0x00000005) fails.

IMO possible patch could make location of the libsofthsm2.so detection in setu.py and than generate PyKCS11/init.py with proper path.

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

No branches or pull requests

2 participants