From 3ac6a2b9a769d451cd7bcf5eb138839dbfca1f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 28 May 2014 22:04:25 +0200 Subject: [PATCH] Same as previous commit with Camellia --- library/camellia.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/library/camellia.c b/library/camellia.c index 524e6ffae4..306be61fe6 100644 --- a/library/camellia.c +++ b/library/camellia.c @@ -435,20 +435,14 @@ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, uint32_t *SK; int ret; - switch( keysize ) - { - case 128: ctx->nr = 3; idx = 0; break; - case 192: - case 256: ctx->nr = 4; idx = 1; break; - default : return( POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH ); - } - - RK = ctx->rk; - - ret = camellia_setkey_enc(&cty, key, keysize); - if( ret != 0 ) + /* Also checks keysize */ + if( ( ret = camellia_setkey_enc(&cty, key, keysize) ) ) return( ret ); + ctx->nr = cty.nr; + idx = ( ctx->nr == 4 ); + + RK = ctx->rk; SK = cty.rk + 24 * 2 + 8 * idx * 2; *RK++ = *SK++;