diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_rc2.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_rc2.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/libcrypto/evp/e_rc2.c b/src/lib/libcrypto/evp/e_rc2.c index 32559e223f..501e2dd31f 100644 --- a/src/lib/libcrypto/evp/e_rc2.c +++ b/src/lib/libcrypto/evp/e_rc2.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_rc2.c,v 1.22 2023/07/07 19:37:53 beck Exp $ */ | 1 | /* $OpenBSD: e_rc2.c,v 1.23 2023/11/18 09:37:15 tb 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 | * |
@@ -343,7 +343,7 @@ rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | |||
343 | 343 | ||
344 | if (type != NULL) { | 344 | if (type != NULL) { |
345 | l = EVP_CIPHER_CTX_iv_length(c); | 345 | l = EVP_CIPHER_CTX_iv_length(c); |
346 | if (l > sizeof(iv)) { | 346 | if (l < 0 || l > sizeof(iv)) { |
347 | EVPerror(EVP_R_IV_TOO_LARGE); | 347 | EVPerror(EVP_R_IV_TOO_LARGE); |
348 | return -1; | 348 | return -1; |
349 | } | 349 | } |
@@ -373,6 +373,8 @@ rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | |||
373 | if (type != NULL) { | 373 | if (type != NULL) { |
374 | num = rc2_meth_to_magic(c); | 374 | num = rc2_meth_to_magic(c); |
375 | j = EVP_CIPHER_CTX_iv_length(c); | 375 | j = EVP_CIPHER_CTX_iv_length(c); |
376 | if (j < 0 || j > sizeof(c->oiv)) | ||
377 | return 0; | ||
376 | i = ASN1_TYPE_set_int_octetstring(type, num, c->oiv, j); | 378 | i = ASN1_TYPE_set_int_octetstring(type, num, c->oiv, j); |
377 | } | 379 | } |
378 | return (i); | 380 | return (i); |
@@ -381,9 +383,15 @@ rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | |||
381 | static int | 383 | static int |
382 | rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) | 384 | rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) |
383 | { | 385 | { |
386 | int iv_len; | ||
387 | |||
384 | switch (type) { | 388 | switch (type) { |
385 | case EVP_CTRL_INIT: | 389 | case EVP_CTRL_INIT: |
386 | data(c)->key_bits = EVP_CIPHER_CTX_key_length(c) * 8; | 390 | data(c)->key_bits = 0; |
391 | /* XXX - upper bound? */ | ||
392 | if ((iv_len = EVP_CIPHER_CTX_key_length(c)) < 0) | ||
393 | return -1; | ||
394 | data(c)->key_bits = iv_len * 8; | ||
387 | return 1; | 395 | return 1; |
388 | 396 | ||
389 | case EVP_CTRL_GET_RC2_KEY_BITS: | 397 | case EVP_CTRL_GET_RC2_KEY_BITS: |