mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-10 17:01:41 +08:00
Make use of optimised bswap from ARIA
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
6d23ff60dd
commit
2d0f27d0fc
@ -98,47 +98,8 @@ static inline uint32_t aria_p1( uint32_t x )
|
|||||||
* modify byte order: ( A B C D ) -> ( D C B A ), i.e. change endianness
|
* modify byte order: ( A B C D ) -> ( D C B A ), i.e. change endianness
|
||||||
*
|
*
|
||||||
* This is submatrix P3 in [1] Appendix B.1
|
* This is submatrix P3 in [1] Appendix B.1
|
||||||
*
|
|
||||||
* Some compilers fail to translate this to a single instruction,
|
|
||||||
* so let's provide asm versions for common platforms with C fallback.
|
|
||||||
*/
|
*/
|
||||||
#if defined(MBEDTLS_HAVE_ASM)
|
#define ARIA_P3(x) MBEDTLS_BSWAP32(x)
|
||||||
#if defined(__arm__) /* rev available from v6 up */
|
|
||||||
/* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */
|
|
||||||
#if defined(__GNUC__) && \
|
|
||||||
( !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000 ) && \
|
|
||||||
__ARM_ARCH >= 6
|
|
||||||
static inline uint32_t aria_p3( uint32_t x )
|
|
||||||
{
|
|
||||||
uint32_t r;
|
|
||||||
__asm( "rev %0, %1" : "=l" (r) : "l" (x) );
|
|
||||||
return( r );
|
|
||||||
}
|
|
||||||
#define ARIA_P3 aria_p3
|
|
||||||
#elif defined(__ARMCC_VERSION) && __ARMCC_VERSION < 6000000 && \
|
|
||||||
( __TARGET_ARCH_ARM >= 6 || __TARGET_ARCH_THUMB >= 3 )
|
|
||||||
static inline uint32_t aria_p3( uint32_t x )
|
|
||||||
{
|
|
||||||
uint32_t r;
|
|
||||||
__asm( "rev r, x" );
|
|
||||||
return( r );
|
|
||||||
}
|
|
||||||
#define ARIA_P3 aria_p3
|
|
||||||
#endif
|
|
||||||
#endif /* arm */
|
|
||||||
#if defined(__GNUC__) && \
|
|
||||||
defined(__i386__) || defined(__amd64__) || defined( __x86_64__)
|
|
||||||
static inline uint32_t aria_p3( uint32_t x )
|
|
||||||
{
|
|
||||||
__asm( "bswap %0" : "=r" (x) : "0" (x) );
|
|
||||||
return( x );
|
|
||||||
}
|
|
||||||
#define ARIA_P3 aria_p3
|
|
||||||
#endif /* x86 gnuc */
|
|
||||||
#endif /* MBEDTLS_HAVE_ASM && GNUC */
|
|
||||||
#if !defined(ARIA_P3)
|
|
||||||
#define ARIA_P3(x) ARIA_P2( ARIA_P1 ( x ) )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ARIA Affine Transform
|
* ARIA Affine Transform
|
||||||
|
Loading…
x
Reference in New Issue
Block a user