diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_des3.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_des3.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/e_des3.c b/src/lib/libcrypto/evp/e_des3.c index e9d7f56809..1171a53b74 100644 --- a/src/lib/libcrypto/evp/e_des3.c +++ b/src/lib/libcrypto/evp/e_des3.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_des3.c,v 1.23 2022/09/04 13:17:18 jsing Exp $ */ | 1 | /* $OpenBSD: e_des3.c,v 1.24 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 | #include <string.h> | 61 | #include <string.h> |
61 | 62 | ||
@@ -129,6 +130,9 @@ des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
129 | { | 130 | { |
130 | size_t i, bl; | 131 | size_t i, bl; |
131 | 132 | ||
133 | if (inl > LONG_MAX) | ||
134 | return 0; | ||
135 | |||
132 | bl = ctx->cipher->block_size; | 136 | bl = ctx->cipher->block_size; |
133 | 137 | ||
134 | if (inl < bl) | 138 | if (inl < bl) |
@@ -146,6 +150,9 @@ static int | |||
146 | des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 150 | des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
147 | const unsigned char *in, size_t inl) | 151 | const unsigned char *in, size_t inl) |
148 | { | 152 | { |
153 | if (inl > LONG_MAX) | ||
154 | return 0; | ||
155 | |||
149 | while (inl >= EVP_MAXCHUNK) { | 156 | while (inl >= EVP_MAXCHUNK) { |
150 | DES_ede3_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, | 157 | DES_ede3_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, |
151 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | 158 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, |
@@ -166,6 +173,9 @@ static int | |||
166 | des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 173 | des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
167 | const unsigned char *in, size_t inl) | 174 | const unsigned char *in, size_t inl) |
168 | { | 175 | { |
176 | if (inl > LONG_MAX) | ||
177 | return 0; | ||
178 | |||
169 | while (inl >= EVP_MAXCHUNK) { | 179 | while (inl >= EVP_MAXCHUNK) { |
170 | DES_ede3_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, | 180 | DES_ede3_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, |
171 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | 181 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, |
@@ -185,6 +195,9 @@ static int | |||
185 | des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 195 | des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
186 | const unsigned char *in, size_t inl) | 196 | const unsigned char *in, size_t inl) |
187 | { | 197 | { |
198 | if (inl > LONG_MAX) | ||
199 | return 0; | ||
200 | |||
188 | while (inl >= EVP_MAXCHUNK) { | 201 | while (inl >= EVP_MAXCHUNK) { |
189 | DES_ede3_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, | 202 | DES_ede3_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, |
190 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | 203 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, |
@@ -208,6 +221,10 @@ des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
208 | { | 221 | { |
209 | size_t n; | 222 | size_t n; |
210 | unsigned char c[1], d[1]; | 223 | unsigned char c[1], d[1]; |
224 | |||
225 | if (inl > LONG_MAX) | ||
226 | return 0; | ||
227 | |||
211 | if (!(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS)) | 228 | if (!(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS)) |
212 | inl *= 8; | 229 | inl *= 8; |
213 | 230 | ||
@@ -227,6 +244,9 @@ static int | |||
227 | des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 244 | des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
228 | const unsigned char *in, size_t inl) | 245 | const unsigned char *in, size_t inl) |
229 | { | 246 | { |
247 | if (inl > LONG_MAX) | ||
248 | return 0; | ||
249 | |||
230 | while (inl >= EVP_MAXCHUNK) { | 250 | while (inl >= EVP_MAXCHUNK) { |
231 | DES_ede3_cfb_encrypt(in, out, 8, (long)EVP_MAXCHUNK, | 251 | DES_ede3_cfb_encrypt(in, out, 8, (long)EVP_MAXCHUNK, |
232 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | 252 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, |