mirror of
				https://github.com/yuzu-emu/mbedtls.git
				synced 2025-11-04 06:14:53 +00:00 
			
		
		
		
	benchmark: Add AES-XTS benchmark
This commit is contained in:
		
							parent
							
								
									e4daf77c2e
								
							
						
					
					
						commit
						c00cac79be
					
				| 
						 | 
					@ -94,7 +94,7 @@ int main( void )
 | 
				
			||||||
#define OPTIONS                                                         \
 | 
					#define OPTIONS                                                         \
 | 
				
			||||||
    "md4, md5, ripemd160, sha1, sha256, sha512,\n"                      \
 | 
					    "md4, md5, ripemd160, sha1, sha256, sha512,\n"                      \
 | 
				
			||||||
    "arc4, des3, des, camellia, blowfish,\n"                            \
 | 
					    "arc4, des3, des, camellia, blowfish,\n"                            \
 | 
				
			||||||
    "aes_cbc, aes_gcm, aes_ccm, aes_cmac, des3_cmac,\n"                 \
 | 
					    "aes_cbc, aes_gcm, aes_ccm, aes_cmac, aes_xts, des3_cmac,\n"        \
 | 
				
			||||||
    "havege, ctr_drbg, hmac_drbg\n"                                     \
 | 
					    "havege, ctr_drbg, hmac_drbg\n"                                     \
 | 
				
			||||||
    "rsa, dhm, ecdsa, ecdh.\n"
 | 
					    "rsa, dhm, ecdsa, ecdh.\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -228,7 +228,7 @@ unsigned char buf[BUFSIZE];
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    char md4, md5, ripemd160, sha1, sha256, sha512,
 | 
					    char md4, md5, ripemd160, sha1, sha256, sha512,
 | 
				
			||||||
         arc4, des3, des,
 | 
					         arc4, des3, des,
 | 
				
			||||||
         aes_cbc, aes_gcm, aes_ccm, aes_cmac, des3_cmac,
 | 
					         aes_cbc, aes_gcm, aes_ccm, aes_cmac, aes_xts, des3_cmac,
 | 
				
			||||||
         camellia, blowfish,
 | 
					         camellia, blowfish,
 | 
				
			||||||
         havege, ctr_drbg, hmac_drbg,
 | 
					         havege, ctr_drbg, hmac_drbg,
 | 
				
			||||||
         rsa, dhm, ecdsa, ecdh;
 | 
					         rsa, dhm, ecdsa, ecdh;
 | 
				
			||||||
| 
						 | 
					@ -280,6 +280,8 @@ int main( int argc, char *argv[] )
 | 
				
			||||||
                todo.aes_ccm = 1;
 | 
					                todo.aes_ccm = 1;
 | 
				
			||||||
            else if( strcmp( argv[i], "aes_cmac" ) == 0 )
 | 
					            else if( strcmp( argv[i], "aes_cmac" ) == 0 )
 | 
				
			||||||
                todo.aes_cmac = 1;
 | 
					                todo.aes_cmac = 1;
 | 
				
			||||||
 | 
					            else if( strcmp( argv[i], "aes_xts" ) == 0 )
 | 
				
			||||||
 | 
					                todo.aes_xts = 1;
 | 
				
			||||||
            else if( strcmp( argv[i], "des3_cmac" ) == 0 )
 | 
					            else if( strcmp( argv[i], "des3_cmac" ) == 0 )
 | 
				
			||||||
                todo.des3_cmac = 1;
 | 
					                todo.des3_cmac = 1;
 | 
				
			||||||
            else if( strcmp( argv[i], "camellia" ) == 0 )
 | 
					            else if( strcmp( argv[i], "camellia" ) == 0 )
 | 
				
			||||||
| 
						 | 
					@ -496,6 +498,29 @@ int main( int argc, char *argv[] )
 | 
				
			||||||
                                                output ) );
 | 
					                                                output ) );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif /* MBEDTLS_CMAC_C */
 | 
					#endif /* MBEDTLS_CMAC_C */
 | 
				
			||||||
 | 
					#if defined(MBEDTLS_CIPHER_MODE_XTS)
 | 
				
			||||||
 | 
					    if( todo.aes_xts )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int keysize;
 | 
				
			||||||
 | 
					        mbedtls_aes_xts_context ctx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mbedtls_aes_xts_init( &ctx );
 | 
				
			||||||
 | 
					        for( keysize = 128; keysize <= 256; keysize += 64 )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mbedtls_snprintf( title, sizeof( title ), "AES-XTS-%d", keysize );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            memset( buf, 0, sizeof( buf ) );
 | 
				
			||||||
 | 
					            memset( tmp, 0, sizeof( tmp ) );
 | 
				
			||||||
 | 
					            mbedtls_aes_xts_setkey_enc( &ctx, tmp, keysize * 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            TIME_AND_TSC( title,
 | 
				
			||||||
 | 
					                    mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, BUFSIZE,
 | 
				
			||||||
 | 
					                                           tmp, buf, buf ) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            mbedtls_aes_xts_free( &ctx );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif /* MBEDTLS_CIPHER_MODE_XTS */
 | 
				
			||||||
#endif /* MBEDTLS_AES_C */
 | 
					#endif /* MBEDTLS_AES_C */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(MBEDTLS_CAMELLIA_C) && defined(MBEDTLS_CIPHER_MODE_CBC)
 | 
					#if defined(MBEDTLS_CAMELLIA_C) && defined(MBEDTLS_CIPHER_MODE_CBC)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue