Skip to content

Commit 5656623

Browse files
authored
Merge pull request #240 from Ko-/development
Enable 64-bit bignum limbs and add optimized multiplication for Aarch64
2 parents f66e7ea + cb260bb commit 5656623

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

include/mbedtls/bignum.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@
129129
defined(__ppc64__) || defined(__powerpc64__) || \
130130
defined(__ia64__) || defined(__alpha__) || \
131131
( defined(__sparc__) && defined(__arch64__) ) || \
132-
defined(__s390x__) || defined(__mips64) )
132+
defined(__s390x__) || defined(__mips64) || \
133+
defined(__aarch64__) )
133134
#if !defined(MBEDTLS_HAVE_INT64)
134135
#define MBEDTLS_HAVE_INT64
135136
#endif /* MBEDTLS_HAVE_INT64 */

include/mbedtls/bn_mul.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,30 @@
198198

199199
#endif /* AMD64 */
200200

201+
#if defined(__aarch64__)
202+
203+
#define MULADDC_INIT \
204+
asm(
205+
206+
#define MULADDC_CORE \
207+
"ldr x4, [%2], #8 \n\t" \
208+
"ldr x5, [%1] \n\t" \
209+
"mul x6, x4, %3 \n\t" \
210+
"umulh x7, x4, %3 \n\t" \
211+
"adds x5, x5, x6 \n\t" \
212+
"adc x7, x7, xzr \n\t" \
213+
"adds x5, x5, %0 \n\t" \
214+
"adc %0, x7, xzr \n\t" \
215+
"str x5, [%1], #8 \n\t"
216+
217+
#define MULADDC_STOP \
218+
: "+r" (c), "+r" (d), "+r" (s) \
219+
: "r" (b) \
220+
: "x4", "x5", "x6", "x7", "cc" \
221+
);
222+
223+
#endif /* Aarch64 */
224+
201225
#if defined(__mc68020__) || defined(__mcpu32__)
202226

203227
#define MULADDC_INIT \

0 commit comments

Comments
 (0)