Last active
December 29, 2019 16:16
-
-
Save gjyoung1974/ef98e00ab3b4afc63b29e6665b00ee78 to your computer and use it in GitHub Desktop.
Python Generate RSA via PKCS11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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