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; }
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; }
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; }