Exemple #1
0
/// Decrypt table 2
void CPaz::DecodeTable2()
{
	u32* table = GetTable();
	u32 value1 = 0;
	u32 value2 = 0;
	u32 table_ptr = 0;

	// Decrypt 72 byte table
	for (table_ptr = 0; table_ptr < 18;)
	{
		DecodeValue(&value1, &value2, table);

		table[table_ptr++] = value1;
		table[table_ptr++] = value2;
	}

	// Decrypt 4096 byte table
	for (size_t i = 0; i < 4; i++)
	{
		for (size_t j = 0; j < 128; j++)
		{
			DecodeValue(&value1, &value2, table);

			table[table_ptr++] = value1;
			table[table_ptr++] = value2;
		}
	}
}
Exemple #2
0
/// Decrypt table 2
void CPaz::DecodeTable2()
{
    DWORD* pdwTable = GetTable();
    DWORD dwValue1 = 0;
    DWORD dwValue2 = 0;
    DWORD dwTablePtr = 0;

    // Decrypt 72 byte table
    for (dwTablePtr = 0; dwTablePtr < 18;)
    {
        DecodeValue(&dwValue1, &dwValue2, pdwTable);

        pdwTable[dwTablePtr++] = dwValue1;
        pdwTable[dwTablePtr++] = dwValue2;
    }

    // Decrypt 4096 byte table
    for (DWORD i = 0; i < 4; i++)
    {
        for (DWORD j = 0; j < 128; j++)
        {
            DecodeValue(&dwValue1, &dwValue2, pdwTable);

            pdwTable[dwTablePtr++] = dwValue1;
            pdwTable[dwTablePtr++] = dwValue2;
        }
    }
}
Exemple #3
0
void CVerifyCertDialog::ParseDN_by_prefix(wxWindow* parent, std::list<wxString>& tokens, wxString prefix, const wxString& name, wxSizer* pSizer, bool decode /*=false*/)
{
	prefix += _T("=");
	int len = prefix.Length();

	wxString value;

	bool append = false;

	auto iter = tokens.begin();
	while (iter != tokens.end())
	{
		if (!append)
		{
			if (iter->Left(len) != prefix)
			{
				++iter;
				continue;
			}

			if (!value.empty())
				value += _T("\n");
		}
		else
		{
			append = false;
			value += _T(",");
		}

		value += iter->Mid(len);

		if (iter->Last() == '\\')
		{
			value.RemoveLast();
			append = true;
			len = 0;
		}

		auto remove = iter++;
		tokens.erase(remove);
	}

	if (decode)
		value = DecodeValue(value);

	if (!value.empty())
	{
		pSizer->Add(new wxStaticText(parent, wxID_ANY, name));
		pSizer->Add(new wxStaticText(parent, wxID_ANY, value));
	}
}
Exemple #4
0
static bool ReadBlock(JPEGCompressor *self,JPEGBlock *block,int comp)
{
	int dcindex=self->jpeg.scancomponents[comp].dcindex;
	int acindex=self->jpeg.scancomponents[comp].acindex;

	int dcmagnitude=ReadHuffmanCode(&self->bitstream,&self->dctables[dcindex]);
	if(dcmagnitude<0) return false;
	int dcremainder=ReadBitString(&self->bitstream,dcmagnitude);
	if(dcremainder<0) return false;

	int delta=DecodeValue(dcmagnitude,dcremainder);
	block->c[0]=self->predicted[comp]+delta;
	self->predicted[comp]+=delta;

	int coeff=1;
	while(coeff<64)
	{
		int val=ReadHuffmanCode(&self->bitstream,&self->actables[acindex]);
		if(val<0) return false;
		if(val==0x00) break;

		int zeroes=val>>4;
		int acmagnitude=val&0x0f;
		int acremainder=ReadBitString(&self->bitstream,acmagnitude);
		if(acremainder<0) return false;

		// TODO: range checks
		for(int i=0;i<zeroes;i++) block->c[coeff++]=0;
		block->c[coeff++]=DecodeValue(acmagnitude,acremainder);
	}

	for(int i=coeff;i<64;i++) block->c[i]=0;

	block->eob=coeff-1;

	return true;
}
Exemple #5
0
void CField::LoadFromFile(CBibReader *file)
{
	xString* tmp = xsNew();
	_TUCHAR c;
	int openpar = 0;
	BOOL quote = FALSE;
	BOOL squote = FALSE;
	BOOL escape = FALSE;
	while (file->Read(&c, sizeof(_TUCHAR))) {
		switch (c) {
			case 9:
			case _T(' '):
				if ((openpar || quote) && !xsIsEmpty(tmp) && xsRightChar(tmp) != _T(' ')) {						
					// always use spaces
					xsPut(tmp, _T(' '));
				}
				escape = FALSE;
				break;
			case _T('='):
				if (openpar || quote)
					// inside value
					xsPut(tmp, c);
				else {
					// outside value
					xsTerminate(tmp);
					m_Name = CString(xsValue(tmp));
					xsClear(tmp);
				}
				escape = FALSE;
				break;
			case _T('\\'):
				escape = !escape;
				xsPut(tmp, c);
				break;
			case _T('"'):
				if (!escape)
					quote = !quote;
				xsPut(tmp, c);
				escape = FALSE;
				break;
			case _T('\''):
				if (!escape)
					squote = !squote;
				xsPut(tmp, c);
				escape = FALSE;
				break;
			case _T('{'):
				if (openpar || quote)
					xsPut(tmp, c);
				openpar++;
				escape = FALSE;
				break;
			case _T('}'):
				if (openpar)
					openpar--;
				else {
					// the last field
					file->Seek(-1, CFile::current);
					goto leave;
				}
				if (openpar || quote)
					xsPut(tmp, c);
				if (!openpar && !quote) {
					xsTerminate(tmp);
					m_Value = DecodeValue(CString(xsValue(tmp)));
					xsClear(tmp);
				}
				escape = FALSE;
				break;
			case _T(','):
				if (!openpar && !quote) {
					if (m_Value.IsEmpty()) {
						xsTerminate(tmp);
						m_Value = DecodeValue(CString(xsValue(tmp)));
					}
					goto leave;
				} else
					xsPut(tmp, c);
				escape = FALSE;
				break;
			case 10:
			case 13:
				escape = FALSE;
				break;
			default:
				xsPut(tmp, c);
				escape = FALSE;
				break;
		}
	}
leave:
	xsDelete(tmp);
}