Skip to content

Commit 049b374

Browse files
committed
Add more information about initialization arguments
1 parent 5d6bd76 commit 049b374

File tree

1 file changed

+9
-32
lines changed

1 file changed

+9
-32
lines changed

main.go

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -266,43 +266,12 @@ func processKMIP(pkcs1Interface any, pkcs11Function any, pkcs11InputParameters [
266266

267267
request := createKMIPRequest(pkcs1Interface, pkcs11Function, pkcs11InputParameters)
268268

269-
type kmipResult struct {
270-
payload kmip.OperationPayload
271-
err error
272-
}
273-
274-
// Begin channel
275-
276-
ch := make(chan kmipResult, 1)
277-
278-
go func() {
279-
resp, err := client.Request(context.Background(), request)
280-
ch <- kmipResult{payload: resp, err: err}
281-
}()
282-
283-
var res kmipResult
284-
select {
285-
case res = <-ch:
286-
// got it
287-
case <-time.After(30 * time.Second):
288-
fmt.Println("KMIP request timed out after 30 seconds")
289-
return nil, nil, C.CKR_DEVICE_ERROR
290-
}
291-
292-
if res.err != nil {
293-
fmt.Println("Failed processing KMIP payload:", res.err)
294-
return nil, nil, C.CKR_FUNCTION_FAILED
295-
}
296-
269+
response, err := client.Request(context.Background(), request)
297270
if err != nil {
298271
fmt.Println("Failed processing KMIP payload:", err)
299272
return nil, nil, C.CKR_FUNCTION_FAILED
300273
}
301274

302-
response := res.payload
303-
304-
// End channel
305-
306275
fields := interface{}(response).(*kmip.UnknownPayload).Fields
307276

308277
var fieldFunction *ttlv.Value
@@ -1641,6 +1610,14 @@ func C_GetTokenInfo(slotID C.CK_SLOT_ID, pInfo C.CK_TOKEN_INFO_PTR) C.CK_RV { //
16411610
func C_Initialize(pInitArgs C.CK_VOID_PTR /*pReserved C.CK_VOID_PTR (v1.0,v2.0)*/) C.CK_RV { // Since v1.0
16421611
fmt.Printf("Function called: C_Initialize(pInitArgs=%+v)\n", pInitArgs)
16431612

1613+
if pInitArgs != nil {
1614+
initializeArgumentsPointer := C.CK_C_INITIALIZE_ARGS_PTR(pInitArgs)
1615+
initializeArguments := unsafe.Slice(initializeArgumentsPointer, 1)[0]
1616+
fmt.Printf("PKCS#11 library initiated with: %+v\n", initializeArguments)
1617+
} else {
1618+
fmt.Println("PKCS#11 library initiated without arguments")
1619+
}
1620+
16441621
inBuffer := new(bytes.Buffer)
16451622
inBuffer.Write(EncodeByte(profileVersion))
16461623
inputParameters := inBuffer.Bytes()

0 commit comments

Comments
 (0)