Make GCM AES faster

13.22% mbedtls_aesni_gcm_mult
    13.03% mbedtls_gcm_update
     9.85% mbedtls_aesni_crypt_ecb

Overhead improvement (perf record)

    10.97% mbedtls_aesni_gcm_mult
    10.59% mbedtls_aesni_crypt_ecb
     2.26% mbedtls_gcm_update
This commit is contained in:
Justine Tunney 2021-07-06 07:07:18 -07:00
parent f8b9bd2b47
commit e51034bab3
10 changed files with 452 additions and 640 deletions

View file

@ -93,18 +93,18 @@ forceinline unsigned char mbedtls_base64_eq( size_t in_a, size_t in_b )
/*
* Constant flow lookup into table.
*/
static unsigned char mbedtls_base64_table_lookup( const unsigned char * const table,
const size_t table_size,
const size_t table_index )
static inline unsigned char mbedtls_base64_table_lookup( const unsigned char * const table,
const size_t table_size,
const size_t table_index )
{
return 0 <= table_index && table_index < table_size ? table[table_index] : 127;
/* come on really? */
size_t i;
unsigned char result = 0;
for( i = 0; i < table_size; ++i )
{
mbedtls_base64_cond_assign_uchar( &result, &table[i], mbedtls_base64_eq( i, table_index ) );
}
return result;
}