void blake_large_lastBlock(blake_large_ctx_t* ctx, const void* msg, uint16_t length_b){
	while(length_b>=BLAKE_LARGE_BLOCKSIZE){
		blake_large_nextBlock(ctx, msg);
		msg = (uint8_t*)msg + BLAKE_LARGE_BLOCKSIZE_B;
		length_b -= BLAKE_LARGE_BLOCKSIZE;
	}
	uint8_t buffer[128];
	uint64_t v[16];
	uint64_t ctr;
	ctr = ctx->counter*1024+length_b;
	memset(buffer, 0, 128);
	memcpy(buffer, msg, (length_b+7)/8);
	buffer[length_b/8] |= 0x80 >> (length_b&0x7);
	blake_large_changeendian(buffer, buffer);
	blake_large_expand(v, ctx);
	if(length_b>1024-128-2){
		v[12] ^= ctr;
		v[13] ^= ctr;
		blake_large_compress(v, buffer);
		blake_large_collapse(ctx, v);
		memset(buffer, 0, 128-8);
		blake_large_expand(v, ctx);
	} else {
		if(length_b){
			v[12] ^= ctr;
			v[13] ^= ctr;
		}
	}
	if(ctx->appendone)
		buffer[128-16-8] |= 0x01;
	*((uint64_t*)(&(buffer[128-8]))) = ctr;
	blake_large_compress(v, buffer);
	blake_large_collapse(ctx, v);

}
Beispiel #2
0
void blake_large_nextBlock(blake_large_ctx_t *ctx, const void *msg){
	uint64_t v[16];
	uint64_t m[16];
	union {
		uint64_t v64;
		uint32_t v32[2];
	}ctr;
	blake_large_expand(v,ctx);
	ctx->counter++;
	ctr.v64 = ctx->counter*1024;
	v[12] ^= ctr.v64;
	v[13] ^= ctr.v64;
	blake_large_changeendian(m, msg);
	blake_large_compress(v, m);
	blake_large_collapse(ctx, v);
}