Skip to content

Commit 0786aa2

Browse files
authored
Merge pull request #9464 from SparkiDev/sp_384_sub_fix
SP Thumb2/ARM32: P-384 sub not needed for small builds
2 parents d49c769 + 46c704f commit 0786aa2

File tree

2 files changed

+4
-111
lines changed

2 files changed

+4
-111
lines changed

wolfcrypt/src/sp_arm32.c

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -92181,58 +92181,7 @@ WC_OMIT_FRAME_POINTER static void sp_384_mont_tpl_12(sp_digit* r,
9218192181
);
9218292182
}
9218392183

92184-
#ifdef WOLFSSL_SP_SMALL
92185-
/* Sub b from a into r. (r = a - b)
92186-
*
92187-
* r A single precision integer.
92188-
* a A single precision integer.
92189-
* b A single precision integer.
92190-
*/
92191-
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
92192-
WC_OMIT_FRAME_POINTER static sp_digit sp_384_sub_12(sp_digit* r_p,
92193-
const sp_digit* a_p, const sp_digit* b_p)
92194-
#else
92195-
WC_OMIT_FRAME_POINTER static sp_digit sp_384_sub_12(sp_digit* r,
92196-
const sp_digit* a, const sp_digit* b)
92197-
#endif /* WOLFSSL_NO_VAR_ASSIGN_REG */
92198-
{
92199-
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
92200-
register sp_digit* r asm ("r0") = (sp_digit*)r_p;
92201-
register const sp_digit* a asm ("r1") = (const sp_digit*)a_p;
92202-
register const sp_digit* b asm ("r2") = (const sp_digit*)b_p;
92203-
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
92204-
92205-
__asm__ __volatile__ (
92206-
"mov r12, #0\n\t"
92207-
"add lr, %[a], #48\n\t"
92208-
"\n"
92209-
"L_sp_384_sub_12_word_%=: \n\t"
92210-
"rsbs r12, r12, #0\n\t"
92211-
"ldm %[a]!, {r3, r4, r5, r6}\n\t"
92212-
"ldm %[b]!, {r7, r8, r9, r10}\n\t"
92213-
"sbcs r3, r3, r7\n\t"
92214-
"sbcs r4, r4, r8\n\t"
92215-
"sbcs r5, r5, r9\n\t"
92216-
"sbcs r6, r6, r10\n\t"
92217-
"stm %[r]!, {r3, r4, r5, r6}\n\t"
92218-
"sbc r12, r3, r3\n\t"
92219-
"cmp %[a], lr\n\t"
92220-
"bne L_sp_384_sub_12_word_%=\n\t"
92221-
"mov %[r], r12\n\t"
92222-
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
92223-
: [r] "+r" (r), [a] "+r" (a), [b] "+r" (b)
92224-
:
92225-
#else
92226-
:
92227-
: [r] "r" (r), [a] "r" (a), [b] "r" (b)
92228-
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
92229-
: "memory", "cc", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
92230-
"r12", "lr"
92231-
);
92232-
return (word32)(size_t)r;
92233-
}
92234-
92235-
#else
92184+
#ifndef WOLFSSL_SP_SMALL
9223692185
/* Sub b from a into r. (r = a - b)
9223792186
*
9223892187
* r A single precision integer.
@@ -92288,7 +92237,7 @@ WC_OMIT_FRAME_POINTER static sp_digit sp_384_sub_12(sp_digit* r,
9228892237
return (word32)(size_t)r;
9228992238
}
9229092239

92291-
#endif /* WOLFSSL_SP_SMALL */
92240+
#endif /* !WOLFSSL_SP_SMALL */
9229292241
#ifdef WOLFSSL_SP_SMALL
9229392242
/* Conditionally add a and b using the mask m.
9229492243
* m is -1 to add and 0 when not.

wolfcrypt/src/sp_cortexm.c

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -45506,63 +45506,7 @@ WC_OMIT_FRAME_POINTER SP_NOINLINE static void sp_384_mont_tpl_12(sp_digit* r,
4550645506
);
4550745507
}
4550845508

45509-
#ifdef WOLFSSL_SP_SMALL
45510-
/* Sub b from a into r. (r = a - b)
45511-
*
45512-
* r A single precision integer.
45513-
* a A single precision integer.
45514-
* b A single precision integer.
45515-
*/
45516-
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
45517-
WC_OMIT_FRAME_POINTER static sp_digit sp_384_sub_12(sp_digit* r_p,
45518-
const sp_digit* a_p, const sp_digit* b_p)
45519-
#else
45520-
WC_OMIT_FRAME_POINTER static sp_digit sp_384_sub_12(sp_digit* r,
45521-
const sp_digit* a, const sp_digit* b)
45522-
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
45523-
{
45524-
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
45525-
register sp_digit* r __asm__ ("r0") = (sp_digit*)r_p;
45526-
register const sp_digit* a __asm__ ("r1") = (const sp_digit*)a_p;
45527-
register const sp_digit* b __asm__ ("r2") = (const sp_digit*)b_p;
45528-
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
45529-
45530-
__asm__ __volatile__ (
45531-
"MOV r11, #0x0\n\t"
45532-
"ADD r12, %[a], #0x30\n\t"
45533-
"\n"
45534-
#if defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000)
45535-
"L_sp_384_sub_12_word:\n\t"
45536-
#else
45537-
"L_sp_384_sub_12_word_%=:\n\t"
45538-
#endif
45539-
"RSBS r11, r11, #0x0\n\t"
45540-
"LDM %[a]!, {r3, r4, r5, r6}\n\t"
45541-
"LDM %[b]!, {r7, r8, r9, r10}\n\t"
45542-
"SBCS r3, r3, r7\n\t"
45543-
"SBCS r4, r4, r8\n\t"
45544-
"SBCS r5, r5, r9\n\t"
45545-
"SBCS r6, r6, r10\n\t"
45546-
"STM %[r]!, {r3, r4, r5, r6}\n\t"
45547-
"SBC r11, r3, r3\n\t"
45548-
"CMP %[a], r12\n\t"
45549-
#if defined(__GNUC__)
45550-
"BNE L_sp_384_sub_12_word_%=\n\t"
45551-
#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ < 9000000)
45552-
"BNE.N L_sp_384_sub_12_word\n\t"
45553-
#else
45554-
"BNE.N L_sp_384_sub_12_word_%=\n\t"
45555-
#endif
45556-
"MOV %[r], r11\n\t"
45557-
: [r] "+r" (r), [a] "+r" (a), [b] "+r" (b)
45558-
:
45559-
: "memory", "cc", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
45560-
"r11", "r12"
45561-
);
45562-
return (word32)(size_t)r;
45563-
}
45564-
45565-
#else
45509+
#ifndef WOLFSSL_SP_SMALL
4556645510
/* Sub b from a into r. (r = a - b)
4556745511
*
4556845512
* r A single precision integer.
@@ -45613,7 +45557,7 @@ WC_OMIT_FRAME_POINTER static sp_digit sp_384_sub_12(sp_digit* r,
4561345557
return (word32)(size_t)r;
4561445558
}
4561545559

45616-
#endif /* WOLFSSL_SP_SMALL */
45560+
#endif /* !WOLFSSL_SP_SMALL */
4561745561
#ifdef WOLFSSL_SP_SMALL
4561845562
/* Conditionally add a and b using the mask m.
4561945563
* m is -1 to add and 0 when not.

0 commit comments

Comments
 (0)