void bcal_eax_free(bcal_eax_ctx_t *ctx){ bcal_ctr_free(&(ctx->cipher)); bcal_cmac_free(&(ctx->ctag)); bcal_cmac_free(&(ctx->htag)); bcal_cmac_free(&(ctx->ntag)); free(ctx->nonce); }
void testrun_aes128_ctr(void){ uint8_t key[16]; uint8_t iv[16]; uint8_t plain[64]; bcal_ctr_ctx_t ctx; uint8_t r; memcpy(key, modes_key, 16); memcpy(iv, modes_ctriv, 16); memcpy(plain, modes_plain, 64); cli_putstr("\r\n** AES128-CTR-TEST **"); r = bcal_ctr_init(&aes128_desc, key, 128, NULL, &ctx); cli_putstr("\r\n init = 0x"); cli_hexdump(&r, 1); cli_putstr("\r\n key: "); cli_hexdump(key, 128/8); cli_putstr("\r\n IV: "); cli_hexdump(iv, 128/8); cli_putstr("\r\n plaintext:"); cli_hexdump_block(plain, 4*128/8, 4, 16); if(r) return; bcal_ctr_encMsg(iv, plain, 4*128, &ctx); cli_putstr("\r\n ciphertext: "); cli_hexdump_block(plain, 4*128/8, 4, 16); bcal_ctr_decMsg(iv, plain, 4*128, &ctx); cli_putstr("\r\n plaintext: "); cli_hexdump_block(plain, 4*128/8, 4, 16); bcal_ctr_free(&ctx); }