mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 08:16:33 +01:00
Merge CCM cipher mode and ciphersuites
Conflicts: library/ssl_tls.c
This commit is contained in:
commit
b5212b436f
27 changed files with 3533 additions and 246 deletions
|
|
@ -47,6 +47,7 @@
|
|||
#include "polarssl/blowfish.h"
|
||||
#include "polarssl/camellia.h"
|
||||
#include "polarssl/gcm.h"
|
||||
#include "polarssl/ccm.h"
|
||||
#include "polarssl/havege.h"
|
||||
#include "polarssl/ctr_drbg.h"
|
||||
#include "polarssl/hmac_drbg.h"
|
||||
|
|
@ -157,14 +158,14 @@ unsigned char buf[BUFSIZE];
|
|||
|
||||
typedef struct {
|
||||
char md4, md5, ripemd160, sha1, sha256, sha512,
|
||||
arc4, des3, des, aes_cbc, aes_gcm, camellia, blowfish,
|
||||
arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,
|
||||
havege, ctr_drbg, hmac_drbg,
|
||||
rsa, dhm, ecdsa, ecdh;
|
||||
} todo_list;
|
||||
|
||||
#define OPTIONS \
|
||||
"md4, md5, ripemd160, sha1, sha256, sha512,\n" \
|
||||
"arc4, des3, des, aes_cbc, aes_gcm, camellia, blowfish,\n" \
|
||||
"arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,\n" \
|
||||
"havege, ctr_drbg, hmac_drbg\n" \
|
||||
"rsa, dhm, ecdsa, ecdh.\n"
|
||||
|
||||
|
|
@ -205,6 +206,8 @@ int main( int argc, char *argv[] )
|
|||
todo.aes_cbc = 1;
|
||||
else if( strcmp( argv[i], "aes_gcm" ) == 0 )
|
||||
todo.aes_gcm = 1;
|
||||
else if( strcmp( argv[i], "aes_ccm" ) == 0 )
|
||||
todo.aes_ccm = 1;
|
||||
else if( strcmp( argv[i], "camellia" ) == 0 )
|
||||
todo.camellia = 1;
|
||||
else if( strcmp( argv[i], "blowfish" ) == 0 )
|
||||
|
|
@ -226,7 +229,7 @@ int main( int argc, char *argv[] )
|
|||
else
|
||||
{
|
||||
printf( "Unrecognized option: %s\n", argv[i] );
|
||||
printf( "Available options:" OPTIONS );
|
||||
printf( "Available options: " OPTIONS );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -331,6 +334,26 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(POLARSSL_CCM_C)
|
||||
if( todo.aes_ccm )
|
||||
{
|
||||
ccm_context ccm;
|
||||
for( keysize = 128; keysize <= 256; keysize += 64 )
|
||||
{
|
||||
snprintf( title, sizeof( title ), "AES-CCM-%d", keysize );
|
||||
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
memset( tmp, 0, sizeof( tmp ) );
|
||||
ccm_init( &ccm, POLARSSL_CIPHER_ID_AES, tmp, keysize );
|
||||
|
||||
TIME_AND_TSC( title,
|
||||
ccm_encrypt_and_tag( &ccm, BUFSIZE, tmp,
|
||||
12, NULL, 0, buf, buf, tmp, 16 ) );
|
||||
|
||||
ccm_free( &ccm );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_CAMELLIA_C) && defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "polarssl/ctr_drbg.h"
|
||||
#include "polarssl/dhm.h"
|
||||
#include "polarssl/gcm.h"
|
||||
#include "polarssl/ccm.h"
|
||||
#include "polarssl/md2.h"
|
||||
#include "polarssl/md4.h"
|
||||
#include "polarssl/md5.h"
|
||||
|
|
@ -132,11 +133,16 @@ int main( int argc, char *argv[] )
|
|||
return( ret );
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_GCM_C)
|
||||
#if defined(POLARSSL_GCM_C) && defined(POLARSSL_AES_C)
|
||||
if( ( ret = gcm_self_test( v ) ) != 0 )
|
||||
return( ret );
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_CCM_C) && defined(POLARSSL_AES_C)
|
||||
if( ( ret = ccm_self_test( v ) ) != 0 )
|
||||
return( ret );
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_BASE64_C)
|
||||
if( ( ret = base64_self_test( v ) ) != 0 )
|
||||
return( ret );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue