Skip to content

Commit 63b9d13

Browse files
authored
Merge pull request #9790 from bigbrett/sp-rsa-unused-var
Fix macro protection in SP code for RSA_LOW_MEM
2 parents 5960a36 + 140f9aa commit 63b9d13

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

wolfcrypt/src/sp_arm32.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17706,6 +17706,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em,
1770617706
}
1770717707

1770817708
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
17709+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
1770917710
#ifdef WOLFSSL_SP_SMALL
1771017711
/* Conditionally add a and b using the mask m.
1771117712
* m is -1 to add and 0 when not.
@@ -17911,6 +17912,7 @@ WC_OMIT_FRAME_POINTER static sp_digit sp_2048_cond_add_32(sp_digit* r,
1791117912
}
1791217913

1791317914
#endif /* WOLFSSL_SP_SMALL */
17915+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
1791417916
/* RSA private key operation.
1791517917
*
1791617918
* in Array of bytes representing the number to exponentiate, base.
@@ -45428,6 +45430,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
4542845430
}
4542945431

4543045432
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
45433+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
4543145434
#ifdef WOLFSSL_SP_SMALL
4543245435
/* Conditionally add a and b using the mask m.
4543345436
* m is -1 to add and 0 when not.
@@ -45689,6 +45692,7 @@ WC_OMIT_FRAME_POINTER static sp_digit sp_3072_cond_add_48(sp_digit* r,
4568945692
}
4569045693

4569145694
#endif /* WOLFSSL_SP_SMALL */
45695+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
4569245696
/* RSA private key operation.
4569345697
*
4569445698
* in Array of bytes representing the number to exponentiate, base.
@@ -61034,6 +61038,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
6103461038
}
6103561039

6103661040
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
61041+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
6103761042
#ifdef WOLFSSL_SP_SMALL
6103861043
/* Conditionally add a and b using the mask m.
6103961044
* m is -1 to add and 0 when not.
@@ -61351,6 +61356,7 @@ WC_OMIT_FRAME_POINTER static sp_digit sp_4096_cond_add_64(sp_digit* r,
6135161356
}
6135261357

6135361358
#endif /* WOLFSSL_SP_SMALL */
61359+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
6135461360
/* RSA private key operation.
6135561361
*
6135661362
* in Array of bytes representing the number to exponentiate, base.

wolfcrypt/src/sp_arm64.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6140,6 +6140,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em,
61406140
}
61416141

61426142
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
6143+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
61436144
#ifdef WOLFSSL_SP_SMALL
61446145
/* Conditionally add a and b using the mask m.
61456146
* m is -1 to add and 0 when not.
@@ -6176,6 +6177,7 @@ static sp_digit sp_2048_cond_add_16(sp_digit* r, const sp_digit* a, const sp_dig
61766177
}
61776178
#endif /* WOLFSSL_SP_SMALL */
61786179

6180+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
61796181
/* RSA private key operation.
61806182
*
61816183
* in Array of bytes representing the number to exponentiate, base.
@@ -15515,6 +15517,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
1551515517
}
1551615518

1551715519
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
15520+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
1551815521
#ifdef WOLFSSL_SP_SMALL
1551915522
/* Conditionally add a and b using the mask m.
1552015523
* m is -1 to add and 0 when not.
@@ -15551,6 +15554,7 @@ static sp_digit sp_3072_cond_add_24(sp_digit* r, const sp_digit* a, const sp_dig
1555115554
}
1555215555
#endif /* WOLFSSL_SP_SMALL */
1555315556

15557+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
1555415558
/* RSA private key operation.
1555515559
*
1555615560
* in Array of bytes representing the number to exponentiate, base.
@@ -20524,6 +20528,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
2052420528
}
2052520529

2052620530
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
20531+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
2052720532
#ifdef WOLFSSL_SP_SMALL
2052820533
/* Conditionally add a and b using the mask m.
2052920534
* m is -1 to add and 0 when not.
@@ -20560,6 +20565,7 @@ static sp_digit sp_4096_cond_add_32(sp_digit* r, const sp_digit* a, const sp_dig
2056020565
}
2056120566
#endif /* WOLFSSL_SP_SMALL */
2056220567

