コード例 #1
0
	void Wiegand37WithFacilityFormat::setLinearDataWithoutParity(const void* data, size_t dataLengthBytes)
	{
		unsigned int pos = 1;

		setFacilityCode((unsigned short)revertField(data, dataLengthBytes, &pos, 16));
		setUid(revertField(data, dataLengthBytes, &pos, 19));
	}
コード例 #2
0
    unsigned char FASCN200BitFormat::calculateLRC(const void* data, unsigned int datalenBits) const
    {
        unsigned char lrc = 0x00;

        size_t datalenBytes = (datalenBits + 7) / 8;

        if (datalenBytes > 1)
        {
            unsigned int pos = 0;

            while (pos < datalenBits)
            {
                unsigned char c = (unsigned char)revertField(data, datalenBytes, &pos, 4);
                lrc ^= c;
            }
        }

        return lrc;
    }
コード例 #3
0
    void FASCN200BitFormat::setLinearData(const void* data, size_t dataLengthBytes)
    {
        unsigned int pos = 0;
        unsigned char c;

        if (dataLengthBytes * 8 < getDataLength())
        {
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, "Data length too small.");
        }

        c = (unsigned char)revertField(data, dataLengthBytes, &pos, 4);
        if (c != FASCN_SS)
        {
            char tmpmsg[64];
            sprintf(tmpmsg, "The FASC-N Start Sentinel doesn't match (%x).", c);
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, tmpmsg);
        }

        setAgencyCode((unsigned short)revertField(data, dataLengthBytes, &pos, 16));
        c = (unsigned char)revertField(data, dataLengthBytes, &pos, 4);
        if (c != FASCN_FS)
        {
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, "The FASC-N Field Separator doesn't match after the Agency Code.");
        }

        setSystemCode((unsigned short)revertField(data, dataLengthBytes, &pos, 16));
        c = (unsigned char)revertField(data, dataLengthBytes, &pos, 4);
        if (c != FASCN_FS)
        {
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, "The FASC-N Field Separator doesn't match after the System Code.");
        }

        setUid(revertField(data, dataLengthBytes, &pos, 24));
        c = (unsigned char)revertField(data, dataLengthBytes, &pos, 4);
        if (c != FASCN_FS)
        {
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, "The FASC-N Field Separator doesn't match after the Credential.");
        }

        setSerieCode((unsigned char)revertField(data, dataLengthBytes, &pos, 4));
        c = (unsigned char)revertField(data, dataLengthBytes, &pos, 4);
        if (c != FASCN_FS)
        {
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, "The FASC-N Field Separator doesn't match after the Credential Series.");
        }

        setCredentialCode((unsigned char)revertField(data, dataLengthBytes, &pos, 4));
        c = (unsigned char)revertField(data, dataLengthBytes, &pos, 4);
        if (c != FASCN_FS)
        {
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, "The FASC-N Field Separator doesn't match after the Credential Issue.");
        }

        setPersonIdentifier(revertField(data, dataLengthBytes, &pos, 40));

        setOrganizationalCategory((FASCNOrganizationalCategory)revertField(data, dataLengthBytes, &pos, 4));
        setOrganizationalIdentifier((unsigned char)revertField(data, dataLengthBytes, &pos, 16));
        setPOACategory((FASCNPOAssociationCategory)revertField(data, dataLengthBytes, &pos, 4));

        c = (unsigned char)revertField(data, dataLengthBytes, &pos, 4);
        if (c != FASCN_ES)
        {
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, "The End Sentinel doesn't match.");
        }

        unsigned char lrc = calculateLRC(data, pos);
        c = (unsigned char)revertField(data, dataLengthBytes, &pos, 4);

        if (c != lrc)
        {
            THROW_EXCEPTION_WITH_LOG(LibLogicalAccessException, "The FASC-N LRC seems wrong.");
        }
    }
コード例 #4
0
    void Wiegand37Format::setLinearDataWithoutParity(const void* data, size_t dataLengthBytes)
    {
        unsigned int pos = 1;

        setUid(revertField(data, dataLengthBytes, &pos, 35));
    }