diff options
author | Pauli <pauli@openssl.org> | 2022-08-15 14:49:17 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-08-19 17:26:12 +1000 |
commit | 709d4be78f64a8ba0707fb5682b90039e848dad4 (patch) | |
tree | 93bb5839cbbc44ad740b4c9caf255fdc035dfee6 | |
parent | e8a557dc3c1ed16faff4aeb39268f8f5a3f8b81d (diff) | |
download | openssl-new-709d4be78f64a8ba0707fb5682b90039e848dad4.tar.gz |
Limit the size of various MAXCHUNK definitions
The current code has issues when sizeof(long) <> sizeof(size_t). The two
types are assumed to be interchangeable and them being different will
cause crashes and endless loops.
This fix limits the maximum chunk size for many of the symmetric ciphers
to 2^30 bytes. This chunk size limits the amount of data that will
be encrypted/decrypted in one lump. The code internally handles block
of data later than the chunk limit, so this will present no difference
to the caller. Any loss of efficiency due to limiting the chunking to
1Gbyte rather than more should be insignificant.
Fixes Coverity issues:
1508498, 1508500 - 1508505, 1508507 - 1508527, 1508529 - 1508533,
1508535 - 1508537, 1508539, 1508541 - 1508549, 1508551 - 1508569 &
1508571 - 1508582.
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18997)
-rw-r--r-- | include/crypto/evp.h | 2 | ||||
-rw-r--r-- | providers/implementations/include/prov/ciphercommon.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/include/crypto/evp.h b/include/crypto/evp.h index cd281a8863..f601b72807 100644 --- a/include/crypto/evp.h +++ b/include/crypto/evp.h @@ -365,7 +365,7 @@ static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns return 1;\ } -#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2)) +#define EVP_MAXCHUNK ((size_t)1 << 30) #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ diff --git a/providers/implementations/include/prov/ciphercommon.h b/providers/implementations/include/prov/ciphercommon.h index f474128592..0e5d9f2681 100644 --- a/providers/implementations/include/prov/ciphercommon.h +++ b/providers/implementations/include/prov/ciphercommon.h @@ -18,7 +18,7 @@ # include "internal/cryptlib.h" # include "crypto/modes.h" -# define MAXCHUNK ((size_t)1 << (sizeof(long) * 8 - 2)) +# define MAXCHUNK ((size_t)1 << 30) # define MAXBITCHUNK ((size_t)1 << (sizeof(size_t) * 8 - 4)) # define GENERIC_BLOCK_SIZE 16 |