mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:35:44 +01:00
Allow detection of CLMUL
This commit is contained in:
parent
5b685653ef
commit
8eaf20b18d
@ -29,6 +29,9 @@
|
||||
|
||||
#include "aes.h"
|
||||
|
||||
#define POLARSSL_AESNI_AES 0x02000000u
|
||||
#define POLARSSL_AESNI_CLMUL 0x00000002u
|
||||
|
||||
#if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && \
|
||||
( defined(__amd64__) || defined(__x86_64__) ) && \
|
||||
! defined(POLARSSL_HAVE_X86_64)
|
||||
@ -38,11 +41,14 @@
|
||||
#if defined(POLARSSL_HAVE_X86_64)
|
||||
|
||||
/**
|
||||
* \brief AES-NI detection routine
|
||||
* \brief AES-NI features detection routine
|
||||
*
|
||||
* \return 1 if CPU supports AES-NI, 0 otherwise
|
||||
* \param what The feature to detect
|
||||
* (POLARSSL_AESNI_AES or POLARSSL_AESNI_CLMUL)
|
||||
*
|
||||
* \return 1 if CPU has support for the feature, 0 otherwise
|
||||
*/
|
||||
int aesni_supported( void );
|
||||
int aesni_supports( unsigned int what );
|
||||
|
||||
/**
|
||||
* \brief AES-NI AES-ECB block en(de)cryption
|
||||
|
@ -677,7 +677,7 @@ int aes_crypt_ecb( aes_context *ctx,
|
||||
uint32_t *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
|
||||
|
||||
#if defined(POLARSSL_AESNI_C) && defined(POLARSSL_HAVE_X86_64)
|
||||
if( aesni_supported() )
|
||||
if( aesni_supports( POLARSSL_AESNI_AES ) )
|
||||
return( aesni_crypt_ecb( ctx, mode, input, output ) );
|
||||
#endif
|
||||
|
||||
|
@ -37,24 +37,24 @@
|
||||
#if defined(POLARSSL_HAVE_X86_64)
|
||||
|
||||
/*
|
||||
* AES-NI support detection routine, [AES-WP] figure 23
|
||||
* AES-NI support detection routine
|
||||
*/
|
||||
int aesni_supported( void )
|
||||
int aesni_supports( unsigned int what )
|
||||
{
|
||||
static int supported = -1;
|
||||
unsigned int c;
|
||||
static int done = 0;
|
||||
static unsigned int c = 0;
|
||||
|
||||
if( supported == -1 )
|
||||
if( ! done )
|
||||
{
|
||||
asm( "movl $1, %%eax \n"
|
||||
"cpuid \n"
|
||||
: "=c" (c)
|
||||
:
|
||||
: "eax", "ebx", "edx" );
|
||||
supported = ( ( c & 0x02000000 ) != 0 );
|
||||
done = 1;
|
||||
}
|
||||
|
||||
return( supported );
|
||||
return( ( c & what ) != 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user