mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-24 22:15:07 +00:00
Fix RC4 key length in cipher
This commit is contained in:
parent
83f3fc0d77
commit
ce4112538c
|
@ -55,7 +55,7 @@ arc4_context;
|
||||||
*
|
*
|
||||||
* \param ctx ARC4 context to be initialized
|
* \param ctx ARC4 context to be initialized
|
||||||
* \param key the secret key
|
* \param key the secret key
|
||||||
* \param keylen length of the key
|
* \param keylen length of the key, in bytes
|
||||||
*/
|
*/
|
||||||
void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen );
|
void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen );
|
||||||
|
|
||||||
|
|
|
@ -786,7 +786,11 @@ static int arc4_crypt_stream_wrap( void *ctx, size_t length,
|
||||||
static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
|
static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
|
||||||
unsigned int key_length )
|
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 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue