LudovicRousseau / PyKCS11

PKCS#11 Wrapper for Python
GNU General Public License v2.0
96 stars 35 forks source link

Documentation for PyKCS11 Version 1.5.9 #74

Closed strmar closed 4 years ago

strmar commented 4 years ago

Your system information

Please describe your issue in as much detail as possible:

Hello , want to test my SmartCard-Reader with the sample get token information. The sample is from the Docu 1.5.2, after testing the script the compiler throw an error.

Describe what did happen.

Error: Module 'PyKCS11' has no 'CKF_DIGEST' member

Is there an actual docu of the version 1.5.9

thanks

Steps for reproducing this issue:

LudovicRousseau commented 4 years ago

Please provide the full output of the execution of the program.

What do you call "the Docu 1.5.2"?

strmar commented 4 years ago

Hello,

I only can find the documentation of PyKCS11 version 1.5.2, on my device i have the version 1.5.9 of PyKCS#11

Bildschirmfoto 2020-08-24 um 09 27 22

I wanted to test my SmartCard-Reader from Omnikey AG 6121 mobile from cryptas, wth the sample code

For testing i have take the example-code "Get token information" from https://pkcs11wrap.sourceforge.io/api/samples.html#get-token-information

i get an error in the method getMechanismInfo(self, slot=

def getMechanismInfo(self, slot): print(" Mechanism list: ") m = self.pkcs11.getMechanismList(slot) for x in m: self.colorize(" ", x) i = self.pkcs11.getMechanismInfo(slot, x) if not i.flags & PyKCS11.CKF_DIGEST: if i.ulMinKeySize != PyKCS11.CK_UNAVAILABLE_INFORMATION: self.colorize(" ulMinKeySize:", i.ulMinKeySize) if i.ulMaxKeySize != PyKCS11.CK_UNAVAILABLE_INFORMATION: self.colorize(" ulMaxKeySize:", i.ulMaxKeySize) self.colorize(" flags:", ", ".join(i.flags2text()))

My Editor shows the Error:

Error: Module 'PyKCS11' has no 'CKF_DIGEST' member (which is bold marked)

So my question is, if something has changed in the newer version of PyKCS11.

I only found the Documentation of the Version 1.5.2

A big thank you in advance

LudovicRousseau commented 4 years ago

I can't reproduce your problem. It works fine for me.

$ python3
Python 3.7.6 (default, Dec 30 2019, 19:38:26) 
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyKCS11
>>> print(PyKCS11.CKF_DIGEST)
1024

CKF_DIGEST is still defined. You have a problem with your PyKCS11 installation.

Have you tried the Debian package python3-pykcs11? https://packages.debian.org/sid/python3-pykcs11

strmar commented 4 years ago

Hello Ludovic,

I think you are right in thinking that I have problems with the installation, I installed the library with pip3, then deleted it and installed the package with apt-get again,

The first attempt was via venv, and in venv using pip3

to install the packages PyKCS11 and asn1crypto, which works, but again the problem is that I can't import the PyKCS11 library.

your suggestion via CLI print(PyKCS11.CKF_DIGEST) worked for me too.

Try to include an external library of the manufacturer, but I get an error here too. Since I am new to Python, I guess that I am not able to include the library of the manufacturer correctly.

See the screenshot, if he can't find the PyKCS11 library when importing, do I have to consider anything else?

screenshot screenshot1

Many thanks in advance

LudovicRousseau commented 4 years ago

I guess the file /usr/lib/x86-athena/libASEP11.so does not exist or, more probably, is for Intel x86 CPU and not ARM CPU (used by the Raspberry Pi).

Your problem is not with PyKCS11 itself.

strmar commented 4 years ago

Hello,

You are probably right, as you can see from the screenshot, I try to include the library dynamically, but it is still not found or ignored. screenshot3