/// <summary>
        /// Creates slot with specified handle
        /// </summary>
        /// <param name="factories">Factories to be used by Developer and Pkcs11Interop library</param>
        /// <param name="pkcs11">Low level PKCS#11 wrapper</param>
        /// <param name="slotId">PKCS#11 handle of slot</param>
        public ISlot CreateSlot(Pkcs11InteropFactories factories, LowLevelPkcs11 pkcs11, ulong slotId)
        {
            LowLevelAPI80.MockPkcs11 p11 = pkcs11 as LowLevelAPI80.MockPkcs11;
            if (p11 == null)
            {
                throw new ArgumentException("Incorrect type of low level PKCS#11 wrapper");
            }

            return(new MockSlot(factories, p11, slotId));
        }
Esempio n. 2
0
        /// <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 MockPkcs11(Pkcs11Factories factories, string libraryPath, AppType appType, InitType initType)
            : base(factories, libraryPath)
        {
            _logger.Debug("MockPkcs11({0})::ctor2", _libraryPath);

            try
            {
                _logger.Info("Loading PKCS#11 library {0}", _libraryPath);
                _p11 = new LowLevelAPI80.MockPkcs11(libraryPath, (initType == InitType.WithFunctionList));
                Initialize(appType);
            }
            catch
            {
                if (_p11 != null)
                {
                    _logger.Info("Unloading PKCS#11 library {0}", _libraryPath);
                    _p11.Dispose();
                    _p11 = null;
                }
                throw;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes new instance of Slot class
 /// </summary>
 /// <param name="factories">Factories to be used by Developer and Pkcs11Interop library</param>
 /// <param name="pkcs11">Low level PKCS#11 wrapper</param>
 /// <param name="slotId">PKCS#11 handle of slot</param>
 internal MockSlot(Pkcs11InteropFactories factories, LowLevelAPI80.MockPkcs11 pkcs11, ulong slotId)
     : base(factories, pkcs11, slotId)
 {
     _logger.Debug("MockSlot({0})::ctor", _slotId);
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes new instance of Session class
 /// </summary>
 /// <param name="factories">Factories to be used by Developer and Pkcs11Interop library</param>
 /// <param name="pkcs11">Low level PKCS#11 wrapper</param>
 /// <param name="sessionId">PKCS#11 handle of session</param>
 internal MockSession(Pkcs11InteropFactories factories, LowLevelAPI80.MockPkcs11 pkcs11, ulong sessionId)
     : base(factories, pkcs11, sessionId)
 {
     _logger.Debug("MockSession({0})::ctor", _sessionId);
 }