Exemplo n.º 1
0
static void
blake64(sph_blake_big_context *sc, const void *data, size_t len)
{
	unsigned char *buf;
	size_t ptr;
	DECL_STATE64

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

	READ_STATE64(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) {
			if ((T0 = SPH_T64(T0 + 1024)) < 1024)
				T1 = SPH_T64(T1 + 1);
			COMPRESS64;
			ptr = 0;
		}
	}
	WRITE_STATE64(sc);
	sc->ptr = ptr;
}
Exemplo n.º 2
0
CBLAKE512& CBLAKE512::Write(const unsigned char* data, size_t len)
{
    unsigned char *buf;
    size_t ptr;
    DECL_STATE64

    buf = s.buf;
    ptr = s.ptr;
    if (len < (sizeof s.buf) - ptr) {
        memcpy(buf + ptr, data, len);
        ptr += len;
        s.ptr = ptr;
        return *this;
    }

    READ_STATE64(&s);
    while (len > 0) {
        size_t clen;

        clen = (sizeof s.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 s.buf) {
            if ((T0 = SPH_T64(T0 + 1024)) < 1024)
                T1 = SPH_T64(T1 + 1);
            COMPRESS64;
            ptr = 0;
        }
    }
    WRITE_STATE64(&s);
    s.ptr = ptr;
    return *this;
}