From 9a131ad7477f85d40ee96853e60d0de86f5f4e09 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 28 Jun 2019 16:29:42 +0100 Subject: Change RC5_32_set_key to return an int type If the key is too long we now return an error. Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/8834) --- crypto/rc5/rc5_skey.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'crypto/rc5') diff --git a/crypto/rc5/rc5_skey.c b/crypto/rc5/rc5_skey.c index 1746406c67..43dc9320da 100644 --- a/crypto/rc5/rc5_skey.c +++ b/crypto/rc5/rc5_skey.c @@ -10,12 +10,15 @@ #include #include "rc5_locl.h" -void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, - int rounds) +int RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, + int rounds) { RC5_32_INT L[64], l, ll, A, B, *S, k; int i, j, m, c, t, ii, jj; + if (len > 255) + return 0; + if ((rounds != RC5_16_ROUNDS) && (rounds != RC5_12_ROUNDS) && (rounds != RC5_8_ROUNDS)) rounds = RC5_16_ROUNDS; @@ -58,4 +61,6 @@ void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, if (++jj >= c) jj = 0; } + + return 1; } -- cgit v1.2.3