diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_des.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_des.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/e_des.c b/src/lib/libcrypto/evp/e_des.c index bf037591be..9205128cf4 100644 --- a/src/lib/libcrypto/evp/e_des.c +++ b/src/lib/libcrypto/evp/e_des.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_des.c,v 1.17 2022/09/04 13:17:18 jsing Exp $ */ | 1 | /* $OpenBSD: e_des.c,v 1.18 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> |
@@ -98,6 +99,9 @@ des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
98 | { | 99 | { |
99 | size_t i, bl; | 100 | size_t i, bl; |
100 | 101 | ||
102 | if (inl > LONG_MAX) | ||
103 | return 0; | ||
104 | |||
101 | bl = ctx->cipher->block_size; | 105 | bl = ctx->cipher->block_size; |
102 | 106 | ||
103 | if (inl < bl) | 107 | if (inl < bl) |
@@ -108,6 +112,7 @@ des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
108 | for (i = 0; i <= inl; i += bl) | 112 | for (i = 0; i <= inl; i += bl) |
109 | DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), | 113 | DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), |
110 | ctx->cipher_data, ctx->encrypt); | 114 | ctx->cipher_data, ctx->encrypt); |
115 | |||
111 | return 1; | 116 | return 1; |
112 | } | 117 | } |
113 | 118 | ||
@@ -115,6 +120,9 @@ static int | |||
115 | des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 120 | des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
116 | const unsigned char *in, size_t inl) | 121 | const unsigned char *in, size_t inl) |
117 | { | 122 | { |
123 | if (inl > LONG_MAX) | ||
124 | return 0; | ||
125 | |||
118 | while (inl >= EVP_MAXCHUNK) { | 126 | while (inl >= EVP_MAXCHUNK) { |
119 | DES_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, | 127 | DES_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, |
120 | (DES_cblock *)ctx->iv, &ctx->num); | 128 | (DES_cblock *)ctx->iv, &ctx->num); |
@@ -132,6 +140,9 @@ static int | |||
132 | des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 140 | des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
133 | const unsigned char *in, size_t inl) | 141 | const unsigned char *in, size_t inl) |
134 | { | 142 | { |
143 | if (inl > LONG_MAX) | ||
144 | return 0; | ||
145 | |||
135 | while (inl >= EVP_MAXCHUNK) { | 146 | while (inl >= EVP_MAXCHUNK) { |
136 | DES_ncbc_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, | 147 | DES_ncbc_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, |
137 | (DES_cblock *)ctx->iv, ctx->encrypt); | 148 | (DES_cblock *)ctx->iv, ctx->encrypt); |
@@ -149,6 +160,9 @@ static int | |||
149 | des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 160 | des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
150 | const unsigned char *in, size_t inl) | 161 | const unsigned char *in, size_t inl) |
151 | { | 162 | { |
163 | if (inl > LONG_MAX) | ||
164 | return 0; | ||
165 | |||
152 | while (inl >= EVP_MAXCHUNK) { | 166 | while (inl >= EVP_MAXCHUNK) { |
153 | DES_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, | 167 | DES_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, |
154 | (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); | 168 | (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); |
@@ -171,6 +185,9 @@ des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
171 | size_t n, chunk = EVP_MAXCHUNK/8; | 185 | size_t n, chunk = EVP_MAXCHUNK/8; |
172 | unsigned char c[1], d[1]; | 186 | unsigned char c[1], d[1]; |
173 | 187 | ||
188 | if (inl > LONG_MAX) | ||
189 | return 0; | ||
190 | |||
174 | if (inl < chunk) | 191 | if (inl < chunk) |
175 | chunk = inl; | 192 | chunk = inl; |
176 | 193 | ||
@@ -197,6 +214,9 @@ static int | |||
197 | des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 214 | des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
198 | const unsigned char *in, size_t inl) | 215 | const unsigned char *in, size_t inl) |
199 | { | 216 | { |
217 | if (inl > LONG_MAX) | ||
218 | return 0; | ||
219 | |||
200 | while (inl >= EVP_MAXCHUNK) { | 220 | while (inl >= EVP_MAXCHUNK) { |
201 | DES_cfb_encrypt(in, out, 8, (long)EVP_MAXCHUNK, | 221 | DES_cfb_encrypt(in, out, 8, (long)EVP_MAXCHUNK, |
202 | ctx->cipher_data, (DES_cblock *)ctx->iv, ctx->encrypt); | 222 | ctx->cipher_data, (DES_cblock *)ctx->iv, ctx->encrypt); |