Ejemplo n.º 1
0
void bcal_cmac_free(bcal_cmac_ctx_t *ctx)
{
    free(ctx->accu);
    free(ctx->k1);
    free(ctx->k2);
    bcal_cipher_free(&(ctx->cctx));
}
Ejemplo n.º 2
0
void testrun_test_aes(void){
	uint8_t key[16] = { 0x2b, 0x7e, 0x15, 0x16,
	                    0x28, 0xae, 0xd2, 0xa6,
	                    0xab, 0xf7, 0x15, 0x88,
	                    0x09, 0xcf, 0x4f, 0x3c };
	uint8_t data[16] = { 0x32, 0x43, 0xf6, 0xa8,
	                     0x88, 0x5a, 0x30, 0x8d,
	                     0x31, 0x31, 0x98, 0xa2,
	                     0xe0, 0x37, 0x07, 0x34 };
	aes128_ctx_t ctx;
	aes128_init(key, &ctx);
	cli_putstr("\r\n\r\n cipher test (FIPS 197):\r\n key:        ");
	cli_hexdump(key, 16);
	cli_putstr("\r\n plaintext:  ");
	cli_hexdump(data, 16);
	aes128_enc(data, &ctx);
	cli_putstr("\r\n ciphertext: ");
	cli_hexdump(data, 16);
	aes128_dec(data, &ctx);
	cli_putstr("\r\n plaintext:  ");
	cli_hexdump(data, 16);
	cli_putstr("\r\n testing bcal:");
	bcgen_ctx_t bcal_ctx;
	uint8_t r;
	r = bcal_cipher_init(&aes128_desc, key, 128, &bcal_ctx);
	cli_putstr("\r\n init = 0x");
	cli_hexdump(&r, 1);

	bcal_cipher_enc(data, &bcal_ctx);
	cli_putstr("\r\n ciphertext: ");
	cli_hexdump(data, 16);
	bcal_cipher_dec(data, &bcal_ctx);
	cli_putstr("\r\n plaintext:  ");
	cli_hexdump(data, 16);
	bcal_cipher_free(&bcal_ctx);
}
Ejemplo n.º 3
0
void bcal_cfb_B_free(bcal_cfb_B_ctx_t* ctx){
	free(ctx->in_block);
	bcal_cipher_free(&(ctx->cctx));
}
Ejemplo n.º 4
0
void bcal_cbc_free(bcal_cbc_ctx_t *ctx){
	bcal_cipher_free(&(ctx->cctx));
	free(ctx->prev_block);
}