Beispiel #1
0
        private List <Pkcs11MechanismInfo> ReadMechanisms()
        {
            List <Pkcs11MechanismInfo> mechanisms = new List <Pkcs11MechanismInfo>();

            foreach (CKM mechanism in _slot.GetMechanismList())
            {
                IMechanismInfo mechanismInfo = _slot.GetMechanismInfo(mechanism);
                mechanisms.Add(new Pkcs11MechanismInfo(mechanism, mechanismInfo));
            }

            return(mechanisms);
        }
Beispiel #2
0
        public void _01_BasicMechanismListAndInfoTest()
        {
            using (IPkcs11Library pkcs11Library = Settings.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType))
            {
                // Find first slot with token present
                ISlot slot = Helpers.GetUsableSlot(pkcs11Library);

                // Get supported mechanisms
                List <CKM> mechanisms = slot.GetMechanismList();

                Assert.IsTrue(mechanisms.Count > 0);

                // Analyze first supported mechanism
                IMechanismInfo mechanismInfo = slot.GetMechanismInfo(mechanisms[0]);

                // Do something interesting with mechanism info
                Assert.IsNotNull(mechanismInfo.MechanismFlags);
            }
        }