diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_cast.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_cast.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/e_cast.c b/src/lib/libcrypto/evp/e_cast.c index d6f1b1d1a0..e654962c75 100644 --- a/src/lib/libcrypto/evp/e_cast.c +++ b/src/lib/libcrypto/evp/e_cast.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_cast.c,v 1.10 2022/09/04 13:55:39 jsing Exp $ */ | 1 | /* $OpenBSD: e_cast.c,v 1.11 2022/09/04 15:45:25 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -56,6 +56,7 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <limits.h> | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | 61 | ||
61 | #include <openssl/opensslconf.h> | 62 | #include <openssl/opensslconf.h> |
@@ -85,6 +86,9 @@ cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | |||
85 | static int | 86 | static int |
86 | cast5_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 87 | cast5_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
87 | { | 88 | { |
89 | if (inl > LONG_MAX) | ||
90 | return 0; | ||
91 | |||
88 | while (inl >= EVP_MAXCHUNK) { | 92 | while (inl >= EVP_MAXCHUNK) { |
89 | CAST_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAST_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 93 | CAST_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAST_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
90 | inl -= EVP_MAXCHUNK; | 94 | inl -= EVP_MAXCHUNK; |
@@ -103,6 +107,9 @@ cast5_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char | |||
103 | { | 107 | { |
104 | size_t chunk = EVP_MAXCHUNK; | 108 | size_t chunk = EVP_MAXCHUNK; |
105 | 109 | ||
110 | if (inl > LONG_MAX) | ||
111 | return 0; | ||
112 | |||
106 | if (inl < chunk) | 113 | if (inl < chunk) |
107 | chunk = inl; | 114 | chunk = inl; |
108 | 115 | ||
@@ -123,6 +130,9 @@ cast5_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *i | |||
123 | { | 130 | { |
124 | size_t i, bl; | 131 | size_t i, bl; |
125 | 132 | ||
133 | if (inl > LONG_MAX) | ||
134 | return 0; | ||
135 | |||
126 | bl = ctx->cipher->block_size; | 136 | bl = ctx->cipher->block_size; |
127 | 137 | ||
128 | if (inl < bl) | 138 | if (inl < bl) |
@@ -139,6 +149,9 @@ cast5_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *i | |||
139 | static int | 149 | static int |
140 | cast5_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 150 | cast5_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
141 | { | 151 | { |
152 | if (inl > LONG_MAX) | ||
153 | return 0; | ||
154 | |||
142 | while (inl >= EVP_MAXCHUNK) { | 155 | while (inl >= EVP_MAXCHUNK) { |
143 | CAST_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAST_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 156 | CAST_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAST_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
144 | inl -= EVP_MAXCHUNK; | 157 | inl -= EVP_MAXCHUNK; |