Ejemplo n.º 1
0
static void
hamsi_small(sph_hamsi_small_context *sc, const unsigned char *buf, size_t num)
{
	DECL_STATE_SMALL
#if !SPH_64
	sph_u32 tmp;
#endif

#if SPH_64
	sc->count += (sph_u64)num << 5;
#else
	tmp = SPH_T32((sph_u32)num << 5);
	sc->count_low = SPH_T32(sc->count_low + tmp);
	sc->count_high += (sph_u32)((num >> 13) >> 14);
	if (sc->count_low < tmp)
		sc->count_high ++;
#endif
	READ_STATE_SMALL(sc);
	while (num -- > 0) {
		sph_u32 m0, m1, m2, m3, m4, m5, m6, m7;

		INPUT_SMALL;
		P_SMALL;
		T_SMALL;
		buf += 4;
	}
	WRITE_STATE_SMALL(sc);
}
Ejemplo n.º 2
0
static void
fugue2_core(sph_fugue_context *sc, const void *data, size_t len)
{
	DECL_STATE_SMALL
	CORE_ENTRY
	READ_STATE_SMALL(sc);
	rshift = sc->round_shift;
	switch (rshift) {
		for (;;) {
			sph_u32 q;

		case 0:
			q = p;
			TIX2(q, S00, S01, S08, S10, S24);
			CMIX30(S27, S28, S29, S01, S02, S03, S12, S13, S14);
			SMIX(S27, S28, S29, S00);
			CMIX30(S24, S25, S26, S28, S29, S00, S09, S10, S11);
			SMIX(S24, S25, S26, S27);
			NEXT(1);
			/* fall through */
		case 1:
			q = p;
			TIX2(q, S24, S25, S02, S04, S18);
			CMIX30(S21, S22, S23, S25, S26, S27, S06, S07, S08);
			SMIX(S21, S22, S23, S24);
			CMIX30(S18, S19, S20, S22, S23, S24, S03, S04, S05);
			SMIX(S18, S19, S20, S21);
			NEXT(2);
			/* fall through */
		case 2:
			q = p;
			TIX2(q, S18, S19, S26, S28, S12);
			CMIX30(S15, S16, S17, S19, S20, S21, S00, S01, S02);
			SMIX(S15, S16, S17, S18);
			CMIX30(S12, S13, S14, S16, S17, S18, S27, S28, S29);
			SMIX(S12, S13, S14, S15);
			NEXT(3);
			/* fall through */
		case 3:
			q = p;
			TIX2(q, S12, S13, S20, S22, S06);
			CMIX30(S09, S10, S11, S13, S14, S15, S24, S25, S26);
			SMIX(S09, S10, S11, S12);
			CMIX30(S06, S07, S08, S10, S11, S12, S21, S22, S23);
			SMIX(S06, S07, S08, S09);
			NEXT(4);
			/* fall through */
		case 4:
			q = p;
			TIX2(q, S06, S07, S14, S16, S00);
			CMIX30(S03, S04, S05, S07, S08, S09, S18, S19, S20);
			SMIX(S03, S04, S05, S06);
			CMIX30(S00, S01, S02, S04, S05, S06, S15, S16, S17);
			SMIX(S00, S01, S02, S03);
			NEXT(0);
		}
	}
	CORE_EXIT
	WRITE_STATE_SMALL(sc);
}
Ejemplo n.º 3
0
static void
hamsi_small_final(sph_hamsi_small_context *sc, const unsigned char *buf)
{
	sph_u32 m0, m1, m2, m3, m4, m5, m6, m7;
	DECL_STATE_SMALL

	READ_STATE_SMALL(sc);
	INPUT_SMALL;
	PF_SMALL;
	T_SMALL;
	WRITE_STATE_SMALL(sc);
}
Ejemplo n.º 4
0
/* obsolete */
static void
skein_small_core(sph_skein_small_context *sc, const void *data, size_t len)
{
	unsigned char *buf;
	size_t ptr, clen;
	unsigned first;
	DECL_STATE_SMALL

	buf = sc->buf;
	ptr = sc->ptr;
	clen = (sizeof sc->buf) - ptr;
	if (len <= clen) {
		memcpy(buf + ptr, data, len);
		sc->ptr = ptr + len;
		return;
	}
	if (clen != 0) {
		memcpy(buf + ptr, data, clen);
		data = (const unsigned char *)data + clen;
		len -= clen;
	}

#if SPH_SMALL_FOOTPRINT_SKEIN

	READ_STATE_SMALL(sc);
	first = (bcount == 0) << 7;
	for (;;) {
		bcount ++;
		UBI_SMALL(96 + first, 0);
		if (len <= sizeof sc->buf)
			break;
		first = 0;
		memcpy(buf, data, sizeof sc->buf);
		data = (const unsigned char *)data + sizeof sc->buf;
		len -= sizeof sc->buf;
	}
	WRITE_STATE_SMALL(sc);
	sc->ptr = len;
	memcpy(buf, data, len);

#else

	/*
	 * Unrolling the loop yields a slight performance boost, while
	 * keeping the code size aorund 24 kB on 32-bit x86.
	 */
	READ_STATE_SMALL(sc);
	first = (bcount == 0) << 7;
	for (;;) {
		bcount ++;
		UBI_SMALL(96 + first, 0);
		if (len <= sizeof sc->buf)
			break;
		buf = (unsigned char *)data;
		bcount ++;
		UBI_SMALL(96, 0);
		if (len <= 2 * sizeof sc->buf) {
			data = buf + sizeof sc->buf;
			len -= sizeof sc->buf;
			break;
		}
		buf += sizeof sc->buf;
		data = buf + sizeof sc->buf;
		first = 0;
		len -= 2 * sizeof sc->buf;
	}
	WRITE_STATE_SMALL(sc);
	sc->ptr = len;
	memcpy(sc->buf, data, len);

#endif
}