1 /* Test for PKCS#11 calls. */
4 #include <security/cryptoki.h>
5 #include <security/pkcs11.h>
9 CK_RV ret
= C_Initialize(NULL
);
11 fprintf(stderr
, "Initialize: %lu\n", ret
);
16 ret
= C_GetSlotList(0, NULL
, &slot_count
);
18 fprintf(stderr
, "GetSlotList(NULL): %lu\n", ret
);
22 CK_SLOT_ID_PTR slots
= malloc(slot_count
* sizeof(CK_SLOT_ID
));
24 fprintf(stderr
, "malloc(slots)\n");
28 ret
= C_GetSlotList(0, slots
, &slot_count
);
30 fprintf(stderr
, "GetSlotList(slots): %lu\n", ret
);
35 for (i
= 0; i
< slot_count
; i
++) {
36 CK_SLOT_ID slot_id
= slots
[i
];
39 ret
= C_GetMechanismList(slot_id
, NULL
, &mech_count
);
41 fprintf(stderr
, "GetMechanismList(NULL): %lu\n", ret
);
45 CK_MECHANISM_TYPE_PTR mechs
= malloc(mech_count
* sizeof(CK_MECHANISM_TYPE
));
47 fprintf(stderr
, "malloc(mechs)\n");
51 ret
= C_GetMechanismList(slot_id
, mechs
, &mech_count
);
53 fprintf(stderr
, "GetMechanismList(mechs): %lu\n", ret
);