Skip to content

unpack throw exception  #66

@Benjamin-Shengming

Description

@Benjamin-Shengming

I have tried this pkcs11 lib on ubuntu 19.04 with python 3.7.3, run with a vendor HSM(EngageBlack), all works good.

However, when I use it on an Linux from scratch system, using same HSM, I got following error.

bash-4.3# python3
Python 3.7.4 (default, Sep 24 2019, 10:51:40) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkcs11
>>> lib = pkcs11.lib("/usr/lib/libbvpkcs.so")
>>> token = lib.get_token()
>>> session = token.open()
>>> key = session.generate_key(pkcs11.KeyType.AES, 256)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pkcs11/_pkcs11.pyx", line 409, in pkcs11._pkcs11.Session.generate_key
  File "pkcs11/_pkcs11.pyx", line 564, in pkcs11._pkcs11.Object._make
  File "pkcs11/_pkcs11.pyx", line 615, in pkcs11._pkcs11.Object.__getitem__
  File "pkcs11/_utils.pyx", line 35, in pkcs11._pkcs11._unpack_attributes
  File "/usr/lib/python3.7/site-packages/python_pkcs11-0.5.0-py3.7-linux-x86_64.egg/pkcs11/defaults.py", line 129, in <lambda>
    lambda v: type_(unpack(v)))
  File "/usr/lib/python3.7/site-packages/python_pkcs11-0.5.0-py3.7-linux-x86_64.egg/pkcs11/defaults.py", line 114, in <lambda>
    _ulong = (Struct('L').pack, lambda v: Struct('L').unpack(v)[0])
struct.error: unpack requires a buffer of 8 bytes

are there any other dependencies I need to take care of?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    vendorThis is a PKCS#11 vendor bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions