(You will be prompted for SO PIN und User PIN. Don't mix them up)
Build and run pkcs11keypair
% go build pkcs11keypair.go
% ./pkcs11keypair
Using module /usr/lib/softhsm/libsofthsm.so, slot ID 0, user PIN 0000, key id '12345', key label 'some_key', rsa bit size 2048.
Wanted slot id 0 and got slot id 0.
HSM Info:
Manufacturer ID SoftHSM
Flags: 0
Library Description: Implementation of PKCS11
Library Version: {1 3}.
Key pair generated:
Public Key: 2
Private Key: 1
Verify that the keypair has been generated:
% pkcs11-tool --module ${HSM_MODULE} --login -O
Using slot 0 with a present token (0x0)
Public Key Object; RSA 2048 bits
label: some_key
ID: 3132333435
Usage: encrypt, verify, wrap
Private Key Object; RSA
label: some_key
Usage: decrypt, sign, unwrap