| 620 | } |
| 621 | |
| 622 | void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length) |
| 623 | { |
| 624 | size_t i; |
| 625 | uint8_t storeNextIv[AES_BLOCKLEN]; |
| 626 | for (i = 0; i < length; i += AES_BLOCKLEN) |
| 627 | { |
| 628 | memcpy(storeNextIv, buf, AES_BLOCKLEN); |
| 629 | InvCipher((state_t*)buf, ctx->RoundKey); |
| 630 | XorWithIv(buf, ctx->Iv); |
| 631 | memcpy(ctx->Iv, storeNextIv, AES_BLOCKLEN); |
| 632 | buf += AES_BLOCKLEN; |
| 633 | } |
| 634 | |
| 635 | } |
| 636 | |
| 637 | #endif // #if defined(CBC) && (CBC == 1) |
| 638 |