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

OverflowError: Python int too large to convert to C ssize_t #139

Open
talcher opened this issue Aug 31, 2022 · 0 comments
Open

OverflowError: Python int too large to convert to C ssize_t #139

talcher opened this issue Aug 31, 2022 · 0 comments

Comments

@talcher
Copy link

talcher commented Aug 31, 2022

Hello,

I try to generate a RSA keypair. Sometimes it works; sometimes it does not.

Here is a part of the traceback of the error, when it is triggered:

File "************.py", line ****, in generate
    pub, priv = session.generate_keypair(
  File "my_project/lib/python3.9/site-packages/pkcs11/types.py", line 509, in generate_keypair
    return self._generate_keypair(key_type, key_length=key_length,
  File "pkcs11/_pkcs11.pyx", line 573, in pkcs11._pkcs11.Session._generate_keypair
  File "pkcs11/_pkcs11.pyx", line 692, in pkcs11._pkcs11.Object._make
  File "pkcs11/_pkcs11.pyx", line 726, in pkcs11._pkcs11.Object.__getitem__
  File "pkcs11/_utils.pyx", line 11, in pkcs11._pkcs11.CK_BYTE_buffer
  File "stringsource", line 152, in View.MemoryView.array.__cinit__
OverflowError: Python int too large to convert to C ssize_t

Here is a part of the code I use:

with token.open(user_pin=*******) as session:
    pub, priv = session.generate_keypair(
        pkcs11.KeyType.RSA,
        self.key_size,
        private_template={
            pkcs11.Attribute.EXTRACTABLE: True,
            pkcs11.Attribute.SENSITIVE: False,
        },
    )

given that:
self.key_size = 2048

My config:
Python 3.9.2
Debian bullseye

Thank you.

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

No branches or pull requests

1 participant