Example #1
0
void bcal_ctr_encMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ctr_ctx_t* ctx){
	bcal_ctr_loadIV(iv, ctx);
	uint16_t blocksize_b;
	blocksize_b = ctx->blocksize_B*8;
	while(msg_len_b>blocksize_b){
		bcal_ctr_encNext(msg, ctx);
		msg_len_b -= blocksize_b;
		msg = (uint8_t*)msg + ctx->blocksize_B;
	}
	uint8_t tmp[ctx->blocksize_B];
	memcpy(tmp, ctx->in_block, ctx->blocksize_B);
	bcal_cipher_enc(tmp, &(ctx->cctx));
	ctx->inc_func(ctx->in_block, ctx->blocksize_B);
	tmp[msg_len_b/8] = 0xff00>>(msg_len_b&7);
	memxor(msg, tmp, (msg_len_b+7)/8);
}
Example #2
0
void bcal_eax_encNextBlock(void *block, bcal_eax_ctx_t *ctx){
	bcal_ctr_encNext(block, &(ctx->cipher));
	bcal_cmac_nextBlock(&(ctx->ctag), block);
}
Example #3
0
void bcal_ctr_decNext(void* block, bcal_ctr_ctx_t* ctx){
	bcal_ctr_encNext(block, ctx);
}