Skip to content

Instantly share code, notes, and snippets.

@gjyoung1974
Last active December 29, 2019 16:16
Show Gist options
  • Select an option

  • Save gjyoung1974/ef98e00ab3b4afc63b29e6665b00ee78 to your computer and use it in GitHub Desktop.

Select an option

Save gjyoung1974/ef98e00ab3b4afc63b29e6665b00ee78 to your computer and use it in GitHub Desktop.
Python Generate RSA via PKCS11
import pkcs11
# Load the library & select the token
lib = pkcs11.lib("/usr/local/lib/softhsm/libsofthsm2.so")
token = lib.get_token(token_label='root')
# Open a session on our token
with token.open(user_pin='1234') as session:
# Generate an RSA keypair in this session
pub, priv = session.generate_keypair(pkcs11.KeyType.RSA, 2048)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment