From the meigk/pkcs11 package. Is there any way to assign a negative value in the Login function as userType? Because the HSM model that I'm working with, supports one more additional role except for the following standard roles and I want to login with that role.
Standard roles:
CKU_SO uint = 0
CKU_USER uint = 1
CKU_CONTEXT_SPECIFIC uint = 2
Login function source code from https://github.com/miekg/pkcs11/
func (c *Ctx) Login(sh SessionHandle, userType uint, pin string) error {
p := C.CString(pin)
defer C.free(unsafe.Pointer(p))
e := C.Login(c.ctx, C.CK_SESSION_HANDLE(sh), C.CK_USER_TYPE(userType), p, C.CK_ULONG(len(pin)))
return toError(e)
}
In the C#. I have using the PKCS11Interop package and its login function also accepts only for the uint parameter as userType. But it can be done by using the unchecked keyword. So I can put the negative value in the Login function without an error.
Here is my sample code in C# using https://github.com/Pkcs11Interop
public enum SpecialRole
{
CU = -12345
}
session.Login(unchecked((CKU)SpecialRole.CU), Settings.CryptoUserPin);
Then, how can I do this in Go? Kindly suggest.