Ejemplo n.º 1
0
        /// <summary>
        /// Sector access conditions
        /// </summary>
        public async Task <AccessConditions> Access()
        {
            if (_Access == null)
            {
                Byte[] data = await GetData(GetTrailerBlockIndex());

                _Access = AccessBits.GetAccessConditions(data);
            }

            return(_Access);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// commit changes made to trailer datablock
        /// </summary>
        /// <remarks>may throw CardLoginException and CardWriteException</remarks>
        public async Task FlushTrailer(String keyA, String keyB)
        {
            DataBlock dataBlock = _DataBlocks[GetTrailerBlockIndex()];

            if (dataBlock == null)
            {
                return;
            }

            await SetKeyA(keyA);
            await SetKeyB(keyB);

            Byte[] data = AccessBits.CalculateAccessBits(await Access());
            Array.Copy(data, 0, dataBlock.Data, 6, 4);

            if (dataBlock.IsChanged)
            {
                await FlushDataBlock(dataBlock);
            }

            _Card.ActiveSector = -1;
        }