Better checking on cipher_info_from_values()

This commit is contained in:
Paul Bakker 2013-09-10 14:29:28 +02:00
parent a0558e0484
commit 2a6a3a7e69

View File

@ -494,7 +494,7 @@ const cipher_info_t *cipher_info_from_values( const cipher_id_t cipher_id,
#endif #endif
#if defined(POLARSSL_DES_C) #if defined(POLARSSL_DES_C)
if( cipher_id == POLARSSL_CIPHER_ID_DES ) if( cipher_id == POLARSSL_CIPHER_ID_DES && key_length == 64 )
{ {
if( mode == POLARSSL_MODE_ECB ) if( mode == POLARSSL_MODE_ECB )
return &des_ecb_info; return &des_ecb_info;
@ -524,13 +524,13 @@ const cipher_info_t *cipher_info_from_values( const cipher_id_t cipher_id,
#endif #endif
#if defined(POLARSSL_ARC4_C) #if defined(POLARSSL_ARC4_C)
if( cipher_id == POLARSSL_CIPHER_ID_ARC4 ) if( cipher_id == POLARSSL_CIPHER_ID_ARC4 &&
if( mode == POLARSSL_MODE_STREAM ) key_length == 128 && mode == POLARSSL_MODE_STREAM )
return &arc4_128_info; return &arc4_128_info;
#endif #endif
#if defined(POLARSSL_BLOWFISH_C) #if defined(POLARSSL_BLOWFISH_C)
if( cipher_id == POLARSSL_CIPHER_ID_BLOWFISH ) if( cipher_id == POLARSSL_CIPHER_ID_BLOWFISH && key_length == 128 )
{ {
if( mode == POLARSSL_MODE_ECB ) if( mode == POLARSSL_MODE_ECB )
return &blowfish_ecb_info; return &blowfish_ecb_info;