mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Remove MD2, MD4, RC4, Blowfish and XTEA
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
This commit is contained in:
@ -36,10 +36,6 @@
|
||||
#include "mbedtls/aes.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ARC4_C)
|
||||
#include "mbedtls/arc4.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
#include "mbedtls/camellia.h"
|
||||
#endif
|
||||
@ -52,10 +48,6 @@
|
||||
#include "mbedtls/des.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_BLOWFISH_C)
|
||||
#include "mbedtls/blowfish.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHACHA20_C)
|
||||
#include "mbedtls/chacha20.h"
|
||||
#endif
|
||||
@ -1674,225 +1666,6 @@ static const mbedtls_cipher_info_t des_ede3_cbc_info = {
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
#endif /* MBEDTLS_DES_C */
|
||||
|
||||
#if defined(MBEDTLS_BLOWFISH_C)
|
||||
|
||||
static int blowfish_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
return mbedtls_blowfish_crypt_ecb( (mbedtls_blowfish_context *) ctx, operation, input,
|
||||
output );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
static int blowfish_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
|
||||
size_t length, unsigned char *iv, const unsigned char *input,
|
||||
unsigned char *output )
|
||||
{
|
||||
return mbedtls_blowfish_crypt_cbc( (mbedtls_blowfish_context *) ctx, operation, length, iv,
|
||||
input, output );
|
||||
}
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
static int blowfish_crypt_cfb64_wrap( void *ctx, mbedtls_operation_t operation,
|
||||
size_t length, size_t *iv_off, unsigned char *iv,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
return mbedtls_blowfish_crypt_cfb64( (mbedtls_blowfish_context *) ctx, operation, length,
|
||||
iv_off, iv, input, output );
|
||||
}
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
static int blowfish_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 )
|
||||
{
|
||||
return mbedtls_blowfish_crypt_ctr( (mbedtls_blowfish_context *) ctx, length, nc_off,
|
||||
nonce_counter, stream_block, input, output );
|
||||
}
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
||||
|
||||
static int blowfish_setkey_wrap( void *ctx, const unsigned char *key,
|
||||
unsigned int key_bitlen )
|
||||
{
|
||||
return mbedtls_blowfish_setkey( (mbedtls_blowfish_context *) ctx, key, key_bitlen );
|
||||
}
|
||||
|
||||
static void * blowfish_ctx_alloc( void )
|
||||
{
|
||||
mbedtls_blowfish_context *ctx;
|
||||
ctx = mbedtls_calloc( 1, sizeof( mbedtls_blowfish_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
||||
mbedtls_blowfish_init( ctx );
|
||||
|
||||
return( ctx );
|
||||
}
|
||||
|
||||
static void blowfish_ctx_free( void *ctx )
|
||||
{
|
||||
mbedtls_blowfish_free( (mbedtls_blowfish_context *) ctx );
|
||||
mbedtls_free( ctx );
|
||||
}
|
||||
|
||||
static const mbedtls_cipher_base_t blowfish_info = {
|
||||
MBEDTLS_CIPHER_ID_BLOWFISH,
|
||||
blowfish_crypt_ecb_wrap,
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
blowfish_crypt_cbc_wrap,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
blowfish_crypt_cfb64_wrap,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_OFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
blowfish_crypt_ctr_wrap,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
blowfish_setkey_wrap,
|
||||
blowfish_setkey_wrap,
|
||||
blowfish_ctx_alloc,
|
||||
blowfish_ctx_free
|
||||
};
|
||||
|
||||
static const mbedtls_cipher_info_t blowfish_ecb_info = {
|
||||
MBEDTLS_CIPHER_BLOWFISH_ECB,
|
||||
MBEDTLS_MODE_ECB,
|
||||
128,
|
||||
"BLOWFISH-ECB",
|
||||
0,
|
||||
MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
|
||||
8,
|
||||
&blowfish_info
|
||||
};
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
static const mbedtls_cipher_info_t blowfish_cbc_info = {
|
||||
MBEDTLS_CIPHER_BLOWFISH_CBC,
|
||||
MBEDTLS_MODE_CBC,
|
||||
128,
|
||||
"BLOWFISH-CBC",
|
||||
8,
|
||||
MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
|
||||
8,
|
||||
&blowfish_info
|
||||
};
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
static const mbedtls_cipher_info_t blowfish_cfb64_info = {
|
||||
MBEDTLS_CIPHER_BLOWFISH_CFB64,
|
||||
MBEDTLS_MODE_CFB,
|
||||
128,
|
||||
"BLOWFISH-CFB64",
|
||||
8,
|
||||
MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
|
||||
8,
|
||||
&blowfish_info
|
||||
};
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
static const mbedtls_cipher_info_t blowfish_ctr_info = {
|
||||
MBEDTLS_CIPHER_BLOWFISH_CTR,
|
||||
MBEDTLS_MODE_CTR,
|
||||
128,
|
||||
"BLOWFISH-CTR",
|
||||
8,
|
||||
MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
|
||||
8,
|
||||
&blowfish_info
|
||||
};
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CTR */
|
||||
#endif /* MBEDTLS_BLOWFISH_C */
|
||||
|
||||
#if defined(MBEDTLS_ARC4_C)
|
||||
static int arc4_crypt_stream_wrap( void *ctx, size_t length,
|
||||
const unsigned char *input,
|
||||
unsigned char *output )
|
||||
{
|
||||
return( mbedtls_arc4_crypt( (mbedtls_arc4_context *) ctx, length, input, output ) );
|
||||
}
|
||||
|
||||
static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
|
||||
unsigned int key_bitlen )
|
||||
{
|
||||
/* we get key_bitlen in bits, arc4 expects it in bytes */
|
||||
if( key_bitlen % 8 != 0 )
|
||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||
|
||||
mbedtls_arc4_setup( (mbedtls_arc4_context *) ctx, key, key_bitlen / 8 );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static void * arc4_ctx_alloc( void )
|
||||
{
|
||||
mbedtls_arc4_context *ctx;
|
||||
ctx = mbedtls_calloc( 1, sizeof( mbedtls_arc4_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
||||
mbedtls_arc4_init( ctx );
|
||||
|
||||
return( ctx );
|
||||
}
|
||||
|
||||
static void arc4_ctx_free( void *ctx )
|
||||
{
|
||||
mbedtls_arc4_free( (mbedtls_arc4_context *) ctx );
|
||||
mbedtls_free( ctx );
|
||||
}
|
||||
|
||||
static const mbedtls_cipher_base_t arc4_base_info = {
|
||||
MBEDTLS_CIPHER_ID_ARC4,
|
||||
NULL,
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_OFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
||||
arc4_crypt_stream_wrap,
|
||||
#endif
|
||||
arc4_setkey_wrap,
|
||||
arc4_setkey_wrap,
|
||||
arc4_ctx_alloc,
|
||||
arc4_ctx_free
|
||||
};
|
||||
|
||||
static const mbedtls_cipher_info_t arc4_128_info = {
|
||||
MBEDTLS_CIPHER_ARC4_128,
|
||||
MBEDTLS_MODE_STREAM,
|
||||
128,
|
||||
"ARC4-128",
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
&arc4_base_info
|
||||
};
|
||||
#endif /* MBEDTLS_ARC4_C */
|
||||
|
||||
#if defined(MBEDTLS_CHACHA20_C)
|
||||
|
||||
static int chacha20_setkey_wrap( void *ctx, const unsigned char *key,
|
||||
@ -2285,23 +2058,6 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] =
|
||||
#endif
|
||||
#endif /* MBEDTLS_AES_C */
|
||||
|
||||
#if defined(MBEDTLS_ARC4_C)
|
||||
{ MBEDTLS_CIPHER_ARC4_128, &arc4_128_info },
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_BLOWFISH_C)
|
||||
{ MBEDTLS_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info },
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
{ MBEDTLS_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info },
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
{ MBEDTLS_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info },
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
{ MBEDTLS_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info },
|
||||
#endif
|
||||
#endif /* MBEDTLS_BLOWFISH_C */
|
||||
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
{ MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info },
|
||||
{ MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info },
|
||||
|
Reference in New Issue
Block a user