/// <summary>
        /// Ejects token from slot.
        /// This method should be used only for testing purposes with PKCS11-MOCK module.
        /// </summary>
        /// <param name="pkcs11">Instance of the extended class</param>
        /// <param name="slotId">The ID of the token's slot</param>
        /// <returns>CKR_CRYPTOKI_NOT_INITIALIZED, CKR_SLOT_ID_INVALID, CKR_OK</returns>
        public static CKR C_EjectToken(this LLA81.Pkcs11 pkcs11, ulong slotId)
        {
            if (pkcs11.Disposed)
            {
                throw new ObjectDisposedException(pkcs11.GetType().FullName);
            }

            Delegates.C_EjectToken8x cEjectToken = null;

            if (pkcs11.LibraryHandle != IntPtr.Zero)
            {
                IntPtr cEjectTokenPtr = UnmanagedLibrary.GetFunctionPointer(pkcs11.LibraryHandle, "C_EjectToken");
                cEjectToken = UnmanagedLibrary.GetDelegateForFunctionPointer <Delegates.C_EjectToken8x>(cEjectTokenPtr);
            }
            else
            {
                cEjectToken = NativeMethods.C_EjectToken8x;
            }

            ulong rv = cEjectToken(slotId);

            return((CKR)Convert.ToUInt32(rv));
        }
Пример #2
0
        /// <summary>
        /// Obtains a list of unmanaged struct sizes.
        /// This method should be used only for testing purposes with PKCS11-MOCK module.
        /// </summary>
        /// <param name="pkcs11">Instance of the extended class</param>
        /// <param name="sizeList">
        /// If set to null then the number of sizes is returned in "count" parameter, without actually returning a list of sizes.
        /// If not set to null then "count" parameter must contain the lenght of sizeList array and size list is returned in "sizeList" parameter.
        /// </param>
        /// <param name="count">Location that receives the number of sizes</param>
        /// <returns>CKR_ARGUMENTS_BAD, CKR_BUFFER_TOO_SMALL, CKR_OK</returns>
        public static CKR C_GetUnmanagedStructSizeList(this LLA81.Pkcs11 pkcs11, ulong[] sizeList, ref ulong count)
        {
            if (pkcs11.Disposed)
            {
                throw new ObjectDisposedException(pkcs11.GetType().FullName);
            }

            Delegates.C_GetUnmanagedStructSizeListDelegate8x cGetUnmanagedStructSizeList = null;

            if (pkcs11.LibraryHandle != IntPtr.Zero)
            {
                IntPtr cGetUnmanagedStructSizeListPtr = UnmanagedLibrary.GetFunctionPointer(pkcs11.LibraryHandle, "C_GetUnmanagedStructSizeList");
                cGetUnmanagedStructSizeList = UnmanagedLibrary.GetDelegateForFunctionPointer <Delegates.C_GetUnmanagedStructSizeListDelegate8x>(cGetUnmanagedStructSizeListPtr);
            }
            else
            {
                cGetUnmanagedStructSizeList = NativeMethods.C_GetUnmanagedStructSizeList8x;
            }

            ulong rv = cGetUnmanagedStructSizeList(sizeList, ref count);

            return((CKR)Convert.ToUInt32(rv));
        }