| 605 | } |
| 606 | |
| 607 | void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t* buf, size_t length) |
| 608 | { |
| 609 | size_t i; |
| 610 | uint8_t *Iv = ctx->Iv; |
| 611 | for (i = 0; i < length; i += AES_BLOCKLEN) |
| 612 | { |
| 613 | XorWithIv(buf, Iv); |
| 614 | Cipher((state_t*)buf, ctx->RoundKey); |
| 615 | Iv = buf; |
| 616 | buf += AES_BLOCKLEN; |
| 617 | } |
| 618 | /* store Iv in ctx for next call */ |
| 619 | memcpy(ctx->Iv, Iv, AES_BLOCKLEN); |
| 620 | } |
| 621 | |
| 622 | void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length) |
| 623 | { |