コード例 #1
0
        public static bool ICDownPublicCA(List <CaItem> caItemList)
        {
            bool result = false;

            if (caItemList.Count > 0)
            {
                byte[] bAllCA = new byte[1024 * 4];
                int    nAllCA = 0;

                TransResult eRet = TransResult.E_SUCC;
                foreach (CaItem item in caItemList)
                {
                    byte[] rid = new byte[item.cRid.Length + 3];
                    rid[0] = 0x9F;
                    rid[1] = 0x06;
                    rid[2] = (byte)item.cRid.Length;
                    Array.Copy(item.cRid, 0, rid, 3, item.cRid.Length);

                    byte[] index = new byte[item.cIndex.Length + 3];
                    index[0] = 0x9F;
                    index[1] = 0x22;
                    index[2] = (byte)item.cIndex.Length;
                    Array.Copy(item.cIndex, 0, index, 3, item.cIndex.Length);

                    CDownPublicCA dCA = new CDownPublicCA();
                    dCA.BField62 = new byte[rid.Length + index.Length];
                    Array.Copy(rid, dCA.BField62, rid.Length);
                    Array.Copy(index, 0, dCA.BField62, rid.Length, index.Length);
                    eRet = dCA.Communicate();
                    //Test
                    //eRet = TransResult.E_SUCC;
                    //string s = "9F0605A0000000039F220172DF05083230313030313031DF060101DF070101DF028190BD9F074D8F60501D2E87B3AB03DCA80C83AF9CE81372AD34B7FA639767E5E6B2491ADCAF943FA165D09AB25B4B8FF541E6D2D3B0B70705B105266751D27E8E56FD9D0974F67B3B2E84322DA7E56152A4E42CC63727EB160B2E5310DF125E74F55618FE8727B167B6456431CFDE80C025D0CB1DE7DDC3186B7314085C7CCA301C691F5577690FD2DE5FC62665CB163F0DDF0403010001DF03141ECF2EFE0B01FA7C94F3960056E748C8FF4F1D09";
                    //dCA.BCA = Utility.str2Bcd(s);
                    if (eRet != TransResult.E_SUCC)
                    {
                        break;
                    }

                    Array.Copy(dCA.BCA, 0, bAllCA, nAllCA, dCA.BCA.Length);
                    nAllCA += dCA.BCA.Length;
                    System.Threading.Thread.Sleep(2000);//四川版需要停顿
                }

                Log.Warn("IC卡公钥下载参数CDownPublicCA:Ret=" + eRet.ToString());
                if (eRet == TransResult.E_SUCC)
                {
                    Log.Info("IC卡公钥下载参数成功");
                    string caPath = Path.Combine(StartupPath, "pbocCA.txt");
                    result = CreateFile(caPath, bAllCA, nAllCA);
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: CQueryPublicCA.cs プロジェクト: radtek/RLPayment
        /// <summary>
        /// 同步下载IC卡公钥入口
        /// </summary>
        /// <returns></returns>
        public static bool ICPublicCAEntry()
        {
            //Log.Info("========开始下载IC卡公钥========");
            TotalCaItemList.Clear();
            bool           bResult   = false;
            byte           bContinue = 0x30;
            CQueryPublicCA qca       = new CQueryPublicCA();
            TransResult    ret       = qca.Communicate();

            if (ret == TransResult.E_SUCC)
            {
                bResult   = true;
                bContinue = qca.BField63;
                while ((ret == TransResult.E_SUCC) && (bContinue == 0x32))
                {
                    System.Threading.Thread.Sleep(2000);//四川版需要停顿
                    CQueryPublicCA qca2 = new CQueryPublicCA();
                    qca2.StrField62 = "1" + TotalCaItemList.Count.ToString().PadLeft(2, '0');
                    ret             = qca2.Communicate();
                    if (ret == TransResult.E_SUCC)
                    {
                        bContinue = qca2.BField63;
                    }
                    else
                    {
                        bResult = false;
                    }
                }
                if (bResult && TotalCaItemList.Count > 0)
                {
                    System.Threading.Thread.Sleep(2000);//四川版需要停顿
                    bResult = CDownPublicCA.ICDownPublicCA(TotalCaItemList);
                    if (bResult)
                    {
                        CEndPublicCA eca = new CEndPublicCA();
                        eca.Communicate();
                    }
                }
            }
            Log.Warn("IC卡公钥下载参数CQueryPublicCA:Ret=" + ret.ToString());
            //Log.Info("========结束下载IC卡公钥========");
            return(bResult);
        }