Pykcs11 - how to create only RSA public key (NOT key pair) from modulus and exponent

13 hours ago 1
ARTICLE AD BOX

I tried to ctreate a public key (RSA) using template from the sample - link below with additions (added modulus, as tuple, data len and exponent changed).

https://github.com/LudovicRousseau/PyKCS11/blob/master/samples/generate.py

key_id = (0x22,) pubTemplate = [ (PyKCS11.CKA_CLASS, PyKCS11.CKO_PUBLIC_KEY), (PyKCS11.CKA_TOKEN, PyKCS11.CK_TRUE), (PyKCS11.CKA_PRIVATE, PyKCS11.CK_FALSE), (PyKCS11.CKA_MODULUS_BITS, 0x0800), (PyKCS11.CKA_MODULUS, modulus_tuple), (PyKCS11.CKA_PUBLIC_EXPONENT, (0x03,)), (PyKCS11.CKA_ENCRYPT, PyKCS11.CK_TRUE), (PyKCS11.CKA_VERIFY, PyKCS11.CK_TRUE), (PyKCS11.CKA_VERIFY_RECOVER, PyKCS11.CK_TRUE), (PyKCS11.CKA_WRAP, PyKCS11.CK_TRUE), (PyKCS11.CKA_LABEL, "My Public Key"), (PyKCS11.CKA_ID, key_id), ]

session.createObject(pubTemplate) returns CKR_TEMPLATE_UNCOMPLETE

Needed to encrypt only by public key provided. The slot is new and completely empty - created for testing. Any advice? I suspect, that key_id should bne other, but which exactly?

Read Entire Article