summaryrefslogtreecommitdiffstats
path: root/crypto/rc5
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2019-06-28 16:29:42 +0100
committerMatt Caswell <matt@openssl.org>2019-07-01 10:18:37 +0100
commit9a131ad7477f85d40ee96853e60d0de86f5f4e09 (patch)
treeb6fad564674f3cd12da7f9c617fa4c78ed943f48 /crypto/rc5
parent792cb4ee8d82e4b063f707fc9f4992271ffd65ab (diff)
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 <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8834)
Diffstat (limited to 'crypto/rc5')
-rw-r--r--crypto/rc5/rc5_skey.c9
1 files changed, 7 insertions, 2 deletions
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 <openssl/rc5.h>
#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;
}