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); }
void bcal_eax_encLastBlock(void *block, uint16_t length_b, bcal_eax_ctx_t *ctx){ bcal_ctr_encMsg(NULL, block, length_b, &(ctx->cipher)); bcal_cmac_lastBlock(&(ctx->ctag), block, length_b); }
void bcal_ctr_decMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ctr_ctx_t* ctx){ bcal_ctr_encMsg(iv, msg, msg_len_b, ctx); }