/// <summary> /// Creates slot with specified handle /// </summary> /// <param name="factories">Factories to be used by Developer and Pkcs11Interop library</param> /// <param name="pkcs11Library">Low level PKCS#11 wrapper</param> /// <param name="slotId">PKCS#11 handle of slot</param> public ISlot Create(Pkcs11InteropFactories factories, LowLevelPkcs11Library pkcs11Library, ulong slotId) { LowLevelAPI41.MockPkcs11Library p11 = pkcs11Library as LowLevelAPI41.MockPkcs11Library; if (p11 == null) { throw new ArgumentException("Incorrect type of low level PKCS#11 wrapper"); } return(new MockSlot(factories, p11, slotId)); }
/// <summary> /// Loads and initializes PCKS#11 library /// </summary> /// <param name="factories">Factories to be used by Developer and Pkcs11Interop library</param> /// <param name="libraryPath">Library name or path</param> /// <param name="appType">Type of application that will be using PKCS#11 library</param> /// <param name="initType">Source of PKCS#11 function pointers</param> public MockPkcs11Library(Pkcs11InteropFactories factories, string libraryPath, AppType appType, InitType initType) : base(factories, libraryPath) { _logger.Debug("MockPkcs11Library({0})::ctor2", _libraryPath); try { _logger.Info("Loading PKCS#11 library {0}", _libraryPath); _pkcs11Library = new LowLevelAPI41.MockPkcs11Library(libraryPath, (initType == InitType.WithFunctionList)); Initialize(appType); } catch { if (_pkcs11Library != null) { _logger.Info("Unloading PKCS#11 library {0}", _libraryPath); _pkcs11Library.Dispose(); _pkcs11Library = null; } throw; } }
/// <summary> /// Initializes new instance of Slot class /// </summary> /// <param name="factories">Factories to be used by Developer and Pkcs11Interop library</param> /// <param name="pkcs11Library">Low level PKCS#11 wrapper</param> /// <param name="slotId">PKCS#11 handle of slot</param> internal MockSlot(Pkcs11InteropFactories factories, LowLevelAPI41.MockPkcs11Library pkcs11Library, ulong slotId) : base(factories, pkcs11Library, slotId) { _logger.Debug("MockSlot({0})::ctor", _slotId); }