//public static DeviceManager deviceManager = new DeviceManager(false);

        public SmartCardTest()
        {
            List <CardInfo> lst        = SmartCardUtils.GetReaderNames();
            String          readerName = lst[0].ReaderName;

            smartCard = new SmartCard(readerName, "5304");
        }
        public BlobStoreTest()
        {
            LoggerUtils.setupLoggers();
            List <CardInfo> lst        = SmartCardUtils.GetReaderNames();
            String          readerName = lst[0].ReaderName;

            smartCard = new SmartCard(readerName, pin);
            CardMode mode = this.smartCard.GetCardMode();

            if (mode != CardMode.ROOT)
            {
                this.smartCard.SetCardInRootMode();
            }
            BigInteger.TryParse(pString, out p);
            BigInteger.TryParse(qString, out q);
            KeyPair pq  = new KeyPair(p, q);
            String  puk = this.smartCard.InitDevice(pq, pin);
        }
Exemple #3
0
        /// <summary>
        /// Constructs a new SampleDevice instance.
        /// </summary>
        /// <param name="gq">The group construction.</param>
        /// <param name="gd">The device generator.</param>
        public SmartCardDevice(GroupDescription gq, GroupElement gd, SmartCardParams smartCardParam)
        {
            pin      = smartCardParam.pin;
            credID   = smartCardParam.credID;
            groupID  = smartCardParam.groupID;
            proverID = smartCardParam.proverID;

            // As SnartCardDevice do not provide a way to lookup card readr names
            // we provide a small potion of logic to lookup a card and cardreader
            List <CardInfo> cardInfoList = SmartCardUtils.GetReaderNames();
            // loop until we find a card with the status of "working mode". if none found
            // throw
            String readerName = null;

            foreach (CardInfo i in cardInfoList)
            {
                if (i.CardMode == (int)CardMode.WORKING)
                {
                    readerName = i.ReaderName;
                    break;
                }
            }
            if (readerName == null)
            {
                // TODO create a better exception
                throw new Exception("No card founds in working mode");
            }
            bool doTimeProfile = ParseConfigManager.DoTimeProfile();

            this.device = new SmartCard(readerName, pin, doTimeProfile);
            // As the group and generator is set from the java init service we will only verify
            // TODO fix to see that group 0 is set on the hw smartcard.
            //if (!this.device.IsGeneratorSet(groupID))
            //{
            // TODO Find better exception
            // throw new Exception("No generator is set on the card to use this group");
            //}

            this.Gq = gq;
            this.Gd = gd;
        }
        public HardwareSmartCardTest()
        {
            List <CardInfo> lst = SmartCardUtils.GetReaderNames();

            Assert.IsNotNull(lst);
            Assert.IsTrue(lst.Count > 0);
            String readerName = lst[0].ReaderName;

            BigInteger.TryParse(this.pString, out p);
            BigInteger.TryParse(this.qString, out q);

            smartCard = new SmartCard(readerName, "1234");
            try
            {
                this.smartCard.SetVirginMode();
            }
            catch (Exception)
            {
                Assert.Fail("Set the card into virgin mode failed");
            }
        }