Example #1
0
static void
cubehash_close(sph_cubehash_context *sc, unsigned ub, unsigned n,
	void *dst, size_t out_size_w32)
{
	unsigned char *buf, *out;
	size_t ptr;
	unsigned z;
	int i;
	DECL_STATE

	buf = sc->buf;
	ptr = sc->ptr;
	z = 0x80 >> n;
	buf[ptr ++] = ((ub & -z) | z) & 0xFF;
	memset(buf + ptr, 0, (sizeof sc->buf) - ptr);
	READ_STATE(sc);
	INPUT_BLOCK;
	for (i = 0; i < 11; i ++) {
		SIXTEEN_ROUNDS;
		if (i == 0)
			xv ^= SPH_C32(1);
	}
	WRITE_STATE(sc);
	out = (unsigned char *)dst;
	for (z = 0; z < out_size_w32; z ++)
		sph_enc32le(out + (z << 2), sc->state[z]);
}
static void
shabal_core(void *cc, const unsigned char *data, size_t len)
{
    sph_shabal_context *sc;
    unsigned char *buf;
    size_t ptr;
    DECL_STATE

    sc = cc;
    buf = sc->buf;
    ptr = sc->ptr;

    /*
     * We do not want to copy the state to local variables if the
     * amount of data is less than what is needed to complete the
     * current block. Note that it is anyway suboptimal to call
     * this method many times for small chunks of data.
     */
    if (len < (sizeof sc->buf) - ptr) {
        memcpy(buf + ptr, data, len);
        ptr += len;
        sc->ptr = ptr;
        return;
    }

    READ_STATE(sc);
    while (len > 0) {
        size_t clen;

        clen = (sizeof sc->buf) - ptr;
        if (clen > len)
            clen = len;
        memcpy(buf + ptr, data, clen);
        ptr += clen;
        data += clen;
        len -= clen;
        if (ptr == sizeof sc->buf) {
            DECODE_BLOCK;
            INPUT_BLOCK_ADD;
            XOR_W;
            APPLY_P;
            INPUT_BLOCK_SUB;
            SWAP_BC;
            INCR_W;
            ptr = 0;
        }
    }
    WRITE_STATE(sc);
    sc->ptr = ptr;
}
Example #3
0
static void
jh_core(sph_jh_context *sc, const void *data, size_t len)
{
	unsigned char *buf;
	size_t ptr;
	DECL_STATE

	buf = sc->buf;
	ptr = sc->ptr;

	if (len < (sizeof sc->buf) - ptr) {
		memcpy(buf + ptr, data, len);
		ptr += len;
		sc->ptr = ptr;
		return;
	}

	READ_STATE(sc);
	while (len > 0) {
		size_t clen;

		clen = (sizeof sc->buf) - ptr;
		if (clen > len)
			clen = len;
		memcpy(buf + ptr, data, clen);
		ptr += clen;
		data = (const unsigned char *)data + clen;
		len -= clen;
		if (ptr == sizeof sc->buf) {
			INPUT_BUF1;
			E8;
			INPUT_BUF2;
#if SPH_64
			sc->block_count ++;
#else
			if ((sc->block_count_low = SPH_T32(
				sc->block_count_low + 1)) == 0)
				sc->block_count_high ++;
#endif
			ptr = 0;
		}
	}
	WRITE_STATE(sc);
	sc->ptr = ptr;
}
Example #4
0
static void
cubehash_core(sph_cubehash_context *sc, const void *data, size_t len)
{
	unsigned char *buf;
	size_t ptr;
	DECL_STATE

	buf = sc->buf;
	ptr = sc->ptr;
	if (len < (sizeof sc->buf) - ptr) {
		memcpy(buf + ptr, data, len);
		ptr += len;
		sc->ptr = ptr;
		return;
	}

	READ_STATE(sc);
	while (len > 0) {
		size_t clen;

		clen = (sizeof sc->buf) - ptr;
		if (clen > len)
			clen = len;
		memcpy(buf + ptr, data, clen);
		ptr += clen;
		data = (const unsigned char *)data + clen;
		len -= clen;
		if (ptr == sizeof sc->buf) {
			INPUT_BLOCK;
			SIXTEEN_ROUNDS;
			ptr = 0;
		}
	}
	WRITE_STATE(sc);
	sc->ptr = ptr;
}
static void
shabal_close(void *cc, unsigned ub, unsigned n, void *dst, unsigned size_words)
{
    sph_shabal_context *sc;
    unsigned char *buf;
    size_t ptr;
    int i;
    unsigned z;
    union {
        unsigned char tmp_out[64];
        sph_u32 dummy;
    } u;
    size_t out_len;
    DECL_STATE

    sc = cc;
    buf = sc->buf;
    ptr = sc->ptr;
    z = 0x80 >> n;
    buf[ptr] = ((ub & -z) | z) & 0xFF;
    memset(buf + ptr + 1, 0, (sizeof sc->buf) - (ptr + 1));
    READ_STATE(sc);
    DECODE_BLOCK;
    INPUT_BLOCK_ADD;
    XOR_W;
    APPLY_P;
    for (i = 0; i < 3; i ++) {
        SWAP_BC;
        XOR_W;
        APPLY_P;
    }

    /*
     * We just use our local variables; no need to go through
     * the state structure. In order to share some code, we
     * emit the relevant words into a temporary buffer, which
     * we finally copy into the destination array.
     */
    switch (size_words) {
    case 16:
        sph_enc32le_aligned(u.tmp_out +  0, B0);
        sph_enc32le_aligned(u.tmp_out +  4, B1);
        sph_enc32le_aligned(u.tmp_out +  8, B2);
        sph_enc32le_aligned(u.tmp_out + 12, B3);
    /* fall through */
    case 12:
        sph_enc32le_aligned(u.tmp_out + 16, B4);
        sph_enc32le_aligned(u.tmp_out + 20, B5);
        sph_enc32le_aligned(u.tmp_out + 24, B6);
        sph_enc32le_aligned(u.tmp_out + 28, B7);
    /* fall through */
    case 8:
        sph_enc32le_aligned(u.tmp_out + 32, B8);
    /* fall through */
    case 7:
        sph_enc32le_aligned(u.tmp_out + 36, B9);
    /* fall through */
    case 6:
        sph_enc32le_aligned(u.tmp_out + 40, BA);
        sph_enc32le_aligned(u.tmp_out + 44, BB);
        sph_enc32le_aligned(u.tmp_out + 48, BC);
        sph_enc32le_aligned(u.tmp_out + 52, BD);
        sph_enc32le_aligned(u.tmp_out + 56, BE);
        sph_enc32le_aligned(u.tmp_out + 60, BF);
        break;
    default:
        return;
    }
    out_len = size_words << 2;
    memcpy(dst, u.tmp_out + (sizeof u.tmp_out) - out_len, out_len);
    shabal_init(sc, size_words << 5);
}
Example #6
0
bool ObjectTable::SetTableData(void* pvTable, WCHAR* pwszSheetName, std::wstring* pstrDataName, BSTR bstrData)
{
#define READ_STATE( idx )															\
	if ( READ_STRING( bstrData, szTemp, 1024 ) )									\
		{																				\
		int nCnt = 0;																\
		char *pToken, *pNextToken;													\
																					\
		pToken = strtok_s( szTemp, ";", &pNextToken );								\
																					\
																							while ( NULL != pToken )													\
																									{																			\
			DWORD dwTemp = (DWORD)_atoi64( pToken );								\
																					\
			if ( dwTemp >= INVALID_BYTE )											\
						{																		\
				_ASSERTE( !"BYTE 타입의 데이타 값이 최대값 을 초과했습니다." );		\
						}																		\
						else																	\
			{																		\
				pObj->abyState[idx][nCnt] = (BYTE)dwTemp;							\
			}																		\
																					\
			nCnt++;																	\
																					\
			pToken = strtok_s( NULL, ";", &pNextToken );							\
																									}																			\
		}

	static char szTemp[1024];

	if (0 == wcscmp(pwszSheetName, L"Table_Data_KOR"))
	{
		sOBJECT_TBLDAT* pObj = (sOBJECT_TBLDAT*)pvTable;

		if (0 == wcscmp(pstrDataName->c_str(), L"Tblidx"))
		{
			pObj->tblidx = READ_DWORD(bstrData);
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Name"))
		{
			pObj->dwName = READ_DWORD(bstrData);
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Loc_X"))
		{
			pObj->vLoc.x = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Loc_Y"))
		{
			pObj->vLoc.y = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Loc_Z"))
		{
			pObj->vLoc.z = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Dir_X"))
		{
			pObj->vDir.x = READ_FLOAT(bstrData, pstrDataName->c_str(), 0.0f);
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Dir_Y"))
		{
			pObj->vDir.y = READ_FLOAT(bstrData, pstrDataName->c_str(), 0.0f);
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Dir_Z"))
		{
			pObj->vDir.z = READ_FLOAT(bstrData, pstrDataName->c_str(), 0.0f);
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Func"))
		{
			pObj->wFunction = (WORD)READ_BITFLAG(bstrData, 0);
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Min_X"))
		{
			pObj->vMin.x = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Min_Y"))
		{
			pObj->vMin.y = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Min_Z"))
		{
			pObj->vMin.z = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Max_X"))
		{
			pObj->vMax.x = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Max_Y"))
		{
			pObj->vMax.y = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Max_Z"))
		{
			pObj->vMax.z = READ_FLOAT(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"StateType"))
		{
			pObj->byStateType = READ_BYTE(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"DefMainState"))
		{
			pObj->byDefMainState = READ_BYTE(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"DefSubState"))
		{
			pObj->byDefSubState = READ_BYTE(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcsncmp(pstrDataName->c_str(), L"State", wcslen(L"State")))
		{
			bool bFound = false;
			WCHAR szBuffer[1024] = { 0x00, };

			for (int i = 0; i < DBO_MAX_OBJECT_STATE; i++)
			{
				swprintf(szBuffer, 1024, L"State%d", i);

				if (0 == wcscmp(pstrDataName->c_str(), szBuffer))
				{
					READ_STATE(i);
					bFound = true;
					break;
				}
			}

			if (false == bFound)
			{
				Table::CallErrorCallbackFunction(L"[File] : %s\n[Error] : Unknown field name found!(Field Name = %s)", m_wszXmlFileName, pstrDataName->c_str());
				return false;
			}
		}
		else if (0 == wcsncmp(pstrDataName->c_str(), L"Click_Sound", wcslen(L"Click_Sound")))
		{
			bool bFound = false;

			WCHAR szBuffer[1024] = { 0x00, };
			for (int i = 0; i < DBO_MAX_OBJECT_STATE; i++)
			{
				swprintf(szBuffer, 1024, L"Click_Sound%d", i);

				if (0 == wcscmp(pstrDataName->c_str(), szBuffer))
				{
					READ_STRING(bstrData, pObj->achClickSound[i], _countof(pObj->achClickSound[i]));
					bFound = true;
					break;
				}
			}

			if (false == bFound)
			{
				Table::CallErrorCallbackFunction(L"[File] : %s\n[Error] : Unknown field name found!(Field Name = %s)", m_wszXmlFileName, pstrDataName->c_str());
				return false;
			}
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Boundary_Distance"))
		{
			pObj->byBoundaryDistance = READ_BYTE(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"ModelName"))
		{
			CheckNegativeInvalid(pstrDataName->c_str(), bstrData);

			READ_STRING(bstrData, pObj->szModelName, _countof(pObj->szModelName));
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Note"))
		{
			// 기획 전용 필드
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Contents_Tblidx"))
		{
			pObj->contentsTblidx = READ_DWORD(bstrData);
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"Object_Direction_Index"))
		{
			pObj->objectDirectionIndex = READ_DWORD(bstrData);
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"MinQuestId"))
		{
			pObj->minQuestId = READ_WORD(bstrData, pstrDataName->c_str());
		}
		else if (0 == wcscmp(pstrDataName->c_str(), L"MaxQuestId"))
		{
			pObj->maxQuestId = READ_WORD(bstrData, pstrDataName->c_str());
		}
		else
		{
			Table::CallErrorCallbackFunction(L"[File] : %s\n[Error] : Unknown field name found!(Field Name = %s)", m_wszXmlFileName, pstrDataName->c_str());
			return false;
		}
	}
	else
	{
		return false;
	}

	return true;
}