From 2ca3e81f3c065a780d0d66cc8a77faabbb4d62f1 Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Sat, 26 Sep 2020 19:10:19 +0300 Subject: use size_t for buffer size and its indexes - this allows using CBC/CTR with buffers larger than 4GB on 64bit systems; Closes: #172 Signed-off-by: Ihor Dutchak --- aes.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'aes.c') diff --git a/aes.c b/aes.c index eaf2b69..555457a 100644 --- a/aes.c +++ b/aes.c @@ -495,9 +495,9 @@ static void XorWithIv(uint8_t* buf, const uint8_t* Iv) } } -void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t* buf, uint32_t length) +void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t* buf, size_t length) { - uintptr_t i; + size_t i; uint8_t *Iv = ctx->Iv; for (i = 0; i < length; i += AES_BLOCKLEN) { @@ -510,9 +510,9 @@ void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t* buf, uint32_t length) memcpy(ctx->Iv, Iv, AES_BLOCKLEN); } -void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length) +void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length) { - uintptr_t i; + size_t i; uint8_t storeNextIv[AES_BLOCKLEN]; for (i = 0; i < length; i += AES_BLOCKLEN) { @@ -532,11 +532,11 @@ void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length) #if defined(CTR) && (CTR == 1) /* Symmetrical operation: same function for encrypting as for decrypting. Note any IV/nonce should never be reused with the same key */ -void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length) +void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length) { uint8_t buffer[AES_BLOCKLEN]; - unsigned i; + size_t i; int bi; for (i = 0, bi = AES_BLOCKLEN; i < length; ++i, ++bi) { -- cgit v1.2.3