public void _03_SingleThreadedInitializeTest()
{
if (Platform.UnmanagedLongSize != 4 || Platform.StructPackingSize != 0)
Assert.Inconclusive("Test cannot be executed on this platform");
CKR rv = CKR.CKR_OK;
using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath))
{
// PKCS#11 library needs to be initialized with C_Initialize method.
// If an application will not be accessing PKCS#11 library from multiple threads
// simultaneously, it can generally call C_Initialize with initArgs parameter set to null.
rv = pkcs11.C_Initialize(null);
if ((rv != CKR.CKR_OK) && (rv != CKR.CKR_CRYPTOKI_ALREADY_INITIALIZED))
Assert.Fail(rv.ToString());
// Do something interesting
// C_Finalize is called to indicate that an application is finished
// with the PKCS#11 library. It should be the last call made by an application.
rv = pkcs11.C_Finalize(IntPtr.Zero);
if (rv != CKR.CKR_OK)
Assert.Fail(rv.ToString());
}
}