From 02419e248f0399308d7c695c9776c72ad5972af1 Mon Sep 17 00:00:00 2001 From: julek-wolfssl <49391366+julek-wolfssl@users.noreply.github.com> Date: Mon, 9 Sep 2019 02:46:48 -0700 Subject: [PATCH] Fix clang 3.8 arm (#2449) * Fix 'value size does not match register size' error in clang with arm assembly * More readable casting --- wolfcrypt/src/port/arm/armv8-chacha.c | 7 ++++--- wolfcrypt/src/port/arm/armv8-poly1305.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wolfcrypt/src/port/arm/armv8-chacha.c b/wolfcrypt/src/port/arm/armv8-chacha.c index 21affce39..09d6c4785 100644 --- a/wolfcrypt/src/port/arm/armv8-chacha.c +++ b/wolfcrypt/src/port/arm/armv8-chacha.c @@ -198,7 +198,7 @@ static WC_INLINE void wc_Chacha_encrypt_320(const word32* input, const byte* m, #ifdef CHACHA_TEST printf("Entering wc_Chacha_encrypt_320 with %d bytes\n", bytes); #endif /*CHACHA_TEST */ - + word64 bytes64 = (word64) bytes; __asm__ __volatile__ ( /* * The layout of used registers is: @@ -601,7 +601,7 @@ static WC_INLINE void wc_Chacha_encrypt_320(const word32* input, const byte* m, "ADD v28.4s, v28.4s, v29.4s \n\t" "BNE L_chacha20_arm64_outer_%= \n\t" : [input] "+r" (input), [m] "+r" (m), [c] "+r" (c), - [bytes] "+r" (bytes) + [bytes] "+r" (bytes64) : [L_chacha20_neon_add_all_counters] "r" (L_chacha20_neon_add_all_counters), [L_chacha20_neon_rol8] "r" (L_chacha20_neon_rol8) : "memory", "cc", @@ -1680,6 +1680,7 @@ static WC_INLINE void wc_Chacha_encrypt_64(const word32* input, const byte* m, #endif /*CHACHA_TEST */ #ifdef __aarch64__ + word64 bytes64 = (word64) bytes; __asm__ __volatile__ ( /* Load index look-up for rotating left 8 bits */ "LD1 {v13.16B}, [%[L_chacha20_neon_rol8]] \n\t" @@ -2198,7 +2199,7 @@ static WC_INLINE void wc_Chacha_encrypt_64(const word32* input, const byte* m, "BGE L_chacha20_arm64_64_loop_lt_8_%= \n\t" "\n" "L_chacha20_arm64_64_done_%=: \n\t" - : [input] "+r" (input), [m] "+r" (m), [c] "+r" (c), [bytes] "+r" (bytes) + : [input] "+r" (input), [m] "+r" (m), [c] "+r" (c), [bytes] "+r" (bytes64) : [L_chacha20_neon_rol8] "r" (L_chacha20_neon_rol8), [L_chacha20_neon_inc_first_word] "r" (L_chacha20_neon_inc_first_word) : "memory", "x4", "x5", "x6", "x7", "v0", "v1", "v2", "v3", diff --git a/wolfcrypt/src/port/arm/armv8-poly1305.c b/wolfcrypt/src/port/arm/armv8-poly1305.c index fb770a4de..b257c8b45 100644 --- a/wolfcrypt/src/port/arm/armv8-poly1305.c +++ b/wolfcrypt/src/port/arm/armv8-poly1305.c @@ -178,7 +178,7 @@ static WC_INLINE void poly1305_blocks_16(Poly1305* ctx, const unsigned char *m, : [POLY1305_BLOCK_SIZE] "I" (POLY1305_BLOCK_SIZE), [ctx_r] "m" (ctx->r[0]), [ctx_r_4] "m" (ctx->r[4]), - [finished] "r" (ctx->finished) + [finished] "r" ((word64)ctx->finished) : "memory", "cc", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w15", "w21", "w22", "w23", "w24", "w25", "x2", "x3", "x4", "x5", "x6", @@ -858,7 +858,7 @@ void poly1305_blocks(Poly1305* ctx, const unsigned char *m, [r] "r" (ctx->r), [r_2] "r" (ctx->r_2), [r_4] "r" (ctx->r_4), - [finished] "r" (ctx->finished) + [finished] "r" ((word64)ctx->finished) : "memory", "cc", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19",