コード例 #1
0
        private void EstablishContext()
        {
            var platform = Environment.OSVersion.Platform;

            if (platform == PlatformID.Win32S || platform == PlatformID.Win32Windows || platform == PlatformID.Win32NT || platform == PlatformID.WinCE)
            {
                _context = Pcsc <WinSCard> .EstablishContext(SCardScope.User);
            }
            else
            {
                _context = Pcsc <PCSCliteAPI> .EstablishContext(SCardScope.User);
            }
        }
コード例 #2
0
        public static async Task<DesfireCard> SnapshotAsync(Pcsc.Desfire.AccessHandler handler) {

            Pcsc.Desfire.CardDetails cd = await handler.ReadCardDetailsAsync();

            // get the list of applications
            byte[][] __appIDs = await handler.GetApplicationIds();

            // Holder for the apps
            DesfireApplication[] t_apps = new DesfireApplication[__appIDs.Length];

            int appIdx = 0;

            foreach(byte[] __appID in __appIDs)
            {
                System.Diagnostics.Debug.WriteLine("ZaibatsuPass: Getting details on AID " + BitConverter.ToString(__appID));
                await handler.SelectApplicationAsync(__appID);
                System.Diagnostics.Debug.WriteLine("ZaibatsuPass: Getting Files for AID " + BitConverter.ToString(__appID));
                byte[] __fileIDs = await handler.getFiles(__appID);

                Desfire.File.DesfireFile[] t_files = new File.DesfireFile[__fileIDs.Length];
                int fileIdx = 0;
                foreach(byte __fileID in __fileIDs)
                {
                    System.Diagnostics.Debug.WriteLine("ZaibatsuPass: Get settings for file" + __fileID);
                    byte[] __settings = await handler.GetFileSettingsAsync(__fileID);
                    Desfire.File.Settings.DesfireFileSettings p_settings = Desfire.File.Settings.DesfireFileSettings.Parse(__settings);
                    System.Diagnostics.Debug.WriteLine("ZaibatsuPass: Get content of file " + __fileID);
                    byte[] __data = await handler.ReadDataAsync(__fileID);
                    if (__data != null)
                    {
                        Desfire.File.DesfireFile __tFile = Desfire.File.DesfireFile.parse(__fileID, p_settings, __data);
                        t_files[fileIdx] = __tFile;
                    }
                    else
                    {
                        t_files[fileIdx] = new File.InvalidFile(__fileID);
                    }
                    fileIdx++;
                }
                DesfireApplication __tApp = new DesfireApplication(__appID, t_files);
                t_apps[appIdx] = __tApp;
                appIdx++;
            }

            DesfireCard __tCard = new DesfireCard(t_apps);
            __tCard.cardDetails = cd;
            return __tCard;
            
        }
コード例 #3
0
 static void Main(string[] args)
 {
     using (var context = Pcsc <WinSCard> .EstablishContext(SCardScope.User))
     {
         Console.WriteLine(context.IsEstablished);
         context.Validate();
         context.Release();
         Console.WriteLine(context.IsEstablished);
         try
         {
             context.Validate();
         }
         catch (PcscException ex)
         {
             Console.WriteLine($"0x{ex.NativeErrorCode:X8}: {ex.Message}");
         }
     }
     Console.WriteLine("Hello World!");
 }
コード例 #4
0
        public PcscContext EstablishContext()
        {
            if (_context != null)
            {
                throw new ConnectionException(Constants.ErrorCodes.ContextExists);
            }

            var platform = Environment.OSVersion.Platform;

            if (
                platform == PlatformID.Win32S ||
                platform == PlatformID.Win32Windows ||
                platform == PlatformID.Win32NT ||
                platform == PlatformID.WinCE)
            {
                _context = Pcsc <WinSCard> .EstablishContext(SCardScope.User);
            }
            else
            {
                _context = Pcsc <PCSCliteAPI> .EstablishContext(SCardScope.User);
            }

            return(_context);
        }