From 4f6fadbdc7c414a2037510de2e3cdde36883470f Mon Sep 17 00:00:00 2001 From: Vincent Dupont <vincent@otakeys.com> Date: Tue, 27 Jun 2017 18:58:33 +0200 Subject: [PATCH] crypto/cbc: constify input buffers --- sys/crypto/modes/cbc.c | 7 ++++--- sys/include/crypto/modes/cbc.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/crypto/modes/cbc.c b/sys/crypto/modes/cbc.c index b5ffdeb845..21e193569d 100644 --- a/sys/crypto/modes/cbc.c +++ b/sys/crypto/modes/cbc.c @@ -23,7 +23,7 @@ #include "crypto/modes/cbc.h" int cipher_encrypt_cbc(cipher_t* cipher, uint8_t iv[16], - uint8_t* input, size_t length, uint8_t* output) + const uint8_t* input, size_t length, uint8_t* output) { size_t offset = 0; uint8_t block_size, input_block[CIPHER_MAX_BLOCK_SIZE] = {0}, @@ -55,10 +55,11 @@ int cipher_encrypt_cbc(cipher_t* cipher, uint8_t iv[16], int cipher_decrypt_cbc(cipher_t* cipher, uint8_t iv[16], - uint8_t* input, size_t length, uint8_t* output) + const uint8_t* input, size_t length, uint8_t* output) { size_t offset = 0; - uint8_t* input_block, *input_block_last, block_size; + const uint8_t *input_block, *input_block_last; + uint8_t block_size; block_size = cipher_get_block_size(cipher); diff --git a/sys/include/crypto/modes/cbc.h b/sys/include/crypto/modes/cbc.h index 022bfa20f1..c09a60ff37 100644 --- a/sys/include/crypto/modes/cbc.h +++ b/sys/include/crypto/modes/cbc.h @@ -37,7 +37,7 @@ extern "C" { * @param output pointer to allocated memory for encrypted data. It has to * be of size data_len + BLOCK_SIZE - data_len % BLOCK_SIZE. */ -int cipher_encrypt_cbc(cipher_t* cipher, uint8_t iv[16], uint8_t* input, +int cipher_encrypt_cbc(cipher_t* cipher, uint8_t iv[16], const uint8_t* input, size_t input_len, uint8_t* output); @@ -51,7 +51,7 @@ int cipher_encrypt_cbc(cipher_t* cipher, uint8_t iv[16], uint8_t* input, * @param output pointer to allocated memory for plaintext data. It has to * be of size input_len. */ -int cipher_decrypt_cbc(cipher_t* cipher, uint8_t iv[16], uint8_t* input, +int cipher_decrypt_cbc(cipher_t* cipher, uint8_t iv[16], const uint8_t* input, size_t input_len, uint8_t* output); #ifdef __cplusplus -- GitLab