/// <summary>
        /// Obtains a list of managed struct sizes.
        /// </summary>
        /// <returns>List of managed struct sizes</returns>
        private List <ulong> GetManagedStructSizeList()
        {
            List <ulong> sizeList = new List <ulong>();

            if (Platform.UnmanagedLongSize == 4)
            {
                if (Platform.StructPackingSize == 0)
                {
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_ATTRIBUTE))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_C_INITIALIZE_ARGS))));
#if COREFX
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_INFO).GetTypeInfo().Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI40.CK_FUNCTION_LIST"))));
#else
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_INFO).Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI40.CK_FUNCTION_LIST"))));
#endif
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_MECHANISM))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_MECHANISM_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_SESSION_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_SLOT_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_TOKEN_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_VERSION))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_AES_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_AES_CTR_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_ARIA_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_CAMELLIA_CTR_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_CMS_SIG_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_DES_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_ECDH1_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_ECDH2_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_ECMQV_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_EXTRACT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_KEA_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_KEY_DERIVATION_STRING_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_KEY_WRAP_SET_OAEP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_KIP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_OTP_PARAM))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_OTP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_OTP_SIGNATURE_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_PBE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_PKCS5_PBKD2_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_RC2_CBC_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_RC2_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_RC2_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_RC5_CBC_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_RC5_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_RC5_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_RSA_PKCS_OAEP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_RSA_PKCS_PSS_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_SKIPJACK_PRIVATE_WRAP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_SKIPJACK_RELAYX_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_SSL3_KEY_MAT_OUT))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_SSL3_KEY_MAT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_SSL3_MASTER_KEY_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_SSL3_RANDOM_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_TLS_PRF_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_WTLS_KEY_MAT_OUT))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_WTLS_KEY_MAT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_WTLS_MASTER_KEY_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_WTLS_PRF_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_WTLS_RANDOM_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_X9_42_DH1_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_X9_42_DH2_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.MechanismParams.CK_X9_42_MQV_DERIVE_PARAMS))));
                }
                else
                {
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_ATTRIBUTE))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_C_INITIALIZE_ARGS))));
#if COREFX
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_INFO).GetTypeInfo().Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI41.CK_FUNCTION_LIST"))));
#else
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_INFO).Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI41.CK_FUNCTION_LIST"))));
#endif
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_MECHANISM))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_MECHANISM_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_SESSION_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_SLOT_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_TOKEN_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_VERSION))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_AES_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_AES_CTR_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_ARIA_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_CAMELLIA_CTR_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_CMS_SIG_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_DES_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_ECDH1_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_ECDH2_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_ECMQV_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_EXTRACT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_KEA_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_KEY_DERIVATION_STRING_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_KEY_WRAP_SET_OAEP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_KIP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_OTP_PARAM))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_OTP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_OTP_SIGNATURE_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_PBE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_PKCS5_PBKD2_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_RC2_CBC_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_RC2_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_RC2_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_RC5_CBC_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_RC5_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_RC5_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_RSA_PKCS_OAEP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_RSA_PKCS_PSS_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_SKIPJACK_PRIVATE_WRAP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_SKIPJACK_RELAYX_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_SSL3_KEY_MAT_OUT))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_SSL3_KEY_MAT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_SSL3_MASTER_KEY_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_SSL3_RANDOM_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_TLS_PRF_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_WTLS_KEY_MAT_OUT))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_WTLS_KEY_MAT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_WTLS_MASTER_KEY_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_WTLS_PRF_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_WTLS_RANDOM_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_X9_42_DH1_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_X9_42_DH2_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.MechanismParams.CK_X9_42_MQV_DERIVE_PARAMS))));
                }
            }
            else
            {
                if (Platform.StructPackingSize == 0)
                {
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_ATTRIBUTE))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_C_INITIALIZE_ARGS))));
#if COREFX
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_INFO).GetTypeInfo().Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI80.CK_FUNCTION_LIST"))));
#else
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_INFO).Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI80.CK_FUNCTION_LIST"))));
#endif
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_MECHANISM))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_MECHANISM_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_SESSION_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_SLOT_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_TOKEN_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_VERSION))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_AES_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_AES_CTR_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_ARIA_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_CAMELLIA_CTR_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_CMS_SIG_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_DES_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_ECDH1_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_ECDH2_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_ECMQV_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_EXTRACT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_KEA_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_KEY_DERIVATION_STRING_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_KEY_WRAP_SET_OAEP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_KIP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_OTP_PARAM))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_OTP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_OTP_SIGNATURE_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_PBE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_PKCS5_PBKD2_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_RC2_CBC_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_RC2_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_RC2_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_RC5_CBC_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_RC5_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_RC5_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_RSA_PKCS_OAEP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_RSA_PKCS_PSS_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_SKIPJACK_PRIVATE_WRAP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_SKIPJACK_RELAYX_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_SSL3_KEY_MAT_OUT))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_SSL3_KEY_MAT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_SSL3_MASTER_KEY_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_SSL3_RANDOM_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_TLS_PRF_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_WTLS_KEY_MAT_OUT))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_WTLS_KEY_MAT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_WTLS_MASTER_KEY_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_WTLS_PRF_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_WTLS_RANDOM_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_X9_42_DH1_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_X9_42_DH2_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.MechanismParams.CK_X9_42_MQV_DERIVE_PARAMS))));
                }
                else
                {
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_ATTRIBUTE))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_C_INITIALIZE_ARGS))));
#if COREFX
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_INFO).GetTypeInfo().Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI81.CK_FUNCTION_LIST"))));
#else
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_INFO).Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI81.CK_FUNCTION_LIST"))));
#endif
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_MECHANISM))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_MECHANISM_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_SESSION_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_SLOT_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_TOKEN_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_VERSION))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_AES_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_AES_CTR_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_ARIA_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_CAMELLIA_CTR_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_CMS_SIG_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_DES_CBC_ENCRYPT_DATA_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_ECDH1_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_ECDH2_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_ECMQV_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_EXTRACT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_KEA_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_KEY_DERIVATION_STRING_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_KEY_WRAP_SET_OAEP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_KIP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_OTP_PARAM))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_OTP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_OTP_SIGNATURE_INFO))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_PBE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_PKCS5_PBKD2_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_RC2_CBC_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_RC2_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_RC2_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_RC5_CBC_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_RC5_MAC_GENERAL_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_RC5_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_RSA_PKCS_OAEP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_RSA_PKCS_PSS_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_SKIPJACK_PRIVATE_WRAP_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_SKIPJACK_RELAYX_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_SSL3_KEY_MAT_OUT))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_SSL3_KEY_MAT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_SSL3_MASTER_KEY_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_SSL3_RANDOM_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_TLS_PRF_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_WTLS_KEY_MAT_OUT))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_WTLS_KEY_MAT_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_WTLS_MASTER_KEY_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_WTLS_PRF_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_WTLS_RANDOM_DATA))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_X9_42_DH1_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_X9_42_DH2_DERIVE_PARAMS))));
                    sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.MechanismParams.CK_X9_42_MQV_DERIVE_PARAMS))));
                }
            }

            return(sizeList);
        }
        public void _07_AttributeArrayAttributeTest()
        {
            Helpers.CheckPlatform();

            CK_ATTRIBUTE[] originalValue = new CK_ATTRIBUTE[2];
            originalValue[0] = CkaUtils.CreateAttribute(CKA.CKA_TOKEN, true);
            originalValue[1] = CkaUtils.CreateAttribute(CKA.CKA_PRIVATE, true);
            // Create attribute with attribute array value
            CK_ATTRIBUTE attr = CkaUtils.CreateAttribute(CKA.CKA_WRAP_TEMPLATE, originalValue);

            Assert.IsTrue(attr.type == ConvertUtils.UInt32FromCKA(CKA.CKA_WRAP_TEMPLATE));
            Assert.IsTrue(attr.value != IntPtr.Zero);
            Assert.IsTrue(attr.valueLen == ConvertUtils.UInt32FromInt32(UnmanagedMemory.SizeOf(typeof(CK_ATTRIBUTE)) * originalValue.Length));

            CK_ATTRIBUTE[] recoveredValue = null;
            // Read the value of attribute
            CkaUtils.ConvertValue(ref attr, out recoveredValue);
            Assert.IsTrue(originalValue.Length == recoveredValue.Length);
            for (int i = 0; i < recoveredValue.Length; i++)
            {
                Assert.IsTrue(originalValue[i].type == recoveredValue[i].type);
                Assert.IsTrue(originalValue[i].valueLen == recoveredValue[i].valueLen);

                bool originalBool = false;
                // Read the value of nested attribute
                CkaUtils.ConvertValue(ref originalValue[i], out originalBool);

                bool recoveredBool = true;
                // Read the value of nested attribute
                CkaUtils.ConvertValue(ref recoveredValue[i], out recoveredBool);
                Assert.IsTrue(originalBool == recoveredBool);

                // In this example there is the same pointer to unmanaged memory
                // in both originalValue and recoveredValue array therefore it
                // needs to be freed only once.
                Assert.IsTrue(originalValue[i].value == recoveredValue[i].value);
                // Free value of nested attributes
                UnmanagedMemory.Free(ref originalValue[i].value);
                originalValue[i].valueLen  = 0;
                recoveredValue[i].value    = IntPtr.Zero;
                recoveredValue[i].valueLen = 0;
            }

            // Free attribute value
            UnmanagedMemory.Free(ref attr.value);
            attr.valueLen = 0;
            Assert.IsTrue(attr.type == ConvertUtils.UInt32FromCKA(CKA.CKA_WRAP_TEMPLATE));
            Assert.IsTrue(attr.value == IntPtr.Zero);
            Assert.IsTrue(attr.valueLen == 0);

            // Create attribute with null attribute array value
            attr = CkaUtils.CreateAttribute(CKA.CKA_WRAP_TEMPLATE, (CK_ATTRIBUTE[])null);
            Assert.IsTrue(attr.type == ConvertUtils.UInt32FromCKA(CKA.CKA_WRAP_TEMPLATE));
            Assert.IsTrue(attr.value == IntPtr.Zero);
            Assert.IsTrue(attr.valueLen == 0);

            // Create attribute with empty attribute array value
            attr = CkaUtils.CreateAttribute(CKA.CKA_WRAP_TEMPLATE, new CK_ATTRIBUTE[0]);
            Assert.IsTrue(attr.type == ConvertUtils.UInt32FromCKA(CKA.CKA_WRAP_TEMPLATE));
            Assert.IsTrue(attr.value == IntPtr.Zero);
            Assert.IsTrue(attr.valueLen == 0);
        }
        /// <summary>
        /// Initializes a new instance of the CkWtlsMasterKeyDeriveParams class.
        /// </summary>
        /// <param name='digestMechanism'>Digest mechanism to be used (CKM)</param>
        /// <param name='randomInfo'>Client's and server's random data information</param>
        /// <param name='dh'>Set to false for CKM_WTLS_MASTER_KEY_DERIVE mechanism and to true for CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC mechanism</param>
        public CkWtlsMasterKeyDeriveParams(NativeULong digestMechanism, ICkWtlsRandomData randomInfo, bool dh)
        {
            if (randomInfo == null)
            {
                throw new ArgumentNullException("randomInfo");
            }

            // Keep reference to randomInfo so GC will not free it while this object exists
            _randomInfo = randomInfo;

            _lowLevelStruct.DigestMechanism = digestMechanism;
            _lowLevelStruct.RandomInfo      = (CK_WTLS_RANDOM_DATA)_randomInfo.ToMarshalableStructure();
            _lowLevelStruct.Version         = (dh) ? IntPtr.Zero : UnmanagedMemory.Allocate(UnmanagedMemory.SizeOf(typeof(CK_VERSION)));
        }
        /// <summary>
        /// Initializes a new instance of the CkSsl3MasterKeyDeriveParams class.
        /// </summary>
        /// <param name='randomInfo'>Client's and server's random data information</param>
        /// <param name='dh'>Set to false for CKM_SSL3_MASTER_KEY_DERIVE mechanism and to true for CKM_SSL3_MASTER_KEY_DERIVE_DH mechanism</param>
        public CkSsl3MasterKeyDeriveParams(CkSsl3RandomData randomInfo, bool dh)
        {
            if (randomInfo == null)
            {
                throw new ArgumentNullException("randomInfo");
            }

            // Keep reference to randomInfo so GC will not free it while this object exists
            _randomInfo = randomInfo;

            _lowLevelStruct.RandomInfo = (CK_SSL3_RANDOM_DATA)_randomInfo.ToLowLevelParams();
            _lowLevelStruct.Version    = (dh) ? IntPtr.Zero : UnmanagedMemory.Allocate(UnmanagedMemory.SizeOf(typeof(CK_VERSION)));
        }