20568+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
2056320569
/* RSA private key operation.
2056420570
*
2056520571
* in Array of bytes representing the number to exponentiate, base.

wolfcrypt/src/sp_armthumb.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28024,6 +28024,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em,
2802428024
}
2802528025

2802628026
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
28027+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
2802728028
/* Conditionally add a and b using the mask m.
2802828029
* m is -1 to add and 0 when not.
2802928030
*
@@ -28093,6 +28094,7 @@ SP_NOINLINE static sp_digit sp_2048_cond_add_32(sp_digit* r, const sp_digit* a,
2809328094
return (word32)(size_t)r;
2809428095
}
2809528096

28097+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
2809628098
/* RSA private key operation.
2809728099
*
2809828100
* in Array of bytes representing the number to exponentiate, base.
@@ -80194,6 +80196,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
8019480196
}
8019580197

8019680198
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
80199+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
8019780200
/* Conditionally add a and b using the mask m.
8019880201
* m is -1 to add and 0 when not.
8019980202
*
@@ -80263,6 +80266,7 @@ SP_NOINLINE static sp_digit sp_3072_cond_add_48(sp_digit* r, const sp_digit* a,
8026380266
return (word32)(size_t)r;
8026480267
}
8026580268

80269+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
8026680270
/* RSA private key operation.
8026780271
*
8026880272
* in Array of bytes representing the number to exponentiate, base.
@@ -92650,6 +92654,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
9265092654
}
9265192655

9265292656
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
92657+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
9265392658
/* Conditionally add a and b using the mask m.
9265492659
* m is -1 to add and 0 when not.
9265592660
*
@@ -92724,6 +92729,7 @@ SP_NOINLINE static sp_digit sp_4096_cond_add_64(sp_digit* r, const sp_digit* a,
9272492729
return (word32)(size_t)r;
9272592730
}
9272692731

92732+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
9272792733
/* RSA private key operation.
9272892734
*
9272992735
* in Array of bytes representing the number to exponentiate, base.

wolfcrypt/src/sp_c32.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,7 +3646,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em,
36463646

36473647
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
36483648
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
3649-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
3649+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
36503650
/* RSA private key operation.
36513651
*
36523652
* in Array of bytes representing the number to exponentiate, base.
@@ -6751,7 +6751,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
67516751

67526752
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
67536753
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
6754-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
6754+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
67556755
/* RSA private key operation.
67566756
*
67576757
* in Array of bytes representing the number to exponentiate, base.
@@ -10516,7 +10516,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
1051610516

1051710517
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
1051810518
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
10519-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
10519+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
1052010520
/* RSA private key operation.
1052110521
*
1052210522
* in Array of bytes representing the number to exponentiate, base.
@@ -13703,7 +13703,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
1370313703

1370413704
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
1370513705
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
13706-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
13706+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
1370713707
/* RSA private key operation.
1370813708
*
1370913709
* in Array of bytes representing the number to exponentiate, base.
@@ -17376,7 +17376,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
1737617376

1737717377
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
1737817378
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
17379-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
17379+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
1738017380
/* RSA private key operation.
1738117381
*
1738217382
* in Array of bytes representing the number to exponentiate, base.

wolfcrypt/src/sp_c64.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em,
23172317

23182318
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
23192319
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
2320-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
2320+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
23212321
/* RSA private key operation.
23222322
*
23232323
* in Array of bytes representing the number to exponentiate, base.
@@ -5564,7 +5564,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em,
55645564

55655565
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
55665566
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
5567-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
5567+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
55685568
/* RSA private key operation.
55695569
*
55705570
* in Array of bytes representing the number to exponentiate, base.
@@ -8494,7 +8494,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
84948494

84958495
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
84968496
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
8497-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
8497+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
84988498
/* RSA private key operation.
84998499
*
85008500
* in Array of bytes representing the number to exponentiate, base.
@@ -11890,7 +11890,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
1189011890

1189111891
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
1189211892
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
11893-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
11893+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
1189411894
/* RSA private key operation.
1189511895
*
1189611896
* in Array of bytes representing the number to exponentiate, base.
@@ -14857,7 +14857,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
1485714857

1485814858
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
1485914859
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
14860-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
14860+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
1486114861
/* RSA private key operation.
1486214862
*
1486314863
* in Array of bytes representing the number to exponentiate, base.
@@ -18350,7 +18350,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
1835018350

1835118351
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
1835218352
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
18353-
#endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
18353+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
1835418354
/* RSA private key operation.
1835518355
*
1835618356
* in Array of bytes representing the number to exponentiate, base.

wolfcrypt/src/sp_cortexm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8884,6 +8884,7 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em,
88848884
}
88858885

88868886
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
8887+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
88878888
#ifdef WOLFSSL_SP_SMALL
88888889
/* Conditionally add a and b using the mask m.
88898890
* m is -1 to add and 0 when not.
@@ -9089,6 +9090,7 @@ WC_OMIT_FRAME_POINTER static sp_digit sp_2048_cond_add_32(sp_digit* r,
90899090
}
90909091

90919092
#endif /* WOLFSSL_SP_SMALL */
9093+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
90929094
/* RSA private key operation.
90939095
*
90949096
* in Array of bytes representing the number to exponentiate, base.
@@ -21488,6 +21490,7 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
2148821490
}
2148921491

2149021492
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
21493+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
2149121494
#ifdef WOLFSSL_SP_SMALL
2149221495
/* Conditionally add a and b using the mask m.
2149321496
* m is -1 to add and 0 when not.
@@ -21749,6 +21752,7 @@ WC_OMIT_FRAME_POINTER static sp_digit sp_3072_cond_add_48(sp_digit* r,
2174921752
}
2175021753

2175121754
#endif /* WOLFSSL_SP_SMALL */
21755+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
2175221756
/* RSA private key operation.
2175321757
*
2175421758
* in Array of bytes representing the number to exponentiate, base.
@@ -29835,6 +29839,7 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
2983529839
}
2983629840

2983729841
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
29842+
#if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
2983829843
#ifdef WOLFSSL_SP_SMALL
2983929844
/* Conditionally add a and b using the mask m.
2984029845
* m is -1 to add and 0 when not.
@@ -30152,6 +30157,7 @@ WC_OMIT_FRAME_POINTER static sp_digit sp_4096_cond_add_64(sp_digit* r,
3015230157
}
3015330158

3015430159
#endif /* WOLFSSL_SP_SMALL */
30160+
#endif /* !SP_RSA_PRIVATE_EXP_D && !RSA_LOW_MEM */
3015530161
/* RSA private key operation.
3015630162
*
3015730163
* in Array of bytes representing the number to exponentiate, base.

0 commit comments

Comments
 (0)