Thumb2 inline ASM: IAR doesn't do register variables

IAR doesn't parse register variable declarations with specified
registers. IAR doesn't even honor the register keyword.
Can use small negative but IAR doesn't like it.
Specify the positive value instead.
Add a small code size version of mont_reduce_full using umlal and umaal.
Make 'asm' usage in variables use keyword '__asm__'.
Explicitly don't inline some functions when compiling with IAR.
This commit is contained in:
Sean Parkinson
2023-11-03 08:45:10 +10:00
parent c8af4edd74
commit cefe108cab
7 changed files with 3956 additions and 1081 deletions

View File

@ -44,6 +44,7 @@
#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
#define __volatile__ volatile
#define WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* __IAR_SYSTEMS_ICC__ */
#ifdef __KEIL__
#define __asm__ __asm
@ -198,12 +199,18 @@ static const uint32_t* L_AES_Thumb2_te = L_AES_Thumb2_te_data;
#endif /* HAVE_AES_DECRYPT || HAVE_AES_CBC || HAVE_AESCCM || HAVE_AESGCM || WOLFSSL_AES_DIRECT || WOLFSSL_AES_COUNTER */
#ifdef HAVE_AES_DECRYPT
void AES_invert_key(unsigned char* ks, word32 rounds);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_invert_key(unsigned char* ks_p, word32 rounds_p)
#else
void AES_invert_key(unsigned char* ks, word32 rounds)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register unsigned char* ks asm ("r0") = (unsigned char*)ks_p;
register word32 rounds asm ("r1") = (word32)rounds_p;
register uint32_t* L_AES_Thumb2_te_c asm ("r2") = (uint32_t*)L_AES_Thumb2_te;
register uint32_t* L_AES_Thumb2_td_c asm ("r3") = (uint32_t*)L_AES_Thumb2_td;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register unsigned char* ks __asm__ ("r0") = (unsigned char*)ks_p;
register word32 rounds __asm__ ("r1") = (word32)rounds_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_AES_Thumb2_te_c __asm__ ("r2") = (uint32_t*)L_AES_Thumb2_te;
register uint32_t* L_AES_Thumb2_td_c __asm__ ("r3") = (uint32_t*)L_AES_Thumb2_td;
__asm__ __volatile__ (
"MOV r12, %[L_AES_Thumb2_te]\n\t"
@ -314,13 +321,19 @@ static const uint32_t L_AES_Thumb2_rcon[] = {
void AES_set_encrypt_key(const unsigned char* key, word32 len,
unsigned char* ks);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_set_encrypt_key(const unsigned char* key_p, word32 len_p, unsigned char* ks_p)
#else
void AES_set_encrypt_key(const unsigned char* key, word32 len, unsigned char* ks)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const unsigned char* key asm ("r0") = (const unsigned char*)key_p;
register word32 len asm ("r1") = (word32)len_p;
register unsigned char* ks asm ("r2") = (unsigned char*)ks_p;
register uint32_t* L_AES_Thumb2_te_c asm ("r3") = (uint32_t*)L_AES_Thumb2_te;
register uint32_t* L_AES_Thumb2_rcon_c asm ("r4") = (uint32_t*)&L_AES_Thumb2_rcon;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const unsigned char* key __asm__ ("r0") = (const unsigned char*)key_p;
register word32 len __asm__ ("r1") = (word32)len_p;
register unsigned char* ks __asm__ ("r2") = (unsigned char*)ks_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_AES_Thumb2_te_c __asm__ ("r3") = (uint32_t*)L_AES_Thumb2_te;
register uint32_t* L_AES_Thumb2_rcon_c __asm__ ("r4") = (uint32_t*)&L_AES_Thumb2_rcon;
__asm__ __volatile__ (
"MOV r8, %[L_AES_Thumb2_te]\n\t"
@ -534,12 +547,18 @@ void AES_set_encrypt_key(const unsigned char* key_p, word32 len_p, unsigned char
}
void AES_encrypt_block(const uint32_t* te, int nr, int len, const uint32_t* ks);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_encrypt_block(const uint32_t* te_p, int nr_p, int len_p, const uint32_t* ks_p)
#else
void AES_encrypt_block(const uint32_t* te, int nr, int len, const uint32_t* ks)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const uint32_t* te asm ("r0") = (const uint32_t*)te_p;
register int nr asm ("r1") = (int)nr_p;
register int len asm ("r2") = (int)len_p;
register const uint32_t* ks asm ("r3") = (const uint32_t*)ks_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const uint32_t* te __asm__ ("r0") = (const uint32_t*)te_p;
register int nr __asm__ ("r1") = (int)nr_p;
register int len __asm__ ("r2") = (int)len_p;
register const uint32_t* ks __asm__ ("r3") = (const uint32_t*)ks_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"\n"
@ -762,14 +781,20 @@ static const uint32_t* L_AES_Thumb2_te_ecb = L_AES_Thumb2_te_data;
#if defined(HAVE_AESCCM) || defined(HAVE_AESGCM) || defined(WOLFSSL_AES_DIRECT) || defined(WOLFSSL_AES_COUNTER)
void AES_ECB_encrypt(const unsigned char* in, unsigned char* out,
unsigned long len, const unsigned char* ks, int nr);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_ECB_encrypt(const unsigned char* in_p, unsigned char* out_p, unsigned long len_p, const unsigned char* ks_p, int nr_p)
#else
void AES_ECB_encrypt(const unsigned char* in, unsigned char* out, unsigned long len, const unsigned char* ks, int nr)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const unsigned char* in asm ("r0") = (const unsigned char*)in_p;
register unsigned char* out asm ("r1") = (unsigned char*)out_p;
register unsigned long len asm ("r2") = (unsigned long)len_p;
register const unsigned char* ks asm ("r3") = (const unsigned char*)ks_p;
register int nr asm ("r4") = (int)nr_p;
register uint32_t* L_AES_Thumb2_te_ecb_c asm ("r5") = (uint32_t*)L_AES_Thumb2_te_ecb;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const unsigned char* in __asm__ ("r0") = (const unsigned char*)in_p;
register unsigned char* out __asm__ ("r1") = (unsigned char*)out_p;
register unsigned long len __asm__ ("r2") = (unsigned long)len_p;
register const unsigned char* ks __asm__ ("r3") = (const unsigned char*)ks_p;
register int nr __asm__ ("r4") = (int)nr_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_AES_Thumb2_te_ecb_c __asm__ ("r5") = (uint32_t*)L_AES_Thumb2_te_ecb;
__asm__ __volatile__ (
"MOV lr, %[in]\n\t"
@ -918,15 +943,21 @@ void AES_ECB_encrypt(const unsigned char* in_p, unsigned char* out_p, unsigned l
#ifdef HAVE_AES_CBC
void AES_CBC_encrypt(const unsigned char* in, unsigned char* out,
unsigned long len, const unsigned char* ks, int nr, unsigned char* iv);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_CBC_encrypt(const unsigned char* in_p, unsigned char* out_p, unsigned long len_p, const unsigned char* ks_p, int nr_p, unsigned char* iv_p)
#else
void AES_CBC_encrypt(const unsigned char* in, unsigned char* out, unsigned long len, const unsigned char* ks, int nr, unsigned char* iv)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const unsigned char* in asm ("r0") = (const unsigned char*)in_p;
register unsigned char* out asm ("r1") = (unsigned char*)out_p;
register unsigned long len asm ("r2") = (unsigned long)len_p;
register const unsigned char* ks asm ("r3") = (const unsigned char*)ks_p;
register int nr asm ("r4") = (int)nr_p;
register unsigned char* iv asm ("r5") = (unsigned char*)iv_p;
register uint32_t* L_AES_Thumb2_te_ecb_c asm ("r6") = (uint32_t*)L_AES_Thumb2_te_ecb;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const unsigned char* in __asm__ ("r0") = (const unsigned char*)in_p;
register unsigned char* out __asm__ ("r1") = (unsigned char*)out_p;
register unsigned long len __asm__ ("r2") = (unsigned long)len_p;
register const unsigned char* ks __asm__ ("r3") = (const unsigned char*)ks_p;
register int nr __asm__ ("r4") = (int)nr_p;
register unsigned char* iv __asm__ ("r5") = (unsigned char*)iv_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_AES_Thumb2_te_ecb_c __asm__ ("r6") = (uint32_t*)L_AES_Thumb2_te_ecb;
__asm__ __volatile__ (
"MOV r8, r4\n\t"
@ -1090,15 +1121,21 @@ void AES_CBC_encrypt(const unsigned char* in_p, unsigned char* out_p, unsigned l
#ifdef WOLFSSL_AES_COUNTER
void AES_CTR_encrypt(const unsigned char* in, unsigned char* out,
unsigned long len, const unsigned char* ks, int nr, unsigned char* ctr);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_CTR_encrypt(const unsigned char* in_p, unsigned char* out_p, unsigned long len_p, const unsigned char* ks_p, int nr_p, unsigned char* ctr_p)
#else
void AES_CTR_encrypt(const unsigned char* in, unsigned char* out, unsigned long len, const unsigned char* ks, int nr, unsigned char* ctr)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const unsigned char* in asm ("r0") = (const unsigned char*)in_p;
register unsigned char* out asm ("r1") = (unsigned char*)out_p;
register unsigned long len asm ("r2") = (unsigned long)len_p;
register const unsigned char* ks asm ("r3") = (const unsigned char*)ks_p;
register int nr asm ("r4") = (int)nr_p;
register unsigned char* ctr asm ("r5") = (unsigned char*)ctr_p;
register uint32_t* L_AES_Thumb2_te_ecb_c asm ("r6") = (uint32_t*)L_AES_Thumb2_te_ecb;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const unsigned char* in __asm__ ("r0") = (const unsigned char*)in_p;
register unsigned char* out __asm__ ("r1") = (unsigned char*)out_p;
register unsigned long len __asm__ ("r2") = (unsigned long)len_p;
register const unsigned char* ks __asm__ ("r3") = (const unsigned char*)ks_p;
register int nr __asm__ ("r4") = (int)nr_p;
register unsigned char* ctr __asm__ ("r5") = (unsigned char*)ctr_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_AES_Thumb2_te_ecb_c __asm__ ("r6") = (uint32_t*)L_AES_Thumb2_te_ecb;
__asm__ __volatile__ (
"MOV r12, r4\n\t"
@ -1283,11 +1320,17 @@ void AES_CTR_encrypt(const unsigned char* in_p, unsigned char* out_p, unsigned l
#ifdef HAVE_AES_DECRYPT
#if defined(WOLFSSL_AES_DIRECT) || defined(WOLFSSL_AES_COUNTER) || defined(HAVE_AES_CBC)
void AES_decrypt_block(const uint32_t* td, int nr, const uint8_t* td4);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_decrypt_block(const uint32_t* td_p, int nr_p, const uint8_t* td4_p)
#else
void AES_decrypt_block(const uint32_t* td, int nr, const uint8_t* td4)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const uint32_t* td asm ("r0") = (const uint32_t*)td_p;
register int nr asm ("r1") = (int)nr_p;
register const uint8_t* td4 asm ("r2") = (const uint8_t*)td4_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const uint32_t* td __asm__ ("r0") = (const uint32_t*)td_p;
register int nr __asm__ ("r1") = (int)nr_p;
register const uint8_t* td4 __asm__ ("r2") = (const uint8_t*)td4_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"\n"
@ -1543,15 +1586,21 @@ static const unsigned char L_AES_Thumb2_td4[] = {
#if defined(WOLFSSL_AES_DIRECT) || defined(WOLFSSL_AES_COUNTER)
void AES_ECB_decrypt(const unsigned char* in, unsigned char* out,
unsigned long len, const unsigned char* ks, int nr);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_ECB_decrypt(const unsigned char* in_p, unsigned char* out_p, unsigned long len_p, const unsigned char* ks_p, int nr_p)
#else
void AES_ECB_decrypt(const unsigned char* in, unsigned char* out, unsigned long len, const unsigned char* ks, int nr)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const unsigned char* in asm ("r0") = (const unsigned char*)in_p;
register unsigned char* out asm ("r1") = (unsigned char*)out_p;
register unsigned long len asm ("r2") = (unsigned long)len_p;
register const unsigned char* ks asm ("r3") = (const unsigned char*)ks_p;
register int nr asm ("r4") = (int)nr_p;
register uint32_t* L_AES_Thumb2_td_ecb_c asm ("r5") = (uint32_t*)L_AES_Thumb2_td_ecb;
register unsigned char* L_AES_Thumb2_td4_c asm ("r6") = (unsigned char*)&L_AES_Thumb2_td4;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const unsigned char* in __asm__ ("r0") = (const unsigned char*)in_p;
register unsigned char* out __asm__ ("r1") = (unsigned char*)out_p;
register unsigned long len __asm__ ("r2") = (unsigned long)len_p;
register const unsigned char* ks __asm__ ("r3") = (const unsigned char*)ks_p;
register int nr __asm__ ("r4") = (int)nr_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_AES_Thumb2_td_ecb_c __asm__ ("r5") = (uint32_t*)L_AES_Thumb2_td_ecb;
register unsigned char* L_AES_Thumb2_td4_c __asm__ ("r6") = (unsigned char*)&L_AES_Thumb2_td4;
__asm__ __volatile__ (
"MOV r8, r4\n\t"
@ -1697,16 +1746,22 @@ void AES_ECB_decrypt(const unsigned char* in_p, unsigned char* out_p, unsigned l
#ifdef HAVE_AES_CBC
void AES_CBC_decrypt(const unsigned char* in, unsigned char* out,
unsigned long len, const unsigned char* ks, int nr, unsigned char* iv);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_CBC_decrypt(const unsigned char* in_p, unsigned char* out_p, unsigned long len_p, const unsigned char* ks_p, int nr_p, unsigned char* iv_p)
#else
void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, unsigned long len, const unsigned char* ks, int nr, unsigned char* iv)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const unsigned char* in asm ("r0") = (const unsigned char*)in_p;
register unsigned char* out asm ("r1") = (unsigned char*)out_p;
register unsigned long len asm ("r2") = (unsigned long)len_p;
register const unsigned char* ks asm ("r3") = (const unsigned char*)ks_p;
register int nr asm ("r4") = (int)nr_p;
register unsigned char* iv asm ("r5") = (unsigned char*)iv_p;
register uint32_t* L_AES_Thumb2_td_ecb_c asm ("r6") = (uint32_t*)L_AES_Thumb2_td_ecb;
register unsigned char* L_AES_Thumb2_td4_c asm ("r7") = (unsigned char*)&L_AES_Thumb2_td4;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const unsigned char* in __asm__ ("r0") = (const unsigned char*)in_p;
register unsigned char* out __asm__ ("r1") = (unsigned char*)out_p;
register unsigned long len __asm__ ("r2") = (unsigned long)len_p;
register const unsigned char* ks __asm__ ("r3") = (const unsigned char*)ks_p;
register int nr __asm__ ("r4") = (int)nr_p;
register unsigned char* iv __asm__ ("r5") = (unsigned char*)iv_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_AES_Thumb2_td_ecb_c __asm__ ("r6") = (uint32_t*)L_AES_Thumb2_td_ecb;
register unsigned char* L_AES_Thumb2_td4_c __asm__ ("r7") = (unsigned char*)&L_AES_Thumb2_td4;
__asm__ __volatile__ (
"MOV r8, r4\n\t"
@ -2033,13 +2088,19 @@ static const uint32_t L_GCM_gmult_len_r[] = {
void GCM_gmult_len(unsigned char* x, const unsigned char** m,
const unsigned char* data, unsigned long len);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void GCM_gmult_len(unsigned char* x_p, const unsigned char** m_p, const unsigned char* data_p, unsigned long len_p)
#else
void GCM_gmult_len(unsigned char* x, const unsigned char** m, const unsigned char* data, unsigned long len)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register unsigned char* x asm ("r0") = (unsigned char*)x_p;
register const unsigned char** m asm ("r1") = (const unsigned char**)m_p;
register const unsigned char* data asm ("r2") = (const unsigned char*)data_p;
register unsigned long len asm ("r3") = (unsigned long)len_p;
register uint32_t* L_GCM_gmult_len_r_c asm ("r4") = (uint32_t*)&L_GCM_gmult_len_r;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register unsigned char* x __asm__ ("r0") = (unsigned char*)x_p;
register const unsigned char** m __asm__ ("r1") = (const unsigned char**)m_p;
register const unsigned char* data __asm__ ("r2") = (const unsigned char*)data_p;
register unsigned long len __asm__ ("r3") = (unsigned long)len_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_GCM_gmult_len_r_c __asm__ ("r4") = (uint32_t*)&L_GCM_gmult_len_r;
__asm__ __volatile__ (
"MOV lr, %[L_GCM_gmult_len_r]\n\t"
@ -2603,15 +2664,21 @@ void GCM_gmult_len(unsigned char* x_p, const unsigned char** m_p, const unsigned
static const uint32_t* L_AES_Thumb2_te_gcm = L_AES_Thumb2_te_data;
void AES_GCM_encrypt(const unsigned char* in, unsigned char* out,
unsigned long len, const unsigned char* ks, int nr, unsigned char* ctr);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void AES_GCM_encrypt(const unsigned char* in_p, unsigned char* out_p, unsigned long len_p, const unsigned char* ks_p, int nr_p, unsigned char* ctr_p)
#else
void AES_GCM_encrypt(const unsigned char* in, unsigned char* out, unsigned long len, const unsigned char* ks, int nr, unsigned char* ctr)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const unsigned char* in asm ("r0") = (const unsigned char*)in_p;
register unsigned char* out asm ("r1") = (unsigned char*)out_p;
register unsigned long len asm ("r2") = (unsigned long)len_p;
register const unsigned char* ks asm ("r3") = (const unsigned char*)ks_p;
register int nr asm ("r4") = (int)nr_p;
register unsigned char* ctr asm ("r5") = (unsigned char*)ctr_p;
register uint32_t* L_AES_Thumb2_te_gcm_c asm ("r6") = (uint32_t*)L_AES_Thumb2_te_gcm;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const unsigned char* in __asm__ ("r0") = (const unsigned char*)in_p;
register unsigned char* out __asm__ ("r1") = (unsigned char*)out_p;
register unsigned long len __asm__ ("r2") = (unsigned long)len_p;
register const unsigned char* ks __asm__ ("r3") = (const unsigned char*)ks_p;
register int nr __asm__ ("r4") = (int)nr_p;
register unsigned char* ctr __asm__ ("r5") = (unsigned char*)ctr_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_AES_Thumb2_te_gcm_c __asm__ ("r6") = (uint32_t*)L_AES_Thumb2_te_gcm;
__asm__ __volatile__ (
"MOV r12, r4\n\t"

View File

@ -44,6 +44,7 @@
#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
#define __volatile__ volatile
#define WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* __IAR_SYSTEMS_ICC__ */
#ifdef __KEIL__
#define __asm__ __asm
@ -60,8 +61,14 @@
#if defined(HAVE_CURVE25519) || defined(HAVE_ED25519)
#if !defined(CURVE25519_SMALL) || !defined(ED25519_SMALL)
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_init()
#else
void fe_init()
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"\n\t"
:
@ -71,8 +78,14 @@ void fe_init()
}
void fe_add_sub_op(void);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_add_sub_op()
#else
void fe_add_sub_op()
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
/* Add-Sub */
"LDRD r4, r5, [r2]\n\t"
@ -168,8 +181,14 @@ void fe_add_sub_op()
}
void fe_sub_op(void);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_sub_op()
#else
void fe_sub_op()
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
/* Sub */
"LDM r2!, {r6, r7, r8, r9, r10, r11, r12, lr}\n\t"
@ -202,11 +221,17 @@ void fe_sub_op()
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_sub(fe r_p, const fe a_p, const fe b_p)
#else
void fe_sub(fe r, const fe a, const fe b)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
register const sword32* b asm ("r2") = (const sword32*)b_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
register const sword32* b __asm__ ("r2") = (const sword32*)b_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"BL fe_sub_op\n\t"
@ -217,8 +242,14 @@ void fe_sub(fe r_p, const fe a_p, const fe b_p)
}
void fe_add_op(void);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_add_op()
#else
void fe_add_op()
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
/* Add */
"LDM r2!, {r6, r7, r8, r9, r10, r11, r12, lr}\n\t"
@ -251,11 +282,17 @@ void fe_add_op()
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_add(fe r_p, const fe a_p, const fe b_p)
#else
void fe_add(fe r, const fe a, const fe b)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
register const sword32* b asm ("r2") = (const sword32*)b_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
register const sword32* b __asm__ ("r2") = (const sword32*)b_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"BL fe_add_op\n\t"
@ -266,10 +303,16 @@ void fe_add(fe r_p, const fe a_p, const fe b_p)
}
#ifdef HAVE_ED25519
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_frombytes(fe out_p, const unsigned char* in_p)
#else
void fe_frombytes(fe out, const unsigned char* in)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* out asm ("r0") = (sword32*)out_p;
register const unsigned char* in asm ("r1") = (const unsigned char*)in_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* out __asm__ ("r0") = (sword32*)out_p;
register const unsigned char* in __asm__ ("r1") = (const unsigned char*)in_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"LDR r2, [%[in]]\n\t"
@ -295,10 +338,16 @@ void fe_frombytes(fe out_p, const unsigned char* in_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_tobytes(unsigned char* out_p, const fe n_p)
#else
void fe_tobytes(unsigned char* out, const fe n)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register unsigned char* out asm ("r0") = (unsigned char*)out_p;
register const sword32* n asm ("r1") = (const sword32*)n_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register unsigned char* out __asm__ ("r0") = (unsigned char*)out_p;
register const sword32* n __asm__ ("r1") = (const sword32*)n_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"LDM %[n], {r2, r3, r4, r5, r6, r7, r8, r9}\n\t"
@ -335,9 +384,15 @@ void fe_tobytes(unsigned char* out_p, const fe n_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_1(fe n_p)
#else
void fe_1(fe n)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* n asm ("r0") = (sword32*)n_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* n __asm__ ("r0") = (sword32*)n_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
/* Set one */
@ -356,9 +411,15 @@ void fe_1(fe n_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_0(fe n_p)
#else
void fe_0(fe n)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* n asm ("r0") = (sword32*)n_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* n __asm__ ("r0") = (sword32*)n_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
/* Set zero */
@ -377,10 +438,16 @@ void fe_0(fe n_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_copy(fe r_p, const fe a_p)
#else
void fe_copy(fe r, const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
/* Copy */
@ -398,10 +465,16 @@ void fe_copy(fe r_p, const fe a_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_neg(fe r_p, const fe a_p)
#else
void fe_neg(fe r, const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"MVN r7, #0x0\n\t"
@ -425,9 +498,15 @@ void fe_neg(fe r_p, const fe a_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
int fe_isnonzero(const fe a_p)
#else
int fe_isnonzero(const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const sword32* a asm ("r0") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const sword32* a __asm__ ("r0") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"LDM %[a], {r2, r3, r4, r5, r6, r7, r8, r9}\n\t"
@ -464,9 +543,15 @@ int fe_isnonzero(const fe a_p)
return (uint32_t)(size_t)a;
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
int fe_isnegative(const fe a_p)
#else
int fe_isnegative(const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register const sword32* a asm ("r0") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register const sword32* a __asm__ ("r0") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"LDM %[a]!, {r2, r3, r4, r5}\n\t"
@ -492,11 +577,17 @@ int fe_isnegative(const fe a_p)
#if defined(HAVE_ED25519_MAKE_KEY) || defined(HAVE_ED25519_SIGN)
#ifndef WC_NO_CACHE_RESISTANT
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_cmov_table(fe* r_p, fe* base_p, signed char b_p)
#else
void fe_cmov_table(fe* r, fe* base, signed char b)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register fe* r asm ("r0") = (fe*)r_p;
register fe* base asm ("r1") = (fe*)base_p;
register signed char b asm ("r2") = (signed char)b_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register fe* r __asm__ ("r0") = (fe*)r_p;
register fe* base __asm__ ("r1") = (fe*)base_p;
register signed char b __asm__ ("r2") = (signed char)b_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SXTB %[b], %[b]\n\t"
@ -1469,11 +1560,17 @@ void fe_cmov_table(fe* r_p, fe* base_p, signed char b_p)
}
#else
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_cmov_table(fe* r_p, fe* base_p, signed char b_p)
#else
void fe_cmov_table(fe* r, fe* base, signed char b)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register fe* r asm ("r0") = (fe*)r_p;
register fe* base asm ("r1") = (fe*)base_p;
register signed char b asm ("r2") = (signed char)b_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register fe* r __asm__ ("r0") = (fe*)r_p;
register fe* base __asm__ ("r1") = (fe*)base_p;
register signed char b __asm__ ("r2") = (signed char)b_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SXTB %[b], %[b]\n\t"
@ -1579,8 +1676,14 @@ void fe_cmov_table(fe* r_p, fe* base_p, signed char b_p)
#endif /* HAVE_ED25519 */
#ifdef WOLFSSL_SP_NO_UMAAL
void fe_mul_op(void);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_mul_op()
#else
void fe_mul_op()
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x28\n\t"
"STR r0, [sp, #36]\n\t"
@ -1959,8 +2062,14 @@ void fe_mul_op()
#else
void fe_mul_op(void);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_mul_op()
#else
void fe_mul_op()
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x2c\n\t"
"STRD r0, r1, [sp, #36]\n\t"
@ -2092,11 +2201,17 @@ void fe_mul_op()
}
#endif /* WOLFSSL_SP_NO_UMAAL */
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_mul(fe r_p, const fe a_p, const fe b_p)
#else
void fe_mul(fe r, const fe a, const fe b)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
register const sword32* b asm ("r2") = (const sword32*)b_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
register const sword32* b __asm__ ("r2") = (const sword32*)b_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"BL fe_mul_op\n\t"
@ -2108,8 +2223,14 @@ void fe_mul(fe r_p, const fe a_p, const fe b_p)
#ifdef WOLFSSL_SP_NO_UMAAL
void fe_sq_op(void);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_sq_op()
#else
void fe_sq_op()
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x44\n\t"
"STR r0, [sp, #64]\n\t"
@ -2381,8 +2502,14 @@ void fe_sq_op()
#else
void fe_sq_op(void);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_sq_op()
#else
void fe_sq_op()
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x20\n\t"
"STR r0, [sp, #28]\n\t"
@ -2500,10 +2627,16 @@ void fe_sq_op()
}
#endif /* WOLFSSL_SP_NO_UMAAL */
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_sq(fe r_p, const fe a_p)
#else
void fe_sq(fe r, const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"BL fe_sq_op\n\t"
@ -2515,10 +2648,16 @@ void fe_sq(fe r_p, const fe a_p)
#ifdef HAVE_CURVE25519
#ifdef WOLFSSL_SP_NO_UMAAL
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_mul121666(fe r_p, fe a_p)
#else
void fe_mul121666(fe r, fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register sword32* a asm ("r1") = (sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register sword32* a __asm__ ("r1") = (sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
/* Multiply by 121666 */
@ -2568,10 +2707,16 @@ void fe_mul121666(fe r_p, fe a_p)
}
#else
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_mul121666(fe r_p, fe a_p)
#else
void fe_mul121666(fe r, fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register sword32* a asm ("r1") = (sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register sword32* a __asm__ ("r1") = (sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
/* Multiply by 121666 */
@ -2609,11 +2754,17 @@ void fe_mul121666(fe r_p, fe a_p)
#endif /* WOLFSSL_SP_NO_UMAAL */
#ifndef WC_NO_CACHE_RESISTANT
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
int curve25519(byte* r_p, const byte* n_p, const byte* a_p)
#else
int curve25519(byte* r, const byte* n, const byte* a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register byte* r asm ("r0") = (byte*)r_p;
register const byte* n asm ("r1") = (const byte*)n_p;
register const byte* a asm ("r2") = (const byte*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register byte* r __asm__ ("r0") = (byte*)r_p;
register const byte* n __asm__ ("r1") = (const byte*)n_p;
register const byte* a __asm__ ("r2") = (const byte*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0xbc\n\t"
@ -3039,11 +3190,17 @@ int curve25519(byte* r_p, const byte* n_p, const byte* a_p)
}
#else
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
int curve25519(byte* r_p, const byte* n_p, const byte* a_p)
#else
int curve25519(byte* r, const byte* n, const byte* a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register byte* r asm ("r0") = (byte*)r_p;
register const byte* n asm ("r1") = (const byte*)n_p;
register const byte* a asm ("r2") = (const byte*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register byte* r __asm__ ("r0") = (byte*)r_p;
register const byte* n __asm__ ("r1") = (const byte*)n_p;
register const byte* a __asm__ ("r2") = (const byte*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0xc0\n\t"
@ -3387,10 +3544,16 @@ int curve25519(byte* r_p, const byte* n_p, const byte* a_p)
#endif /* WC_NO_CACHE_RESISTANT */
#endif /* HAVE_CURVE25519 */
#ifdef HAVE_ED25519
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_invert(fe r_p, const fe a_p)
#else
void fe_invert(fe r, const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x88\n\t"
@ -3590,10 +3753,16 @@ void fe_invert(fe r_p, const fe a_p)
}
#ifdef WOLFSSL_SP_NO_UMAAL
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_sq2(fe r_p, const fe a_p)
#else
void fe_sq2(fe r, const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x44\n\t"
@ -3898,10 +4067,16 @@ void fe_sq2(fe r_p, const fe a_p)
}
#else
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_sq2(fe r_p, const fe a_p)
#else
void fe_sq2(fe r, const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x24\n\t"
@ -4055,10 +4230,16 @@ void fe_sq2(fe r_p, const fe a_p)
}
#endif /* WOLFSSL_SP_NO_UMAAL */
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void fe_pow22523(fe r_p, const fe a_p)
#else
void fe_pow22523(fe r, const fe a)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register sword32* r asm ("r0") = (sword32*)r_p;
register const sword32* a asm ("r1") = (const sword32*)a_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register sword32* r __asm__ ("r0") = (sword32*)r_p;
register const sword32* a __asm__ ("r1") = (const sword32*)a_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x68\n\t"
@ -4257,10 +4438,16 @@ void fe_pow22523(fe r_p, const fe a_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void ge_p1p1_to_p2(ge_p2 * r_p, const ge_p1p1 * p_p)
#else
void ge_p1p1_to_p2(ge_p2 * r, const ge_p1p1 * p)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register ge_p2 * r asm ("r0") = (ge_p2 *)r_p;
register const ge_p1p1 * p asm ("r1") = (const ge_p1p1 *)p_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register ge_p2 * r __asm__ ("r0") = (ge_p2 *)r_p;
register const ge_p1p1 * p __asm__ ("r1") = (const ge_p1p1 *)p_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x8\n\t"
@ -4287,10 +4474,16 @@ void ge_p1p1_to_p2(ge_p2 * r_p, const ge_p1p1 * p_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void ge_p1p1_to_p3(ge_p3 * r_p, const ge_p1p1 * p_p)
#else
void ge_p1p1_to_p3(ge_p3 * r, const ge_p1p1 * p)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register ge_p3 * r asm ("r0") = (ge_p3 *)r_p;
register const ge_p1p1 * p asm ("r1") = (const ge_p1p1 *)p_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register ge_p3 * r __asm__ ("r0") = (ge_p3 *)r_p;
register const ge_p1p1 * p __asm__ ("r1") = (const ge_p1p1 *)p_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x8\n\t"
@ -4322,10 +4515,16 @@ void ge_p1p1_to_p3(ge_p3 * r_p, const ge_p1p1 * p_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void ge_p2_dbl(ge_p1p1 * r_p, const ge_p2 * p_p)
#else
void ge_p2_dbl(ge_p1p1 * r, const ge_p2 * p)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register ge_p1p1 * r asm ("r0") = (ge_p1p1 *)r_p;
register const ge_p2 * p asm ("r1") = (const ge_p2 *)p_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register ge_p1p1 * r __asm__ ("r0") = (ge_p1p1 *)r_p;
register const ge_p2 * p __asm__ ("r1") = (const ge_p2 *)p_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x8\n\t"
@ -4369,11 +4568,17 @@ void ge_p2_dbl(ge_p1p1 * r_p, const ge_p2 * p_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void ge_madd(ge_p1p1 * r_p, const ge_p3 * p_p, const ge_precomp * q_p)
#else
void ge_madd(ge_p1p1 * r, const ge_p3 * p, const ge_precomp * q)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register ge_p1p1 * r asm ("r0") = (ge_p1p1 *)r_p;
register const ge_p3 * p asm ("r1") = (const ge_p3 *)p_p;
register const ge_precomp * q asm ("r2") = (const ge_precomp *)q_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register ge_p1p1 * r __asm__ ("r0") = (ge_p1p1 *)r_p;
register const ge_p3 * p __asm__ ("r1") = (const ge_p3 *)p_p;
register const ge_precomp * q __asm__ ("r2") = (const ge_precomp *)q_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0xc\n\t"
@ -4451,11 +4656,17 @@ void ge_madd(ge_p1p1 * r_p, const ge_p3 * p_p, const ge_precomp * q_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void ge_msub(ge_p1p1 * r_p, const ge_p3 * p_p, const ge_precomp * q_p)
#else
void ge_msub(ge_p1p1 * r, const ge_p3 * p, const ge_precomp * q)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register ge_p1p1 * r asm ("r0") = (ge_p1p1 *)r_p;
register const ge_p3 * p asm ("r1") = (const ge_p3 *)p_p;
register const ge_precomp * q asm ("r2") = (const ge_precomp *)q_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register ge_p1p1 * r __asm__ ("r0") = (ge_p1p1 *)r_p;
register const ge_p3 * p __asm__ ("r1") = (const ge_p3 *)p_p;
register const ge_precomp * q __asm__ ("r2") = (const ge_precomp *)q_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0xc\n\t"
@ -4534,11 +4745,17 @@ void ge_msub(ge_p1p1 * r_p, const ge_p3 * p_p, const ge_precomp * q_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void ge_add(ge_p1p1 * r_p, const ge_p3 * p_p, const ge_cached* q_p)
#else
void ge_add(ge_p1p1 * r, const ge_p3 * p, const ge_cached* q)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register ge_p1p1 * r asm ("r0") = (ge_p1p1 *)r_p;
register const ge_p3 * p asm ("r1") = (const ge_p3 *)p_p;
register const ge_cached* q asm ("r2") = (const ge_cached*)q_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register ge_p1p1 * r __asm__ ("r0") = (ge_p1p1 *)r_p;
register const ge_p3 * p __asm__ ("r1") = (const ge_p3 *)p_p;
register const ge_cached* q __asm__ ("r2") = (const ge_cached*)q_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x2c\n\t"
@ -4617,11 +4834,17 @@ void ge_add(ge_p1p1 * r_p, const ge_p3 * p_p, const ge_cached* q_p)
);
}
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void ge_sub(ge_p1p1 * r_p, const ge_p3 * p_p, const ge_cached* q_p)
#else
void ge_sub(ge_p1p1 * r, const ge_p3 * p, const ge_cached* q)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register ge_p1p1 * r asm ("r0") = (ge_p1p1 *)r_p;
register const ge_p3 * p asm ("r1") = (const ge_p3 *)p_p;
register const ge_cached* q asm ("r2") = (const ge_cached*)q_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register ge_p1p1 * r __asm__ ("r0") = (ge_p1p1 *)r_p;
register const ge_p3 * p __asm__ ("r1") = (const ge_p3 *)p_p;
register const ge_cached* q __asm__ ("r2") = (const ge_cached*)q_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x2c\n\t"
@ -4701,9 +4924,15 @@ void ge_sub(ge_p1p1 * r_p, const ge_p3 * p_p, const ge_cached* q_p)
}
#ifdef WOLFSSL_SP_NO_UMAAL
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void sc_reduce(byte* s_p)
#else
void sc_reduce(byte* s)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register byte* s asm ("r0") = (byte*)s_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register byte* s __asm__ ("r0") = (byte*)s_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x38\n\t"
@ -5129,9 +5358,15 @@ void sc_reduce(byte* s_p)
}
#else
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void sc_reduce(byte* s_p)
#else
void sc_reduce(byte* s)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register byte* s asm ("r0") = (byte*)s_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register byte* s __asm__ ("r0") = (byte*)s_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x38\n\t"
@ -5430,12 +5665,18 @@ void sc_reduce(byte* s_p)
#endif /* WOLFSSL_SP_NO_UMAAL */
#ifdef HAVE_ED25519_SIGN
#ifdef WOLFSSL_SP_NO_UMAAL
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void sc_muladd(byte* s_p, const byte* a_p, const byte* b_p, const byte* c_p)
#else
void sc_muladd(byte* s, const byte* a, const byte* b, const byte* c)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register byte* s asm ("r0") = (byte*)s_p;
register const byte* a asm ("r1") = (const byte*)a_p;
register const byte* b asm ("r2") = (const byte*)b_p;
register const byte* c asm ("r3") = (const byte*)c_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register byte* s __asm__ ("r0") = (byte*)s_p;
register const byte* a __asm__ ("r1") = (const byte*)a_p;
register const byte* b __asm__ ("r2") = (const byte*)b_p;
register const byte* c __asm__ ("r3") = (const byte*)c_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x50\n\t"
@ -6218,12 +6459,18 @@ void sc_muladd(byte* s_p, const byte* a_p, const byte* b_p, const byte* c_p)
}
#else
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void sc_muladd(byte* s_p, const byte* a_p, const byte* b_p, const byte* c_p)
#else
void sc_muladd(byte* s, const byte* a, const byte* b, const byte* c)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register byte* s asm ("r0") = (byte*)s_p;
register const byte* a asm ("r1") = (const byte*)a_p;
register const byte* b asm ("r2") = (const byte*)b_p;
register const byte* c asm ("r3") = (const byte*)c_p;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register byte* s __asm__ ("r0") = (byte*)s_p;
register const byte* a __asm__ ("r1") = (const byte*)a_p;
register const byte* b __asm__ ("r2") = (const byte*)b_p;
register const byte* c __asm__ ("r3") = (const byte*)c_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
__asm__ __volatile__ (
"SUB sp, sp, #0x50\n\t"

View File

@ -44,6 +44,7 @@
#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
#define __volatile__ volatile
#define WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* __IAR_SYSTEMS_ICC__ */
#ifdef __KEIL__
#define __asm__ __asm
@ -73,12 +74,18 @@ static const uint32_t L_SHA256_transform_len_k[] = {
};
void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void Transform_Sha256_Len(wc_Sha256* sha256_p, const byte* data_p, word32 len_p)
#else
void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register wc_Sha256* sha256 asm ("r0") = (wc_Sha256*)sha256_p;
register const byte* data asm ("r1") = (const byte*)data_p;
register word32 len asm ("r2") = (word32)len_p;
register uint32_t* L_SHA256_transform_len_k_c asm ("r3") = (uint32_t*)&L_SHA256_transform_len_k;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register wc_Sha256* sha256 __asm__ ("r0") = (wc_Sha256*)sha256_p;
register const byte* data __asm__ ("r1") = (const byte*)data_p;
register word32 len __asm__ ("r2") = (word32)len_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint32_t* L_SHA256_transform_len_k_c __asm__ ("r3") = (uint32_t*)&L_SHA256_transform_len_k;
__asm__ __volatile__ (
"SUB sp, sp, #0xc0\n\t"

View File

@ -44,6 +44,7 @@
#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
#define __volatile__ volatile
#define WOLFSSL_NO_VAR_ASSIGN_REG
#endif /* __IAR_SYSTEMS_ICC__ */
#ifdef __KEIL__
#define __asm__ __asm
@ -97,12 +98,18 @@ static const uint64_t L_SHA512_transform_len_k[] = {
};
void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len);
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
void Transform_Sha512_Len(wc_Sha512* sha512_p, const byte* data_p, word32 len_p)
#else
void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len)
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
{
register wc_Sha512* sha512 asm ("r0") = (wc_Sha512*)sha512_p;
register const byte* data asm ("r1") = (const byte*)data_p;
register word32 len asm ("r2") = (word32)len_p;
register uint64_t* L_SHA512_transform_len_k_c asm ("r3") = (uint64_t*)&L_SHA512_transform_len_k;
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
register wc_Sha512* sha512 __asm__ ("r0") = (wc_Sha512*)sha512_p;
register const byte* data __asm__ ("r1") = (const byte*)data_p;
register word32 len __asm__ ("r2") = (word32)len_p;
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
register uint64_t* L_SHA512_transform_len_k_c __asm__ ("r3") = (uint64_t*)&L_SHA512_transform_len_k;
__asm__ __volatile__ (
"SUB sp, sp, #0xc0\n\t"

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* sp_x86_64_asm
*
/* sp_x86_64_asm.S */
/*
* Copyright (C) 2006-2023 wolfSSL Inc.
*
* This file is part of wolfSSL.

View File

@ -1,5 +1,5 @@
; /* sp_x86_64_asm
; *
; /* sp_x86_64_asm.asm */
; /*
; * Copyright (C) 2006-2023 wolfSSL Inc.
; *
; * This file is part of wolfSSL.