-
Notifications
You must be signed in to change notification settings - Fork 0
/
initialize.go
42 lines (38 loc) · 905 Bytes
/
initialize.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package certex
/*
#include <stdlib.h>
#include <dlfcn.h>
#include <unistd.h>
#include <stdio.h>
#include "./headers/cryptoki.h"
#include "./headers/pkcs11def.h"
#include "./headers/pkcs11t.h"
#include "./headers/PKICertexHSM.h"
CK_RV initialize(CK_FUNCTION_LIST_PTR fl, CK_C_INITIALIZE_ARGS_PTR pInitArgs) {
return (*fl->C_Initialize)((CK_VOID_PTR)(pInitArgs));
}
*/
import "C"
import (
"fmt"
)
func initialize(p C.CK_FUNCTION_LIST_PTR) error {
// var cm C.CK_CREATEMUTEX
// var dm C.CK_DESTROYMUTEX
// var lm C.CK_LOCKMUTEX
// var um C.CK_UNLOCKMUTEX
// var pr C.CK_VOID_PTR
args := C.CK_C_INITIALIZE_ARGS{
// CreateMutex: cm,
// DestroyMutex: dm,
// LockMutex: lm,
// UnlockMutex: um,
// pReserved: pr,
flags: C.CKF_OS_LOCKING_OK,
}
rv := C.initialize(p, &args)
if rv != C.CKR_OK {
return fmt.Errorf("initialize: 0x%08x : %s", rv, returnValues[rv])
}
return nil
}