unpack throw exception
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 170
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the traceback locations in pkcs11/_utils.pyx and pkcs11/defaults.py, especially _unpack_attributes and the _ulong conversion. Reproduce the generate_key call on Ubuntu and the Linux-from-scratch system, then compare the Python, platform, compiler, and PKCS#11 library environments. Done means identifying the environmental cause of the buffer-size mismatch or documenting the required dependency or platform condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, python
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100