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

@ -1,6 +1,7 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_MBEDTLS_PLATFORM_H_
#define COSMOPOLITAN_THIRD_PARTY_MBEDTLS_PLATFORM_H_
#include "libc/assert.h"
#include "libc/bits/likely.h"
#include "libc/calls/weirdtypes.h"
#include "libc/fmt/fmt.h"
#include "libc/mem/mem.h"
@ -34,7 +35,7 @@ COSMOPOLITAN_C_START_
#define MBEDTLS_INTERNAL_VALIDATE_RET(cond, ret) \
do { \
if (!(cond)) { \
if (UNLIKELY(!(cond))) { \
MBEDTLS_PARAM_FAILED(cond); \
return ret; \
} \
@ -42,7 +43,7 @@ COSMOPOLITAN_C_START_
#define MBEDTLS_INTERNAL_VALIDATE(cond) \
do { \
if (!(cond)) { \
if (UNLIKELY(!(cond))) { \
MBEDTLS_PARAM_FAILED(cond); \
return; \
} \