28 {
29 if (argc != 2) {
30 fprintf(stderr, "usage: p11 /path/to/yubihsm_pkcs11/module\n");
31 exit(EXIT_FAILURE);
32 }
33
34 CK_C_GetFunctionList
fn;
35 void *handle = dlopen(
argv[1], RTLD_NOW | RTLD_GLOBAL);
36 assert(handle != NULL);
37
38 *(void **) (&fn) = dlsym(handle, "C_GetFunctionList");
39 assert(fn != NULL);
40
44
47
52
53 const char *password = "0001password";
57
60 CK_BYTE exponent[] = {0x00, 0x1, 0x0, 0x1};
64
68 {
CKA_SIGN, &ck_false,
sizeof(ck_false)},
70 {
CKA_WRAP, &ck_true,
sizeof(ck_true)},
81 };
83 sizeof(publicKeyTemplate) / sizeof(publicKeyTemplate[0]);
84
88 {
CKA_SIGN, &ck_true,
sizeof(ck_true)},
90 {
CKA_WRAP, &ck_false,
sizeof(ck_false)},
99 };
101 sizeof(privateKeyTemplate) / sizeof(privateKeyTemplate[0]);
102
103 CK_OBJECT_HANDLE publicKey, privateKey;
106 publicKeyAttributeCount, privateKeyTemplate,
107 privateKeyAttributeCount, &publicKey, &privateKey);
109
112
115
116 return 0;
117}
CK_SESSION_HANDLE session
unsigned long int CK_ULONG
#define CKA_PUBLIC_EXPONENT
#define CKM_RSA_PKCS_KEY_PAIR_GEN
#define CKF_SERIAL_SESSION
CK_UTF8CHAR * CK_UTF8CHAR_PTR
CK_C_OpenSession C_OpenSession
CK_C_GenerateKeyPair C_GenerateKeyPair
CK_C_Initialize C_Initialize