/* Apply padding to the last block, currently in ctx->buf (with ctx->ptr bytes), and finalize OMAC computation.  */
static void do_pad(br_eax_context *ctx)
/* Apply padding to the last block, currently in ctx->buf (with ctx->ptr bytes), and finalize OMAC computation.  */
static void do_pad(br_eax_context *ctx)
{
	unsigned char *pad;
	size_t ptr, u;
	ptr = ctx->ptr;
	if (ptr == 16) {
		pad = ctx->L2;
	} else {
		ctx->buf[ptr ++] = 0x80;
		memset(ctx->buf + ptr, 0x00, 16 - ptr);
		pad = ctx->L4;
	}
	for (u = 0; u < sizeof ctx->buf; u ++) {
		ctx->buf[u] ^= pad[u];
	}
	(*ctx->bctx)->mac(ctx->bctx, ctx->cbcmac, ctx->buf, sizeof ctx->buf);
}