Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / solaris / pkcs11.c
blob9fed347995860a3111bdf5321cc9a876c9266ace
1 /* Test for PKCS#11 calls. */
3 #include <stdio.h>
4 #include <security/cryptoki.h>
5 #include <security/pkcs11.h>
7 int main(void)
9 CK_RV ret = C_Initialize(NULL);
10 if (ret != CKR_OK) {
11 fprintf(stderr, "Initialize: %lu\n", ret);
12 return 1;
15 CK_ULONG slot_count;
16 ret = C_GetSlotList(0, NULL, &slot_count);
17 if (ret != CKR_OK) {
18 fprintf(stderr, "GetSlotList(NULL): %lu\n", ret);
19 return 1;
22 CK_SLOT_ID_PTR slots = malloc(slot_count * sizeof(CK_SLOT_ID));
23 if (slots == NULL) {
24 fprintf(stderr, "malloc(slots)\n");
25 return 1;
28 ret = C_GetSlotList(0, slots, &slot_count);
29 if (ret != CKR_OK) {
30 fprintf(stderr, "GetSlotList(slots): %lu\n", ret);
31 return 1;
34 CK_ULONG i;
35 for (i = 0; i < slot_count; i++) {
36 CK_SLOT_ID slot_id = slots[i];
38 CK_ULONG mech_count;
39 ret = C_GetMechanismList(slot_id, NULL, &mech_count);
40 if (ret != CKR_OK) {
41 fprintf(stderr, "GetMechanismList(NULL): %lu\n", ret);
42 return 1;
45 CK_MECHANISM_TYPE_PTR mechs = malloc(mech_count * sizeof(CK_MECHANISM_TYPE));
46 if (slots == NULL) {
47 fprintf(stderr, "malloc(mechs)\n");
48 return 1;
51 ret = C_GetMechanismList(slot_id, mechs, &mech_count);
52 if (ret != CKR_OK) {
53 fprintf(stderr, "GetMechanismList(mechs): %lu\n", ret);
54 return 1;
57 free(mechs);
60 free(slots);
61 C_Finalize(NULL_PTR);
62 return 0;