- Added Blowfish to generic cipher layer
- Renamed POLARSSL_MODE_CFB128 to POLARSSL_MODE_CFB
diff --git a/library/cipher.c b/library/cipher.c
index 0d1258b..f20cc73 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -86,6 +86,19 @@
POLARSSL_CIPHER_DES_EDE3_CBC,
#endif /* defined(POLARSSL_DES_C) */
+#if defined(POLARSSL_BLOWFISH_C)
+ POLARSSL_CIPHER_BLOWFISH_CBC,
+
+#if defined(POLARSSL_CIPHER_MODE_CFB)
+ POLARSSL_CIPHER_BLOWFISH_CFB64,
+#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
+
+#if defined(POLARSSL_CIPHER_MODE_CTR)
+ POLARSSL_CIPHER_BLOWFISH_CTR,
+#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
+
+#endif /* defined(POLARSSL_BLOWFISH_C) */
+
#if defined(POLARSSL_CIPHER_NULL_CIPHER)
POLARSSL_CIPHER_NULL,
#endif /* defined(POLARSSL_CIPHER_NULL_CIPHER) */
@@ -168,6 +181,22 @@
return &des_ede3_cbc_info;
#endif
+#if defined(POLARSSL_BLOWFISH_C)
+ case POLARSSL_CIPHER_BLOWFISH_CBC:
+ return &blowfish_cbc_info;
+
+#if defined(POLARSSL_CIPHER_MODE_CFB)
+ case POLARSSL_CIPHER_BLOWFISH_CFB64:
+ return &blowfish_cfb64_info;
+#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
+
+#if defined(POLARSSL_CIPHER_MODE_CTR)
+ case POLARSSL_CIPHER_BLOWFISH_CTR:
+ return &blowfish_ctr_info;
+#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
+
+#endif
+
#if defined(POLARSSL_CIPHER_NULL_CIPHER)
case POLARSSL_CIPHER_NULL:
return &null_cipher_info;
@@ -247,6 +276,21 @@
return cipher_info_from_type( POLARSSL_CIPHER_DES_EDE3_CBC );
#endif
+#if defined(POLARSSL_BLOWFISH_C)
+ if( !strcasecmp( "BLOWFISH-CBC", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CBC );
+
+#if defined(POLARSSL_CIPHER_MODE_CFB)
+ if( !strcasecmp( "BLOWFISH-CFB64", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CFB64 );
+#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
+
+#if defined(POLARSSL_CIPHER_MODE_CTR)
+ if( !strcasecmp( "BLOWFISH-CTR", cipher_name ) )
+ return cipher_info_from_type( POLARSSL_CIPHER_BLOWFISH_CTR );
+#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
+#endif
+
#if defined(POLARSSL_CIPHER_NULL_CIPHER)
if( !strcasecmp( "NULL", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_NULL );
@@ -295,10 +339,10 @@
#endif /* defined(POLARSSL_CIPHER_NULL_CIPHER) */
/*
- * For CFB128 and CTR mode always use the encryption key schedule
+ * For CFB and CTR mode always use the encryption key schedule
*/
if( POLARSSL_ENCRYPT == operation ||
- POLARSSL_MODE_CFB128 == ctx->cipher_info->mode ||
+ POLARSSL_MODE_CFB == ctx->cipher_info->mode ||
POLARSSL_MODE_CTR == ctx->cipher_info->mode )
{
return ctx->cipher_info->base->setkey_enc_func( ctx->cipher_ctx, key,
@@ -421,9 +465,9 @@
return 0;
}
- if( ctx->cipher_info->mode == POLARSSL_MODE_CFB128 )
+ if( ctx->cipher_info->mode == POLARSSL_MODE_CFB )
{
- if( 0 != ( ret = ctx->cipher_info->base->cfb128_func( ctx->cipher_ctx,
+ if( 0 != ( ret = ctx->cipher_info->base->cfb_func( ctx->cipher_ctx,
ctx->operation, ilen, &ctx->unprocessed_len, ctx->iv,
input, output ) ) )
{
@@ -493,7 +537,7 @@
*olen = 0;
- if( POLARSSL_MODE_CFB128 == ctx->cipher_info->mode ||
+ if( POLARSSL_MODE_CFB == ctx->cipher_info->mode ||
POLARSSL_MODE_CTR == ctx->cipher_info->mode ||
POLARSSL_MODE_NULL == ctx->cipher_info->mode )
{