1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

fix(crypto): fix build on clang/arm64

This commit is contained in:
Pavol Rusnak 2020-12-17 00:07:41 +01:00
parent acf7294ca2
commit 78be2c9cac
4 changed files with 15 additions and 3 deletions

View File

@ -124,8 +124,8 @@ fuzzer: fuzzer/fuzzer.o $(OBJS)
$(CC) $(CFLAGS) fuzzer/fuzzer.o $(OBJS) -o fuzzer/fuzzer $(CC) $(CFLAGS) fuzzer/fuzzer.o $(OBJS) -o fuzzer/fuzzer
clean: clean:
rm -f *.o aes/*.o chacha20poly1305/*.o ed25519-donna/*.o rm -f *.o aes/*.o chacha20poly1305/*.o ed25519-donna/*.o monero/*.o
rm -f tests/test_check tests/test_speed tests/test_openssl tests/libtrezor-crypto.so tests/aestst rm -f tests/*.o tests/test_check tests/test_speed tests/test_openssl tests/libtrezor-crypto.so tests/aestst
rm -f tools/*.o tools/xpubaddrgen tools/mktable tools/bip39bruteforce rm -f tools/*.o tools/xpubaddrgen tools/mktable tools/bip39bruteforce
rm -f fuzzer/*.o fuzzer/fuzzer rm -f fuzzer/*.o fuzzer/fuzzer

View File

@ -108,8 +108,12 @@ void cycles(volatile uint64_t *rtn)
cpuid cpuid
} }
#elif defined( __GNUC__ ) #elif defined( __GNUC__ )
#if defined(__aarch64__)
__asm__ __volatile__("mrs %0, cntvct_el0": "=r" (*rtn));
#else
__asm__ __volatile__("rdtsc": "=A" (*rtn)); __asm__ __volatile__("rdtsc": "=A" (*rtn));
#endif #endif
#endif
} }
int main(void) int main(void)

View File

@ -29,7 +29,7 @@ static const char tau[16] = "expand 16-byte k";
void ECRYPT_keysetup(ECRYPT_ctx *x,const u8 *k,u32 kbits,u32 ivbits) void ECRYPT_keysetup(ECRYPT_ctx *x,const u8 *k,u32 kbits,u32 ivbits)
{ {
(void)ivbits; (void)ivbits;
const char *constants = NULL; const char *constants = (const char *)0;
x->input[4] = U8TO32_LITTLE(k + 0); x->input[4] = U8TO32_LITTLE(k + 0);
x->input[5] = U8TO32_LITTLE(k + 4); x->input[5] = U8TO32_LITTLE(k + 4);

View File

@ -106,6 +106,14 @@ typedef int64_t sph_s64;
#define SPH_DETECT_LITTLE_ENDIAN 1 #define SPH_DETECT_LITTLE_ENDIAN 1
#define SPH_DETECT_BIG_ENDIAN 0 #define SPH_DETECT_BIG_ENDIAN 0
/*
* ARM64, little-endian.
*/
#elif defined __aarch64__
#define SPH_DETECT_LITTLE_ENDIAN 1
#define SPH_DETECT_BIG_ENDIAN 0
#endif #endif