mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-04 09:59:47 +00:00
ARMv8 Crypto Extensions hooks for AES and GCM
This commit is contained in:
parent
dfb6015ca7
commit
63f213969c
|
@ -39,7 +39,9 @@
|
|||
#if defined(MBEDTLS_AESNI_C)
|
||||
#include "mbedtls/aesni.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ARMV8CE_AES_C)
|
||||
#include "mbedtls/armv8ce_aes.h"
|
||||
#endif
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
|
@ -1037,6 +1039,11 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
|
|||
return( mbedtls_aesni_crypt_ecb( ctx, mode, input, output ) );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ARMV8CE_AES_C)
|
||||
// We don't do runtime checking for ARMv8 Crypto Extensions
|
||||
return mbedtls_armv8ce_aes_crypt_ecb( ctx, mode, input, output );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86)
|
||||
if( aes_padlock_ace )
|
||||
{
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
#include "mbedtls/aesni.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ARMV8CE_AES_C)
|
||||
#include "mbedtls/armv8ce_aes.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
|
||||
#include "mbedtls/aes.h"
|
||||
#include "mbedtls/platform.h"
|
||||
|
@ -110,6 +114,12 @@ static int gcm_gen_table( mbedtls_gcm_context *ctx )
|
|||
if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, h, 16, h, &olen ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
#if defined(MBEDTLS_ARMV8CE_AES_C)
|
||||
// we don't do feature testing with ARMv8 cryptography extensions
|
||||
memcpy( ctx ->HL, h, 16 ); // put H at the beginning of buffer
|
||||
return( 0 ); // that's all we need
|
||||
#endif
|
||||
|
||||
/* pack h as two 64-bits ints, big-endian */
|
||||
GET_UINT32_BE( hi, h, 0 );
|
||||
GET_UINT32_BE( lo, h, 4 );
|
||||
|
@ -219,6 +229,11 @@ static void gcm_mult( mbedtls_gcm_context *ctx, const unsigned char x[16],
|
|||
unsigned char lo, hi, rem;
|
||||
uint64_t zh, zl;
|
||||
|
||||
#if defined(MBEDTLS_ARMV8CE_AES_C)
|
||||
mbedtls_armv8ce_gcm_mult( output, x, (const unsigned char *) ctx->HL );
|
||||
return;
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
|
||||
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) ) {
|
||||
unsigned char h[16];
|
||||
|
|
Loading…
Reference in a new issue