Fix RC4 key length in cipher
diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c
index 79daaf9..f09823a 100644
--- a/library/cipher_wrap.c
+++ b/library/cipher_wrap.c
@@ -786,7 +786,11 @@
static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
unsigned int key_length )
{
- arc4_setup( (arc4_context *) ctx, key, key_length );
+ /* we get key_length in bits, arc4 expects it in bytes */
+ if( key_length % 8 != 0)
+ return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+
+ arc4_setup( (arc4_context *) ctx, key, key_length / 8 );
return( 0 );
}