コード例 #1
0
ファイル: hamsi.c プロジェクト: 5mil/Plebeian
static void
hamsi_big(sph_hamsi_big_context *sc, const unsigned char *buf, size_t num)
{
	DECL_STATE_BIG
#if !SPH_64
	sph_u32 tmp;
#endif

#if SPH_64
	sc->count += (sph_u64)num << 6;
#else
	tmp = SPH_T32((sph_u32)num << 6);
	sc->count_low = SPH_T32(sc->count_low + tmp);
	sc->count_high += (sph_u32)((num >> 13) >> 13);
	if (sc->count_low < tmp)
		sc->count_high ++;
#endif
	READ_STATE_BIG(sc);
	while (num -- > 0) {
		sph_u32 m0, m1, m2, m3, m4, m5, m6, m7;
		sph_u32 m8, m9, mA, mB, mC, mD, mE, mF;

		INPUT_BIG;
		P_BIG;
		T_BIG;
		buf += 8;
	}
	WRITE_STATE_BIG(sc);
}
コード例 #2
0
ファイル: fugue.c プロジェクト: ucisal/UCICOIN
static void
fugue3_core(sph_fugue_context *sc, const void *data, size_t len)
{
	DECL_STATE_BIG
	CORE_ENTRY
	READ_STATE_BIG(sc);
	rshift = sc->round_shift;
	switch (rshift) {
		for (;;) {
			sph_u32 q;

		case 0:
			q = p;
			TIX3(q, S00, S01, S04, S08, S16, S27, S30);
			CMIX36(S33, S34, S35, S01, S02, S03, S15, S16, S17);
			SMIX(S33, S34, S35, S00);
			CMIX36(S30, S31, S32, S34, S35, S00, S12, S13, S14);
			SMIX(S30, S31, S32, S33);
			CMIX36(S27, S28, S29, S31, S32, S33, S09, S10, S11);
			SMIX(S27, S28, S29, S30);
			NEXT(1);
			/* fall through */
		case 1:
			q = p;
			TIX3(q, S27, S28, S31, S35, S07, S18, S21);
			CMIX36(S24, S25, S26, S28, S29, S30, S06, S07, S08);
			SMIX(S24, S25, S26, S27);
			CMIX36(S21, S22, S23, S25, S26, S27, S03, S04, S05);
			SMIX(S21, S22, S23, S24);
			CMIX36(S18, S19, S20, S22, S23, S24, S00, S01, S02);
			SMIX(S18, S19, S20, S21);
			NEXT(2);
			/* fall through */
		case 2:
			q = p;
			TIX3(q, S18, S19, S22, S26, S34, S09, S12);
			CMIX36(S15, S16, S17, S19, S20, S21, S33, S34, S35);
			SMIX(S15, S16, S17, S18);
			CMIX36(S12, S13, S14, S16, S17, S18, S30, S31, S32);
			SMIX(S12, S13, S14, S15);
			CMIX36(S09, S10, S11, S13, S14, S15, S27, S28, S29);
			SMIX(S09, S10, S11, S12);
			NEXT(3);
			/* fall through */
		case 3:
			q = p;
			TIX3(q, S09, S10, S13, S17, S25, S00, S03);
			CMIX36(S06, S07, S08, S10, S11, S12, S24, S25, S26);
			SMIX(S06, S07, S08, S09);
			CMIX36(S03, S04, S05, S07, S08, S09, S21, S22, S23);
			SMIX(S03, S04, S05, S06);
			CMIX36(S00, S01, S02, S04, S05, S06, S18, S19, S20);
			SMIX(S00, S01, S02, S03);
			NEXT(0);
		}
	}
	CORE_EXIT
	WRITE_STATE_BIG(sc);
}
コード例 #3
0
ファイル: hamsi.c プロジェクト: 5mil/Plebeian
static void
hamsi_big_final(sph_hamsi_big_context *sc, const unsigned char *buf)
{
	sph_u32 m0, m1, m2, m3, m4, m5, m6, m7;
	sph_u32 m8, m9, mA, mB, mC, mD, mE, mF;
	DECL_STATE_BIG

	READ_STATE_BIG(sc);
	INPUT_BIG;
	PF_BIG;
	T_BIG;
	WRITE_STATE_BIG(sc);
}
コード例 #4
0
ファイル: skein.cpp プロジェクト: nigeriacoin/nigeriacoin
static void
skein_big_core(sph_skein_big_context *sc, const void *data, size_t len)
{
	/*
	 * The Skein "final bit" in the tweak is troublesome here,
	 * because if the input has a length which is a multiple of the
	 * block size (512 bits) then that bit must be set for the
	 * final block, which is full of message bits (padding in
	 * Skein can be reduced to no extra bit at all). However, this
	 * function cannot know whether it processes the last chunks of
	 * the message or not. Hence we may keep a full block of buffered
	 * data (64 bytes).
	 */
	unsigned char *buf;
	size_t ptr;
	unsigned first;
	DECL_STATE_BIG

	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_BIG(sc);
	first = (bcount == 0) << 7;
	do {
		size_t clen;

		if (ptr == sizeof sc->buf) {
			bcount ++;
			UBI_BIG(96 + first, 0);
			first = 0;
			ptr = 0;
		}
		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;
	} while (len > 0);
	WRITE_STATE_BIG(sc);
	sc->ptr = ptr;
}