- Expanded generic cipher layer with support for CTR and CFB128 modes of operation.

This commit is contained in:
Paul Bakker 2011-06-09 14:27:58 +00:00
parent 1ef71dffc7
commit 343a870daa
7 changed files with 1040 additions and 101 deletions

View file

@ -1,6 +1,9 @@
PolarSSL ChangeLog
= Version trunk
Features
* Expanded cipher layer with support for CFB128 and CTR mode
Bugfix
* Undid faulty bug fix in ssl_write() when flushing old data (Ticket
#18)

View file

@ -36,6 +36,8 @@
#define inline _inline
#endif
#define POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE -0x6080 /**< The selected feature is not available. */
typedef enum {
POLARSSL_CIPHER_ID_NONE = 0,
POLARSSL_CIPHER_ID_AES,
@ -46,12 +48,24 @@ typedef enum {
typedef enum {
POLARSSL_CIPHER_NONE = 0,
POLARSSL_CIPHER_CAMELLIA_128_CBC,
POLARSSL_CIPHER_CAMELLIA_192_CBC,
POLARSSL_CIPHER_CAMELLIA_256_CBC,
POLARSSL_CIPHER_AES_128_CBC,
POLARSSL_CIPHER_AES_192_CBC,
POLARSSL_CIPHER_AES_256_CBC,
POLARSSL_CIPHER_AES_128_CFB128,
POLARSSL_CIPHER_AES_192_CFB128,
POLARSSL_CIPHER_AES_256_CFB128,
POLARSSL_CIPHER_AES_128_CTR,
POLARSSL_CIPHER_AES_192_CTR,
POLARSSL_CIPHER_AES_256_CTR,
POLARSSL_CIPHER_CAMELLIA_128_CBC,
POLARSSL_CIPHER_CAMELLIA_192_CBC,
POLARSSL_CIPHER_CAMELLIA_256_CBC,
POLARSSL_CIPHER_CAMELLIA_128_CFB128,
POLARSSL_CIPHER_CAMELLIA_192_CFB128,
POLARSSL_CIPHER_CAMELLIA_256_CFB128,
POLARSSL_CIPHER_CAMELLIA_128_CTR,
POLARSSL_CIPHER_CAMELLIA_192_CTR,
POLARSSL_CIPHER_CAMELLIA_256_CTR,
POLARSSL_CIPHER_DES_CBC,
POLARSSL_CIPHER_DES_EDE_CBC,
POLARSSL_CIPHER_DES_EDE3_CBC
@ -60,8 +74,9 @@ typedef enum {
typedef enum {
POLARSSL_MODE_NONE = 0,
POLARSSL_MODE_CBC,
POLARSSL_MODE_CFB,
POLARSSL_MODE_CFB128,
POLARSSL_MODE_OFB,
POLARSSL_MODE_CTR,
} cipher_mode_t;
typedef enum {
@ -82,6 +97,40 @@ enum {
POLARSSL_MAX_IV_LENGTH = 16,
};
/**
* Base cipher information. The non-mode specific functions and values.
*/
typedef struct {
/** Base Cipher type (e.g. POLARSSL_CIPHER_ID_AES) */
cipher_id_t cipher;
/** Encrypt using CBC */
int (*cbc_func)( void *ctx, operation_t mode, size_t length, unsigned char *iv,
const unsigned char *input, unsigned char *output );
/** Encrypt using CFB128 */
int (*cfb128_func)( void *ctx, operation_t mode, size_t length, size_t *iv_off,
unsigned char *iv, const unsigned char *input, unsigned char *output );
/** Encrypt using CTR */
int (*ctr_func)( void *ctx, size_t length, size_t *nc_off, unsigned char *nonce_counter,
unsigned char *stream_block, const unsigned char *input, unsigned char *output );
/** Set key for encryption purposes */
int (*setkey_enc_func)( void *ctx, const unsigned char *key, unsigned int key_length);
/** Set key for decryption purposes */
int (*setkey_dec_func)( void *ctx, const unsigned char *key, unsigned int key_length);
/** Allocate a new context */
void * (*ctx_alloc_func)( void );
/** Free the given context */
void (*ctx_free_func)( void *ctx );
} cipher_base_t;
/**
* Cipher information. Allows cipher functions to be called in a generic way.
*/
@ -89,9 +138,6 @@ typedef struct {
/** Full cipher identifier (e.g. POLARSSL_CIPHER_AES_256_CBC) */
cipher_type_t type;
/** Base Cipher type (e.g. POLARSSL_CIPHER_ID_AES) */
cipher_id_t cipher;
/** Cipher mode (e.g. POLARSSL_CIPHER_MODE_CBC) */
cipher_mode_t mode;
@ -107,21 +153,8 @@ typedef struct {
/** block size, in bytes */
unsigned int block_size;
/** Encrypt using CBC */
int (*cbc_func)( void *ctx, operation_t mode, size_t length, unsigned char *iv,
const unsigned char *input, unsigned char *output );
/** Set key for encryption purposes */
int (*setkey_enc_func)( void *ctx, const unsigned char *key, unsigned int key_length);
/** Set key for decryption purposes */
int (*setkey_dec_func)( void *ctx, const unsigned char *key, unsigned int key_length);
/** Allocate a new context */
void * (*ctx_alloc_func)( void );
/** Free the given context */
void (*ctx_free_func)( void *ctx );
/** Base cipher information and functions */
const cipher_base_t *base;
} cipher_info_t;
@ -144,7 +177,7 @@ typedef struct {
/** Number of bytes that still need processing */
size_t unprocessed_len;
/** Current IV */
/** Current IV or NONCE_COUNTER for CTR-mode */
unsigned char iv[POLARSSL_MAX_IV_LENGTH];
/** Cipher-specific context */
@ -307,7 +340,7 @@ int cipher_setkey( cipher_context_t *ctx, const unsigned char *key, int key_leng
* \brief Reset the given context, setting the IV to iv
*
* \param ctx generic cipher context
* \param iv IV to use
* \param iv IV to use or NONCE_COUNTER in the case of a CTR-mode cipher
*
* \returns 0 on success, 1 if parameter verification fails.
*/

View file

@ -43,6 +43,18 @@ extern const cipher_info_t aes_128_cbc_info;
extern const cipher_info_t aes_192_cbc_info;
extern const cipher_info_t aes_256_cbc_info;
#if defined(POLARSSL_CIPHER_MODE_CFB)
extern const cipher_info_t aes_128_cfb128_info;
extern const cipher_info_t aes_192_cfb128_info;
extern const cipher_info_t aes_256_cfb128_info;
#endif /* POLARSSL_CIPHER_MODE_CFB */
#if defined(POLARSSL_CIPHER_MODE_CTR)
extern const cipher_info_t aes_128_ctr_info;
extern const cipher_info_t aes_192_ctr_info;
extern const cipher_info_t aes_256_ctr_info;
#endif /* POLARSSL_CIPHER_MODE_CTR */
#endif /* defined(POLARSSL_AES_C) */
#if defined(POLARSSL_CAMELLIA_C)
@ -51,6 +63,18 @@ extern const cipher_info_t camellia_128_cbc_info;
extern const cipher_info_t camellia_192_cbc_info;
extern const cipher_info_t camellia_256_cbc_info;
#if defined(POLARSSL_CIPHER_MODE_CFB)
extern const cipher_info_t camellia_128_cfb128_info;
extern const cipher_info_t camellia_192_cfb128_info;
extern const cipher_info_t camellia_256_cfb128_info;
#endif /* POLARSSL_CIPHER_MODE_CFB */
#if defined(POLARSSL_CIPHER_MODE_CTR)
extern const cipher_info_t camellia_128_ctr_info;
extern const cipher_info_t camellia_192_ctr_info;
extern const cipher_info_t camellia_256_ctr_info;
#endif /* POLARSSL_CIPHER_MODE_CTR */
#endif /* defined(POLARSSL_CAMELLIA_C) */
#if defined(POLARSSL_DES_C)

View file

@ -46,12 +46,38 @@ static const int supported_ciphers[] = {
POLARSSL_CIPHER_AES_128_CBC,
POLARSSL_CIPHER_AES_192_CBC,
POLARSSL_CIPHER_AES_256_CBC,
#if defined(POLARSSL_CIPHER_MODE_CFB)
POLARSSL_CIPHER_AES_128_CFB128,
POLARSSL_CIPHER_AES_192_CFB128,
POLARSSL_CIPHER_AES_256_CFB128,
#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
#if defined(POLARSSL_CIPHER_MODE_CTR)
POLARSSL_CIPHER_AES_128_CTR,
POLARSSL_CIPHER_AES_192_CTR,
POLARSSL_CIPHER_AES_256_CTR,
#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
#endif /* defined(POLARSSL_AES_C) */
#if defined(POLARSSL_CAMELLIA_C)
POLARSSL_CIPHER_CAMELLIA_128_CBC,
POLARSSL_CIPHER_CAMELLIA_192_CBC,
POLARSSL_CIPHER_CAMELLIA_256_CBC,
#if defined(POLARSSL_CIPHER_MODE_CFB)
POLARSSL_CIPHER_CAMELLIA_128_CFB128,
POLARSSL_CIPHER_CAMELLIA_192_CFB128,
POLARSSL_CIPHER_CAMELLIA_256_CFB128,
#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
#if defined(POLARSSL_CIPHER_MODE_CTR)
POLARSSL_CIPHER_CAMELLIA_128_CTR,
POLARSSL_CIPHER_CAMELLIA_192_CTR,
POLARSSL_CIPHER_CAMELLIA_256_CTR,
#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
#endif /* defined(POLARSSL_CAMELLIA_C) */
#if defined(POLARSSL_DES_C)
@ -80,6 +106,25 @@ const cipher_info_t *cipher_info_from_type( cipher_type_t cipher_type )
return &aes_192_cbc_info;
case POLARSSL_CIPHER_AES_256_CBC:
return &aes_256_cbc_info;
#if defined(POLARSSL_CIPHER_MODE_CFB)
case POLARSSL_CIPHER_AES_128_CFB128:
return &aes_128_cfb128_info;
case POLARSSL_CIPHER_AES_192_CFB128:
return &aes_192_cfb128_info;
case POLARSSL_CIPHER_AES_256_CFB128:
return &aes_256_cfb128_info;
#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
#if defined(POLARSSL_CIPHER_MODE_CTR)
case POLARSSL_CIPHER_AES_128_CTR:
return &aes_128_ctr_info;
case POLARSSL_CIPHER_AES_192_CTR:
return &aes_192_ctr_info;
case POLARSSL_CIPHER_AES_256_CTR:
return &aes_256_ctr_info;
#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
#endif
#if defined(POLARSSL_CAMELLIA_C)
@ -89,6 +134,25 @@ const cipher_info_t *cipher_info_from_type( cipher_type_t cipher_type )
return &camellia_192_cbc_info;
case POLARSSL_CIPHER_CAMELLIA_256_CBC:
return &camellia_256_cbc_info;
#if defined(POLARSSL_CIPHER_MODE_CFB)
case POLARSSL_CIPHER_CAMELLIA_128_CFB128:
return &camellia_128_cfb128_info;
case POLARSSL_CIPHER_CAMELLIA_192_CFB128:
return &camellia_192_cfb128_info;
case POLARSSL_CIPHER_CAMELLIA_256_CFB128:
return &camellia_256_cfb128_info;
#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
#if defined(POLARSSL_CIPHER_MODE_CTR)
case POLARSSL_CIPHER_CAMELLIA_128_CTR:
return &camellia_128_ctr_info;
case POLARSSL_CIPHER_CAMELLIA_192_CTR:
return &camellia_192_ctr_info;
case POLARSSL_CIPHER_CAMELLIA_256_CTR:
return &camellia_256_ctr_info;
#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
#endif
#if defined(POLARSSL_DES_C)
@ -110,7 +174,7 @@ const cipher_info_t *cipher_info_from_string( const char *cipher_name )
if( NULL == cipher_name )
return NULL;
/* Get the appropriate digest information */
/* Get the appropriate cipher information */
#if defined(POLARSSL_CAMELLIA_C)
if( !strcasecmp( "CAMELLIA-128-CBC", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_128_CBC );
@ -118,7 +182,26 @@ const cipher_info_t *cipher_info_from_string( const char *cipher_name )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_192_CBC );
if( !strcasecmp( "CAMELLIA-256-CBC", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_256_CBC );
#if defined(POLARSSL_CIPHER_MODE_CFB)
if( !strcasecmp( "CAMELLIA-128-CFB128", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_128_CFB128 );
if( !strcasecmp( "CAMELLIA-192-CFB128", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_192_CFB128 );
if( !strcasecmp( "CAMELLIA-256-CFB128", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_256_CFB128 );
#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
#if defined(POLARSSL_CIPHER_MODE_CTR)
if( !strcasecmp( "CAMELLIA-128-CTR", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_128_CTR );
if( !strcasecmp( "CAMELLIA-192-CTR", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_192_CTR );
if( !strcasecmp( "CAMELLIA-256-CTR", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_256_CTR );
#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
#endif
#if defined(POLARSSL_AES_C)
if( !strcasecmp( "AES-128-CBC", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_AES_128_CBC );
@ -126,7 +209,26 @@ const cipher_info_t *cipher_info_from_string( const char *cipher_name )
return cipher_info_from_type( POLARSSL_CIPHER_AES_192_CBC );
if( !strcasecmp( "AES-256-CBC", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_AES_256_CBC );
#if defined(POLARSSL_CIPHER_MODE_CFB)
if( !strcasecmp( "AES-128-CFB128", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_AES_128_CFB128 );
if( !strcasecmp( "AES-192-CFB128", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_AES_192_CFB128 );
if( !strcasecmp( "AES-256-CFB128", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_AES_256_CFB128 );
#endif /* defined(POLARSSL_CIPHER_MODE_CFB) */
#if defined(POLARSSL_CIPHER_MODE_CTR)
if( !strcasecmp( "AES-128-CTR", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_AES_128_CTR );
if( !strcasecmp( "AES-192-CTR", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_AES_192_CTR );
if( !strcasecmp( "AES-256-CTR", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_AES_256_CTR );
#endif /* defined(POLARSSL_CIPHER_MODE_CTR) */
#endif
#if defined(POLARSSL_DES_C)
if( !strcasecmp( "DES-CBC", cipher_name ) )
return cipher_info_from_type( POLARSSL_CIPHER_DES_CBC );
@ -145,7 +247,7 @@ int cipher_init_ctx( cipher_context_t *ctx, const cipher_info_t *cipher_info )
memset( ctx, 0, sizeof( ctx ) );
if( NULL == ( ctx->cipher_ctx = cipher_info->ctx_alloc_func() ) )
if( NULL == ( ctx->cipher_ctx = cipher_info->base->ctx_alloc_func() ) )
return 2;
ctx->cipher_info = cipher_info;
@ -158,7 +260,7 @@ int cipher_free_ctx( cipher_context_t *ctx )
if( ctx == NULL || ctx->cipher_info == NULL )
return 1;
ctx->cipher_info->ctx_free_func( ctx->cipher_ctx );
ctx->cipher_info->base->ctx_free_func( ctx->cipher_ctx );
return 0;
}
@ -172,12 +274,19 @@ int cipher_setkey( cipher_context_t *ctx, const unsigned char *key,
ctx->key_length = key_length;
ctx->operation = operation;
if (POLARSSL_ENCRYPT == operation)
return ctx->cipher_info->setkey_enc_func( ctx->cipher_ctx, key,
/*
* For CFB128 and CTR mode always use the encryption key schedule
*/
if( POLARSSL_ENCRYPT == operation ||
POLARSSL_MODE_CFB128 == ctx->cipher_info->mode ||
POLARSSL_MODE_CTR == ctx->cipher_info->mode )
{
return ctx->cipher_info->base->setkey_enc_func( ctx->cipher_ctx, key,
ctx->key_length );
}
if (POLARSSL_DECRYPT == operation)
return ctx->cipher_info->setkey_dec_func( ctx->cipher_ctx, key,
if( POLARSSL_DECRYPT == operation )
return ctx->cipher_info->base->setkey_dec_func( ctx->cipher_ctx, key,
ctx->key_length );
return 1;
@ -235,7 +344,7 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ile
memcpy( &( ctx->unprocessed_data[ctx->unprocessed_len] ), input,
copy_len );
if( 0 != ctx->cipher_info->cbc_func( ctx->cipher_ctx,
if( 0 != ctx->cipher_info->base->cbc_func( ctx->cipher_ctx,
ctx->operation, cipher_get_block_size( ctx ), ctx->iv,
ctx->unprocessed_data, output) )
{
@ -271,7 +380,7 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ile
*/
if( ilen )
{
if( 0 != ctx->cipher_info->cbc_func( ctx->cipher_ctx,
if( 0 != ctx->cipher_info->base->cbc_func( ctx->cipher_ctx,
ctx->operation, ilen, ctx->iv, input, output ) )
{
return 1;
@ -282,6 +391,34 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ile
return 0;
}
if( ctx->cipher_info->mode == POLARSSL_MODE_CFB128 )
{
if( 0 != ctx->cipher_info->base->cfb128_func( ctx->cipher_ctx,
ctx->operation, ilen, &ctx->unprocessed_len, ctx->iv,
input, output ) )
{
return 1;
}
*olen = ilen;
return 0;
}
if( ctx->cipher_info->mode == POLARSSL_MODE_CTR )
{
if( 0 != ctx->cipher_info->base->ctr_func( ctx->cipher_ctx,
ilen, &ctx->unprocessed_len, ctx->iv,
ctx->unprocessed_data, input, output ) )
{
return 1;
}
*olen = ilen;
return 0;
}
return 1;
}
@ -325,6 +462,12 @@ int cipher_finish( cipher_context_t *ctx, unsigned char *output, size_t *olen)
*olen = 0;
if( POLARSSL_MODE_CFB128 == ctx->cipher_info->mode ||
POLARSSL_MODE_CTR == ctx->cipher_info->mode )
{
return 0;
}
if( POLARSSL_MODE_CBC == ctx->cipher_info->mode )
{
if( POLARSSL_ENCRYPT == ctx->operation )
@ -339,7 +482,7 @@ int cipher_finish( cipher_context_t *ctx, unsigned char *output, size_t *olen)
}
/* cipher block */
if( 0 != ctx->cipher_info->cbc_func( ctx->cipher_ctx, ctx->operation,
if( 0 != ctx->cipher_info->base->cbc_func( ctx->cipher_ctx, ctx->operation,
cipher_get_block_size( ctx ), ctx->iv, ctx->unprocessed_data,
output ) )
{

View file

@ -46,6 +46,44 @@ int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
return aes_crypt_cbc( (aes_context *) ctx, operation, length, iv, input, output );
}
int aes_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length,
size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output )
{
#if defined(POLARSSL_CIPHER_MODE_CFB)
return aes_crypt_cfb128( (aes_context *) ctx, operation, length, iv_off, iv, input, output );
#else
((void) ctx);
((void) operation);
((void) length);
((void) iv_off);
((void) iv);
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
#endif
}
int aes_crypt_ctr_wrap( void *ctx, size_t length,
size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block,
const unsigned char *input, unsigned char *output )
{
#if defined(POLARSSL_CIPHER_MODE_CTR)
return aes_crypt_ctr( (aes_context *) ctx, length, nc_off, nonce_counter,
stream_block, input, output );
#else
((void) ctx);
((void) length);
((void) nc_off);
((void) nonce_counter);
((void) stream_block);
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
#endif
}
int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length )
{
return aes_setkey_dec( (aes_context *) ctx, key, key_length );
@ -66,50 +104,111 @@ static void aes_ctx_free( void *ctx )
free( ctx );
}
const cipher_base_t aes_info = {
POLARSSL_CIPHER_ID_AES,
aes_crypt_cbc_wrap,
aes_crypt_cfb128_wrap,
aes_crypt_ctr_wrap,
aes_setkey_enc_wrap,
aes_setkey_dec_wrap,
aes_ctx_alloc,
aes_ctx_free
};
const cipher_info_t aes_128_cbc_info = {
POLARSSL_CIPHER_AES_128_CBC,
POLARSSL_CIPHER_ID_AES,
POLARSSL_MODE_CBC,
128,
"AES-128-CBC",
16,
16,
aes_crypt_cbc_wrap,
aes_setkey_enc_wrap,
aes_setkey_dec_wrap,
aes_ctx_alloc,
aes_ctx_free
&aes_info
};
const cipher_info_t aes_192_cbc_info = {
POLARSSL_CIPHER_AES_192_CBC,
POLARSSL_CIPHER_ID_AES,
POLARSSL_MODE_CBC,
192,
"AES-192-CBC",
16,
16,
aes_crypt_cbc_wrap,
aes_setkey_enc_wrap,
aes_setkey_dec_wrap,
aes_ctx_alloc,
aes_ctx_free
&aes_info
};
const cipher_info_t aes_256_cbc_info = {
POLARSSL_CIPHER_AES_256_CBC,
POLARSSL_CIPHER_ID_AES,
POLARSSL_MODE_CBC,
256,
"AES-256-CBC",
16,
16,
aes_crypt_cbc_wrap,
aes_setkey_enc_wrap,
aes_setkey_dec_wrap,
aes_ctx_alloc,
aes_ctx_free
&aes_info
};
#if defined(POLARSSL_CIPHER_MODE_CFB)
const cipher_info_t aes_128_cfb128_info = {
POLARSSL_CIPHER_AES_128_CFB128,
POLARSSL_MODE_CFB128,
128,
"AES-128-CFB128",
16,
16,
&aes_info
};
const cipher_info_t aes_192_cfb128_info = {
POLARSSL_CIPHER_AES_192_CFB128,
POLARSSL_MODE_CFB128,
192,
"AES-192-CFB128",
16,
16,
&aes_info
};
const cipher_info_t aes_256_cfb128_info = {
POLARSSL_CIPHER_AES_256_CFB128,
POLARSSL_MODE_CFB128,
256,
"AES-256-CFB128",
16,
16,
&aes_info
};
#endif /* POLARSSL_CIPHER_MODE_CFB */
#if defined(POLARSSL_CIPHER_MODE_CTR)
const cipher_info_t aes_128_ctr_info = {
POLARSSL_CIPHER_AES_128_CTR,
POLARSSL_MODE_CTR,
128,
"AES-128-CTR",
16,
16,
&aes_info
};
const cipher_info_t aes_192_ctr_info = {
POLARSSL_CIPHER_AES_192_CTR,
POLARSSL_MODE_CTR,
192,
"AES-192-CTR",
16,
16,
&aes_info
};
const cipher_info_t aes_256_ctr_info = {
POLARSSL_CIPHER_AES_256_CTR,
POLARSSL_MODE_CTR,
256,
"AES-256-CTR",
16,
16,
&aes_info
};
#endif /* POLARSSL_CIPHER_MODE_CTR */
#endif
#if defined(POLARSSL_CAMELLIA_C)
@ -120,6 +219,44 @@ int camellia_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
return camellia_crypt_cbc( (camellia_context *) ctx, operation, length, iv, input, output );
}
int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length,
size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output )
{
#if defined(POLARSSL_CIPHER_MODE_CFB)
return camellia_crypt_cfb128( (camellia_context *) ctx, operation, length, iv_off, iv, input, output );
#else
((void) ctx);
((void) operation);
((void) length);
((void) iv_off);
((void) iv);
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
#endif
}
int camellia_crypt_ctr_wrap( void *ctx, size_t length,
size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block,
const unsigned char *input, unsigned char *output )
{
#if defined(POLARSSL_CIPHER_MODE_CTR)
return camellia_crypt_ctr( (camellia_context *) ctx, length, nc_off, nonce_counter,
stream_block, input, output );
#else
((void) ctx);
((void) length);
((void) nc_off);
((void) nonce_counter);
((void) stream_block);
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
#endif
}
int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length )
{
return camellia_setkey_dec( (camellia_context *) ctx, key, key_length );
@ -140,50 +277,111 @@ static void camellia_ctx_free( void *ctx )
free( ctx );
}
const cipher_base_t camellia_info = {
POLARSSL_CIPHER_ID_CAMELLIA,
camellia_crypt_cbc_wrap,
camellia_crypt_cfb128_wrap,
camellia_crypt_ctr_wrap,
camellia_setkey_enc_wrap,
camellia_setkey_dec_wrap,
camellia_ctx_alloc,
camellia_ctx_free
};
const cipher_info_t camellia_128_cbc_info = {
POLARSSL_CIPHER_CAMELLIA_128_CBC,
POLARSSL_CIPHER_ID_CAMELLIA,
POLARSSL_MODE_CBC,
128,
"CAMELLIA-128-CBC",
16,
16,
camellia_crypt_cbc_wrap,
camellia_setkey_enc_wrap,
camellia_setkey_dec_wrap,
camellia_ctx_alloc,
camellia_ctx_free
&camellia_info
};
const cipher_info_t camellia_192_cbc_info = {
POLARSSL_CIPHER_CAMELLIA_192_CBC,
POLARSSL_CIPHER_ID_CAMELLIA,
POLARSSL_MODE_CBC,
192,
"CAMELLIA-192-CBC",
16,
16,
camellia_crypt_cbc_wrap,
camellia_setkey_enc_wrap,
camellia_setkey_dec_wrap,
camellia_ctx_alloc,
camellia_ctx_free
&camellia_info
};
const cipher_info_t camellia_256_cbc_info = {
POLARSSL_CIPHER_CAMELLIA_256_CBC,
POLARSSL_CIPHER_ID_CAMELLIA,
POLARSSL_MODE_CBC,
256,
"CAMELLIA-256-CBC",
16,
16,
camellia_crypt_cbc_wrap,
camellia_setkey_enc_wrap,
camellia_setkey_dec_wrap,
camellia_ctx_alloc,
camellia_ctx_free
&camellia_info
};
#if defined(POLARSSL_CIPHER_MODE_CFB)
const cipher_info_t camellia_128_cfb128_info = {
POLARSSL_CIPHER_CAMELLIA_128_CFB128,
POLARSSL_MODE_CFB128,
128,
"CAMELLIA-128-CFB128",
16,
16,
&camellia_info
};
const cipher_info_t camellia_192_cfb128_info = {
POLARSSL_CIPHER_CAMELLIA_192_CFB128,
POLARSSL_MODE_CFB128,
192,
"CAMELLIA-192-CFB128",
16,
16,
&camellia_info
};
const cipher_info_t camellia_256_cfb128_info = {
POLARSSL_CIPHER_CAMELLIA_256_CFB128,
POLARSSL_MODE_CFB128,
256,
"CAMELLIA-256-CFB128",
16,
16,
&camellia_info
};
#endif /* POLARSSL_CIPHER_MODE_CFB */
#if defined(POLARSSL_CIPHER_MODE_CTR)
const cipher_info_t camellia_128_ctr_info = {
POLARSSL_CIPHER_CAMELLIA_128_CTR,
POLARSSL_MODE_CTR,
128,
"CAMELLIA-128-CTR",
16,
16,
&camellia_info
};
const cipher_info_t camellia_192_ctr_info = {
POLARSSL_CIPHER_CAMELLIA_192_CTR,
POLARSSL_MODE_CTR,
192,
"CAMELLIA-192-CTR",
16,
16,
&camellia_info
};
const cipher_info_t camellia_256_ctr_info = {
POLARSSL_CIPHER_CAMELLIA_256_CTR,
POLARSSL_MODE_CTR,
256,
"CAMELLIA-256-CTR",
16,
16,
&camellia_info
};
#endif /* POLARSSL_CIPHER_MODE_CTR */
#endif
#if defined(POLARSSL_DES_C)
@ -200,6 +398,36 @@ int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
return des3_crypt_cbc( (des3_context *) ctx, operation, length, iv, input, output );
}
int des_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length,
size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output )
{
((void) ctx);
((void) operation);
((void) length);
((void) iv_off);
((void) iv);
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
}
int des_crypt_ctr_wrap( void *ctx, size_t length,
size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block,
const unsigned char *input, unsigned char *output )
{
((void) ctx);
((void) length);
((void) nc_off);
((void) nonce_counter);
((void) stream_block);
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
}
int des_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length )
{
((void) key_length);
@ -257,50 +485,68 @@ static void des_ctx_free( void *ctx )
free( ctx );
}
const cipher_info_t des_cbc_info = {
POLARSSL_CIPHER_DES_CBC,
const cipher_base_t des_info = {
POLARSSL_CIPHER_ID_DES,
POLARSSL_MODE_CBC,
POLARSSL_KEY_LENGTH_DES,
"DES-CBC",
8,
8,
des_crypt_cbc_wrap,
des_crypt_cfb128_wrap,
des_crypt_ctr_wrap,
des_setkey_enc_wrap,
des_setkey_dec_wrap,
des_ctx_alloc,
des_ctx_free
};
const cipher_info_t des_ede_cbc_info = {
POLARSSL_CIPHER_DES_EDE_CBC,
POLARSSL_CIPHER_ID_DES,
const cipher_info_t des_cbc_info = {
POLARSSL_CIPHER_DES_CBC,
POLARSSL_MODE_CBC,
POLARSSL_KEY_LENGTH_DES_EDE,
"DES-EDE-CBC",
16,
16,
POLARSSL_KEY_LENGTH_DES,
"DES-CBC",
8,
8,
&des_info
};
const cipher_base_t des_ede_info = {
POLARSSL_CIPHER_ID_DES,
des3_crypt_cbc_wrap,
des_crypt_cfb128_wrap,
des_crypt_ctr_wrap,
des3_set2key_enc_wrap,
des3_set2key_dec_wrap,
des3_ctx_alloc,
des_ctx_free
};
const cipher_info_t des_ede3_cbc_info = {
POLARSSL_CIPHER_DES_EDE3_CBC,
POLARSSL_CIPHER_ID_DES,
const cipher_info_t des_ede_cbc_info = {
POLARSSL_CIPHER_DES_EDE_CBC,
POLARSSL_MODE_CBC,
POLARSSL_KEY_LENGTH_DES_EDE3,
"DES-EDE3-CBC",
8,
8,
POLARSSL_KEY_LENGTH_DES_EDE,
"DES-EDE-CBC",
16,
16,
&des_ede_info
};
const cipher_base_t des_ede3_info = {
POLARSSL_CIPHER_ID_DES,
des3_crypt_cbc_wrap,
des_crypt_cfb128_wrap,
des_crypt_ctr_wrap,
des3_set3key_enc_wrap,
des3_set3key_dec_wrap,
des3_ctx_alloc,
des_ctx_free
};
const cipher_info_t des_ede3_cbc_info = {
POLARSSL_CIPHER_DES_EDE3_CBC,
POLARSSL_MODE_CBC,
POLARSSL_KEY_LENGTH_DES_EDE3,
"DES-EDE3-CBC",
8,
8,
&des_ede3_info
};
#endif
#endif

View file

@ -109,6 +109,214 @@ AES Encrypt and decrypt 32 bytes in multiple parts 1
depends_on:POLARSSL_AES_C
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CBC:128:16:16:
AES Encrypt and decrypt 0 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:0
AES Encrypt and decrypt 1 byte
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:1
AES Encrypt and decrypt 2 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:2
AES Encrypt and decrypt 7 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:7
AES Encrypt and decrypt 8 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:8
AES Encrypt and decrypt 9 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:9
AES Encrypt and decrypt 15 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:15
AES Encrypt and decrypt 16 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:16
AES Encrypt and decrypt 17 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:17
AES Encrypt and decrypt 31 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:31
AES Encrypt and decrypt 32 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:32
AES Encrypt and decrypt 32 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:33
AES Encrypt and decrypt 47 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:47
AES Encrypt and decrypt 48 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:48
AES Encrypt and decrypt 49 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_AES_128_CFB128:AES-128-CFB128:128:49
AES Encrypt and decrypt 0 bytes in multiple parts
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:0:0:
AES Encrypt and decrypt 1 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:1:0:
AES Encrypt and decrypt 1 bytes in multiple parts 2
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:0:1:
AES Encrypt and decrypt 16 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:16:0:
AES Encrypt and decrypt 16 bytes in multiple parts 2
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:0:16:
AES Encrypt and decrypt 16 bytes in multiple parts 3
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:1:15:
AES Encrypt and decrypt 16 bytes in multiple parts 4
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:15:1:
AES Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:15:7:
AES Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:16:6:
AES Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:17:6:
AES Encrypt and decrypt 32 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CFB128:128:16:16:
AES Encrypt and decrypt 0 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:0
AES Encrypt and decrypt 1 byte
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:1
AES Encrypt and decrypt 2 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:2
AES Encrypt and decrypt 7 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:7
AES Encrypt and decrypt 8 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:8
AES Encrypt and decrypt 9 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:9
AES Encrypt and decrypt 15 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:15
AES Encrypt and decrypt 16 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:16
AES Encrypt and decrypt 17 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:17
AES Encrypt and decrypt 31 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:31
AES Encrypt and decrypt 32 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:32
AES Encrypt and decrypt 32 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:33
AES Encrypt and decrypt 47 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:47
AES Encrypt and decrypt 48 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:48
AES Encrypt and decrypt 49 bytes
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_AES_128_CTR:AES-128-CTR:128:49
AES Encrypt and decrypt 0 bytes in multiple parts
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:0:0:
AES Encrypt and decrypt 1 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:1:0:
AES Encrypt and decrypt 1 bytes in multiple parts 2
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:0:1:
AES Encrypt and decrypt 16 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:16:0:
AES Encrypt and decrypt 16 bytes in multiple parts 2
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:0:16:
AES Encrypt and decrypt 16 bytes in multiple parts 3
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:1:15:
AES Encrypt and decrypt 16 bytes in multiple parts 4
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:15:1:
AES Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:15:7:
AES Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:16:6:
AES Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:17:6:
AES Encrypt and decrypt 32 bytes in multiple parts 1
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CTR:128:16:16:
AES Encrypt and decrypt 0 bytes
depends_on:POLARSSL_AES_C
enc_dec_buf:POLARSSL_CIPHER_AES_192_CBC:AES-192-CBC:192:0
@ -421,6 +629,214 @@ CAMELLIA Encrypt and decrypt 32 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CBC:128:16:16:
CAMELLIA Encrypt and decrypt 0 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:0
CAMELLIA Encrypt and decrypt 1 byte
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:1
CAMELLIA Encrypt and decrypt 2 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:2
CAMELLIA Encrypt and decrypt 7 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:7
CAMELLIA Encrypt and decrypt 8 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:8
CAMELLIA Encrypt and decrypt 9 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:9
CAMELLIA Encrypt and decrypt 15 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:15
CAMELLIA Encrypt and decrypt 16 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:16
CAMELLIA Encrypt and decrypt 17 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:17
CAMELLIA Encrypt and decrypt 31 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:31
CAMELLIA Encrypt and decrypt 32 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:32
CAMELLIA Encrypt and decrypt 32 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:33
CAMELLIA Encrypt and decrypt 47 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:47
CAMELLIA Encrypt and decrypt 48 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:48
CAMELLIA Encrypt and decrypt 49 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CFB128:CAMELLIA-128-CFB128:128:49
CAMELLIA Encrypt and decrypt 0 bytes in multiple parts
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:0:0:
CAMELLIA Encrypt and decrypt 1 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:1:0:
CAMELLIA Encrypt and decrypt 1 bytes in multiple parts 2
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:0:1:
CAMELLIA Encrypt and decrypt 16 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:16:0:
CAMELLIA Encrypt and decrypt 16 bytes in multiple parts 2
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:0:16:
CAMELLIA Encrypt and decrypt 16 bytes in multiple parts 3
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:1:15:
CAMELLIA Encrypt and decrypt 16 bytes in multiple parts 4
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:15:1:
CAMELLIA Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:15:7:
CAMELLIA Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:16:6:
CAMELLIA Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:17:6:
CAMELLIA Encrypt and decrypt 32 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CFB128:128:16:16:
CAMELLIA Encrypt and decrypt 0 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:0
CAMELLIA Encrypt and decrypt 1 byte
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:1
CAMELLIA Encrypt and decrypt 2 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:2
CAMELLIA Encrypt and decrypt 7 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:7
CAMELLIA Encrypt and decrypt 8 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:8
CAMELLIA Encrypt and decrypt 9 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:9
CAMELLIA Encrypt and decrypt 15 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:15
CAMELLIA Encrypt and decrypt 16 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:16
CAMELLIA Encrypt and decrypt 17 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:17
CAMELLIA Encrypt and decrypt 31 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:31
CAMELLIA Encrypt and decrypt 32 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:32
CAMELLIA Encrypt and decrypt 32 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:33
CAMELLIA Encrypt and decrypt 47 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:47
CAMELLIA Encrypt and decrypt 48 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:48
CAMELLIA Encrypt and decrypt 49 bytes
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CTR:CAMELLIA-128-CTR:128:49
CAMELLIA Encrypt and decrypt 0 bytes in multiple parts
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:0:0:
CAMELLIA Encrypt and decrypt 1 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:1:0:
CAMELLIA Encrypt and decrypt 1 bytes in multiple parts 2
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:0:1:
CAMELLIA Encrypt and decrypt 16 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:16:0:
CAMELLIA Encrypt and decrypt 16 bytes in multiple parts 2
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:0:16:
CAMELLIA Encrypt and decrypt 16 bytes in multiple parts 3
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:1:15:
CAMELLIA Encrypt and decrypt 16 bytes in multiple parts 4
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:15:1:
CAMELLIA Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:15:7:
CAMELLIA Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:16:6:
CAMELLIA Encrypt and decrypt 22 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:17:6:
CAMELLIA Encrypt and decrypt 32 bytes in multiple parts 1
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CTR:128:16:16:
CAMELLIA Encrypt and decrypt 0 bytes
depends_on:POLARSSL_CAMELLIA_C
enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_192_CBC:CAMELLIA-192-CBC:192:0

View file

@ -48,20 +48,59 @@ enc_dec_buf:cipher_id:cipher_string:key_len:length:
TEST_ASSERT( 0 == cipher_reset( &ctx_dec, iv ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_enc, iv ) );
enclen = cipher_get_block_size( &ctx_enc )
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
enclen = cipher_get_block_size( &ctx_enc )
* ( 1 + length / cipher_get_block_size( &ctx_enc ) );
}
else
{
enclen = length;
}
/* encode length number of bytes from inbuf */
TEST_ASSERT( 0 == cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
TEST_ASSERT( outlen == enclen - cipher_get_block_size ( &ctx_enc ) );
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
TEST_ASSERT( outlen == enclen - cipher_get_block_size ( &ctx_enc ) );
}
else
{
TEST_ASSERT( outlen == enclen );
}
TEST_ASSERT( 0 == cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
TEST_ASSERT( outlen == cipher_get_block_size ( &ctx_enc ) );
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
TEST_ASSERT( outlen == cipher_get_block_size ( &ctx_enc ) );
}
else
{
TEST_ASSERT( outlen == 0 );
}
/* decode the previously encoded string */
TEST_ASSERT( 0 == cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
TEST_ASSERT( enclen - cipher_get_block_size ( &ctx_enc ) == outlen );
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
TEST_ASSERT( enclen - cipher_get_block_size ( &ctx_enc ) == outlen );
}
else
{
TEST_ASSERT( enclen == outlen );
}
TEST_ASSERT( 0 == cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
TEST_ASSERT( length - enclen + cipher_get_block_size ( &ctx_enc ) == outlen );
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
TEST_ASSERT( length - enclen + cipher_get_block_size ( &ctx_enc ) == outlen );
}
else
{
TEST_ASSERT( outlen == 0 );
}
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
@ -152,24 +191,59 @@ enc_dec_buf_multipart:cipher_id:key_len:first_length:second_length:
TEST_ASSERT( 0 == cipher_reset( &ctx_dec, iv ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_enc, iv ) );
enclen = cipher_get_block_size(&ctx_enc )
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
enclen = cipher_get_block_size(&ctx_enc )
* ( 1 + length / cipher_get_block_size( &ctx_enc ) );
}
else
{
enclen = length;
}
/* encode length number of bytes from inbuf */
TEST_ASSERT( 0 == cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
totaloutlen = outlen;
TEST_ASSERT( 0 == cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
totaloutlen += outlen;
TEST_ASSERT( totaloutlen == enclen - cipher_get_block_size ( &ctx_enc ) );
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
TEST_ASSERT( totaloutlen == enclen - cipher_get_block_size ( &ctx_enc ) );
}
else
{
TEST_ASSERT( totaloutlen == enclen );
}
TEST_ASSERT( 0 == cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
totaloutlen += outlen;
TEST_ASSERT( outlen == cipher_get_block_size ( &ctx_enc ) );
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
TEST_ASSERT( outlen == cipher_get_block_size ( &ctx_enc ) );
}
else
{
TEST_ASSERT( outlen == 0 );
}
/* decode the previously encoded string */
TEST_ASSERT( 0 == cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
TEST_ASSERT( enclen - cipher_get_block_size ( &ctx_enc ) == outlen );
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
TEST_ASSERT( enclen - cipher_get_block_size ( &ctx_enc ) == outlen );
}
else
{
TEST_ASSERT( enclen == outlen );
}
TEST_ASSERT( 0 == cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
TEST_ASSERT( length - enclen + cipher_get_block_size ( &ctx_enc ) == outlen );
if( POLARSSL_MODE_CBC == cipher_info->mode )
{
TEST_ASSERT( length - enclen + cipher_get_block_size ( &ctx_enc ) == outlen );
}
else
{
TEST_ASSERT( outlen == 0 );
}
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );