Ejemplo n.º 1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public SectorTrailer()
        {
            dbAcList = new DBCondition[] {
                new DBCondition(),
                new DBCondition(),
                new DBCondition(),
            };

            stAc = new STCondition();

            KeyA = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, };
            KeyB = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, };
        }
Ejemplo n.º 2
0
 /// <summary>
 /// SectorTrailer用のConditionBitsを取得
 /// </summary>
 /// <param name="ac">Access Conditoin</param>
 /// <returns>下位3BitにC1,C2,C3を格納</returns>
 private byte GetSTByte(STCondition ac)
 {
     //C1 C2 C3(Bitの並びが逆になっているので注意)
     //0 0 0
     if (ac.KeyA.Read == Grant.None &&
         ac.KeyA.Write == Grant.KeyA &&
         ac.AccessBits.Read == Grant.KeyA &&
         ac.AccessBits.Write == Grant.None &&
         ac.KeyB.Read == Grant.KeyA &&
         ac.KeyB.Write == Grant.KeyA)
     {
         return(0x00);
     }
     //0 1 0
     else if (ac.KeyA.Read == Grant.None &&
              ac.KeyA.Write == Grant.None &&
              ac.AccessBits.Read == Grant.KeyA &&
              ac.AccessBits.Write == Grant.None &&
              ac.KeyB.Read == Grant.KeyA &&
              ac.KeyB.Write == Grant.None)
     {
         return(0x02);
     }
     //1 0 0
     else if (ac.KeyA.Read == Grant.None &&
              ac.KeyA.Write == Grant.KeyB &&
              ac.AccessBits.Read == (Grant.KeyA | Grant.KeyB) &&
              ac.AccessBits.Write == Grant.None &&
              ac.KeyB.Read == Grant.None &&
              ac.KeyB.Write == Grant.KeyB)
     {
         return(0x01);
     }
     //1 1 0
     else if (ac.KeyA.Read == Grant.None &&
              ac.KeyA.Write == Grant.None &&
              ac.AccessBits.Read == (Grant.KeyA | Grant.KeyB) &&
              ac.AccessBits.Write == Grant.None &&
              ac.KeyB.Read == Grant.None &&
              ac.KeyB.Write == Grant.None)
     {
         return(0x03);
     }
     //0 0 1(Transport)
     else if (ac.KeyA.Read == Grant.None &&
              ac.KeyA.Write == Grant.KeyA &&
              ac.AccessBits.Read == Grant.KeyA &&
              ac.AccessBits.Write == Grant.KeyA &&
              ac.KeyB.Read == Grant.KeyA &&
              ac.KeyB.Write == Grant.KeyA)
     {
         return(0x04);
     }
     //0 1 1
     else if (ac.KeyA.Read == Grant.None &&
              ac.KeyA.Write == Grant.KeyB &&
              ac.AccessBits.Read == (Grant.KeyA | Grant.KeyB) &&
              ac.AccessBits.Write == Grant.KeyB &&
              ac.KeyB.Read == Grant.None &&
              ac.KeyB.Write == Grant.KeyB)
     {
         return(0x06);
     }
     //1 0 1
     else if (ac.KeyA.Read == Grant.None &&
              ac.KeyA.Write == Grant.None &&
              ac.AccessBits.Read == (Grant.KeyA | Grant.KeyB) &&
              ac.AccessBits.Write == Grant.KeyB &&
              ac.KeyB.Read == Grant.None &&
              ac.KeyB.Write == Grant.None)
     {
         return(0x05);
     }
     //1 1 1
     else if (ac.KeyA.Read == Grant.None &&
              ac.KeyA.Write == Grant.None &&
              ac.AccessBits.Read == (Grant.KeyA | Grant.KeyB) &&
              ac.AccessBits.Write == Grant.None &&
              ac.KeyB.Read == Grant.None &&
              ac.KeyB.Write == Grant.None)
     {
         return(0x07);
     }
     throw new NfcLibException(ApiErrorKind.APP_INVALID_ACCESS_CONDITION, 0);
 }