Skip to content

Commit 20e2e33

Browse files
authored
Merge pull request #7939 from SparkiDev/thumb2_poly1305
undefined
2 parents 75c6633 + 27033c2 commit 20e2e33

12 files changed

Lines changed: 2511 additions & 42 deletions

File tree

src/include.am

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,12 @@ if !BUILD_FIPS_RAND
922922
if BUILD_POLY1305
923923
if BUILD_ARMASM
924924
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-poly1305.c
925+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-poly1305.c
926+
if BUILD_ARMASM_INLINE
927+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-poly1305-asm_c.c
928+
else
929+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-poly1305-asm.S
930+
endif !BUILD_ARMASM_INLINE
925931
endif
926932
if BUILD_RISCV_ASM
927933
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-poly1305.c
@@ -996,6 +1002,14 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/chacha.c
9961002
if BUILD_ARMASM_NEON
9971003
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-chacha.c
9981004
else
1005+
if BUILD_ARMASM
1006+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-chacha.c
1007+
if BUILD_ARMASM_INLINE
1008+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-chacha-asm_c.c
1009+
else
1010+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-chacha-asm.S
1011+
endif !BUILD_ARMASM_INLINE
1012+
endif BUILD_ARMASM
9991013
if BUILD_RISCV_ASM
10001014
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/riscv/riscv-64-chacha.c
10011015
endif BUILD_RISCV_ASM

wolfcrypt/src/chacha.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ Public domain.
7272
#endif /* HAVE_CHACHA */
7373

7474

75-
#if defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_ARMASM_NO_NEON)
75+
#if defined(WOLFSSL_ARMASM) && (!defined(WOLFSSL_ARMASM_NO_NEON) || \
76+
defined(__thumb__))
7677
/* implementation is located in wolfcrypt/src/port/arm/armv8-chacha.c */
7778

7879
#elif defined(WOLFSSL_RISCV_ASM)

wolfcrypt/src/poly1305.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ extern void poly1305_final_avx2(Poly1305* ctx, byte* mac);
231231
p[7] = (byte)(v >> 56);
232232
}
233233
#endif/* !WOLFSSL_ARMASM && !WOLFSSL_RISCV_ASM */
234-
#else /* if not 64 bit then use 32 bit */
234+
/* if not 64 bit then use 32 bit */
235+
#elif !defined(WOLFSSL_ARMASM) || !defined(__thumb__)
235236

236237
static word32 U8TO32(const byte *p)
237238
{
@@ -268,8 +269,8 @@ static WC_INLINE void u32tole64(const word32 inLe32, byte outLe64[8])
268269
}
269270

270271

271-
#if (!defined(WOLFSSL_ARMASM) || !defined(__aarch64__)) && \
272-
!defined(WOLFSSL_RISCV_ASM)
272+
#if (!defined(WOLFSSL_ARMASM) || (!defined(__aarch64__) && \
273+
!defined(__thumb__))) && !defined(WOLFSSL_RISCV_ASM)
273274
/*
274275
This local function operates on a message with a given number of bytes
275276
with a given ctx pointer to a Poly1305 structure.
@@ -788,7 +789,8 @@ int wc_Poly1305Final(Poly1305* ctx, byte* mac)
788789

789790
return 0;
790791
}
791-
#endif /* (!WOLFSSL_ARMASM || !__aarch64__) && !WOLFSSL_RISCV_ASM */
792+
#endif /* (!WOLFSSL_ARMASM || (!__aarch64__ && !__thumb__)) &&
793+
* !WOLFSSL_RISCV_ASM */
792794

793795

794796
int wc_Poly1305Update(Poly1305* ctx, const byte* m, word32 bytes)
@@ -883,8 +885,8 @@ int wc_Poly1305Update(Poly1305* ctx, const byte* m, word32 bytes)
883885
/* process full blocks */
884886
if (bytes >= POLY1305_BLOCK_SIZE) {
885887
size_t want = ((size_t)bytes & ~((size_t)POLY1305_BLOCK_SIZE - 1));
886-
#if (!defined(WOLFSSL_ARMASM) || !defined(__aarch64__)) && \
887-
!defined(WOLFSSL_RISCV_ASM)
888+
#if (!defined(WOLFSSL_ARMASM) || (!defined(__aarch64__) && \
889+
!defined(__thumb__))) && !defined(WOLFSSL_RISCV_ASM)
888890
int ret;
889891
ret = poly1305_blocks(ctx, m, want);
890892
if (ret != 0)

0 commit comments

Comments
 (0)