Browse Source

Merge pull request #3156 from dgarske/armasm

Fixes for building with `WOLFSSL_ARMASM` when `user_settings.h` is used
toddouska 3 years ago
parent
commit
c67aeba806

+ 20 - 8
IDE/WIN/user_settings.h

@@ -10,7 +10,6 @@
 		52114C8721B5A7320022ADA1 /* sp_c64.c in Sources */ = {isa = PBXBuildFile; fileRef = 52114C8621B5A7320022ADA1 /* sp_c64.c */; };
 		A46FE16F2493E8F800A25BE7 /* armv8-chacha.c in Sources */ = {isa = PBXBuildFile; fileRef = A46FE14C2493E8F500A25BE7 /* armv8-chacha.c */; };
 		A46FE1702493E8F800A25BE7 /* sp_int.c in Sources */ = {isa = PBXBuildFile; fileRef = A46FE14D2493E8F600A25BE7 /* sp_int.c */; };
-		A46FE1732493E8F800A25BE7 /* armv8-poly1305.c in Sources */ = {isa = PBXBuildFile; fileRef = A46FE1502493E8F600A25BE7 /* armv8-poly1305.c */; };
 		A46FE1742493E8F800A25BE7 /* sp_cortexm.c in Sources */ = {isa = PBXBuildFile; fileRef = A46FE1512493E8F600A25BE7 /* sp_cortexm.c */; };
 		A46FE1752493E8F800A25BE7 /* blake2s.c in Sources */ = {isa = PBXBuildFile; fileRef = A46FE1522493E8F600A25BE7 /* blake2s.c */; };
 		A46FE1772493E8F800A25BE7 /* wc_pkcs11.c in Sources */ = {isa = PBXBuildFile; fileRef = A46FE1542493E8F600A25BE7 /* wc_pkcs11.c */; };
@@ -95,17 +94,20 @@
 		A4ADF9281FCE0C5600A06E90 /* ecc.c in Sources */ = {isa = PBXBuildFile; fileRef = A4ADF8CC1FCE0C5500A06E90 /* ecc.c */; };
 		A4ADF92A1FCE0C5600A06E90 /* coding.c in Sources */ = {isa = PBXBuildFile; fileRef = A4ADF8CE1FCE0C5500A06E90 /* coding.c */; };
 		A4ADF92C1FCE0C5600A06E90 /* ge_low_mem.c in Sources */ = {isa = PBXBuildFile; fileRef = A4ADF8D01FCE0C5500A06E90 /* ge_low_mem.c */; };
+		A4CA2EA324C8AF97003CCC50 /* armv8-sha512.c in Sources */ = {isa = PBXBuildFile; fileRef = A4CA2E9E24C8AF97003CCC50 /* armv8-sha512.c */; };
 		A4DFEC0D1FD4CAA300A7BB33 /* benchmark.c in Sources */ = {isa = PBXBuildFile; fileRef = A4DFEC0C1FD4CAA300A7BB33 /* benchmark.c */; };
 		A4DFEC101FD4CB8500A7BB33 /* armv8-sha256.c in Sources */ = {isa = PBXBuildFile; fileRef = A4DFEC0E1FD4CB8500A7BB33 /* armv8-sha256.c */; };
 		A4DFEC111FD4CB8500A7BB33 /* armv8-aes.c in Sources */ = {isa = PBXBuildFile; fileRef = A4DFEC0F1FD4CB8500A7BB33 /* armv8-aes.c */; };
 		A4DFEC3C1FD6B9CC00A7BB33 /* test.c in Sources */ = {isa = PBXBuildFile; fileRef = A4DFEC3B1FD6B9CC00A7BB33 /* test.c */; };
+		CB81DE1D24C9284700B98DA6 /* armv8-poly1305.c in Sources */ = {isa = PBXBuildFile; fileRef = CB81DE1C24C9284700B98DA6 /* armv8-poly1305.c */; };
+		CB81DE1F24C93EC000B98DA6 /* armv8-curve25519.S in Sources */ = {isa = PBXBuildFile; fileRef = CB81DE1E24C93EC000B98DA6 /* armv8-curve25519.S */; };
+		CB81DE2324C93FB300B98DA6 /* armv8-sha512-asm.S in Sources */ = {isa = PBXBuildFile; fileRef = CB81DE2224C93FB300B98DA6 /* armv8-sha512-asm.S */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
 		52114C8621B5A7320022ADA1 /* sp_c64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sp_c64.c; path = ../../../wolfcrypt/src/sp_c64.c; sourceTree = "<group>"; };
 		A46FE14C2493E8F500A25BE7 /* armv8-chacha.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-chacha.c"; path = "../../../wolfcrypt/src/port/arm/armv8-chacha.c"; sourceTree = "<group>"; };
 		A46FE14D2493E8F600A25BE7 /* sp_int.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sp_int.c; path = ../../../wolfcrypt/src/sp_int.c; sourceTree = "<group>"; };
-		A46FE1502493E8F600A25BE7 /* armv8-poly1305.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-poly1305.c"; path = "../../../wolfcrypt/src/port/arm/armv8-poly1305.c"; sourceTree = "<group>"; };
 		A46FE1512493E8F600A25BE7 /* sp_cortexm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sp_cortexm.c; path = ../../../wolfcrypt/src/sp_cortexm.c; sourceTree = "<group>"; };
 		A46FE1522493E8F600A25BE7 /* blake2s.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = blake2s.c; path = ../../../wolfcrypt/src/blake2s.c; sourceTree = "<group>"; };
 		A46FE1542493E8F600A25BE7 /* wc_pkcs11.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wc_pkcs11.c; path = ../../../wolfcrypt/src/wc_pkcs11.c; sourceTree = "<group>"; };
@@ -195,10 +197,14 @@
 		A4ADF8CC1FCE0C5500A06E90 /* ecc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ecc.c; path = ../../../wolfcrypt/src/ecc.c; sourceTree = "<group>"; };
 		A4ADF8CE1FCE0C5500A06E90 /* coding.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = coding.c; path = ../../../wolfcrypt/src/coding.c; sourceTree = "<group>"; };
 		A4ADF8D01FCE0C5500A06E90 /* ge_low_mem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ge_low_mem.c; path = ../../../wolfcrypt/src/ge_low_mem.c; sourceTree = "<group>"; };
+		A4CA2E9E24C8AF97003CCC50 /* armv8-sha512.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-sha512.c"; path = "../../../wolfcrypt/src/port/arm/armv8-sha512.c"; sourceTree = "<group>"; };
 		A4DFEC0C1FD4CAA300A7BB33 /* benchmark.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = benchmark.c; path = ../../../wolfcrypt/benchmark/benchmark.c; sourceTree = "<group>"; };
 		A4DFEC0E1FD4CB8500A7BB33 /* armv8-sha256.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-sha256.c"; path = "../../../wolfcrypt/src/port/arm/armv8-sha256.c"; sourceTree = "<group>"; };
 		A4DFEC0F1FD4CB8500A7BB33 /* armv8-aes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-aes.c"; path = "../../../wolfcrypt/src/port/arm/armv8-aes.c"; sourceTree = "<group>"; };
 		A4DFEC3B1FD6B9CC00A7BB33 /* test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = test.c; path = ../../../wolfcrypt/test/test.c; sourceTree = "<group>"; };
+		CB81DE1C24C9284700B98DA6 /* armv8-poly1305.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-poly1305.c"; path = "../../../wolfcrypt/src/port/arm/armv8-poly1305.c"; sourceTree = "<group>"; };
+		CB81DE1E24C93EC000B98DA6 /* armv8-curve25519.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "armv8-curve25519.S"; path = "../../../wolfcrypt/src/port/arm/armv8-curve25519.S"; sourceTree = "<group>"; };
+		CB81DE2224C93FB300B98DA6 /* armv8-sha512-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "armv8-sha512-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-sha512-asm.S"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -273,8 +279,11 @@
 				A4ADF8921FCE0C4E00A06E90 /* arc4.c */,
 				A4DFEC0F1FD4CB8500A7BB33 /* armv8-aes.c */,
 				A46FE14C2493E8F500A25BE7 /* armv8-chacha.c */,
-				A46FE1502493E8F600A25BE7 /* armv8-poly1305.c */,
+				CB81DE1E24C93EC000B98DA6 /* armv8-curve25519.S */,
+				CB81DE1C24C9284700B98DA6 /* armv8-poly1305.c */,
 				A4DFEC0E1FD4CB8500A7BB33 /* armv8-sha256.c */,
+				A4CA2E9E24C8AF97003CCC50 /* armv8-sha512.c */,
+				CB81DE2224C93FB300B98DA6 /* armv8-sha512-asm.S */,
 				A4ADF8A01FCE0C4F00A06E90 /* asm.c */,
 				A4ADF8C21FCE0C5300A06E90 /* asn.c */,
 				A4ADF8B11FCE0C5100A06E90 /* blake2b.c */,
@@ -434,6 +443,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				CB81DE2324C93FB300B98DA6 /* armv8-sha512-asm.S in Sources */,
 				A4ADF9041FCE0C5600A06E90 /* des3.c in Sources */,
 				A46FE18A2493E8F800A25BE7 /* ge_448.c in Sources */,
 				A4ADF9121FCE0C5600A06E90 /* wc_port.c in Sources */,
@@ -458,6 +468,8 @@
 				A4ADF90D1FCE0C5600A06E90 /* blake2b.c in Sources */,
 				A4ADF9071FCE0C5600A06E90 /* dh.c in Sources */,
 				A46FE1912493E8F800A25BE7 /* sp_c32.c in Sources */,
+				CB81DE1D24C9284700B98DA6 /* armv8-poly1305.c in Sources */,
+				CB81DE1F24C93EC000B98DA6 /* armv8-curve25519.S in Sources */,
 				A4ADF8F31FCE0C5600A06E90 /* rsa.c in Sources */,
 				A46FE1752493E8F800A25BE7 /* blake2s.c in Sources */,
 				A4ADF8FA1FCE0C5600A06E90 /* pkcs12.c in Sources */,
@@ -498,7 +510,6 @@
 				A4ADF9051FCE0C5600A06E90 /* cmac.c in Sources */,
 				52114C8721B5A7320022ADA1 /* sp_c64.c in Sources */,
 				A4ADF8F41FCE0C5600A06E90 /* pkcs7.c in Sources */,
-				A46FE1732493E8F800A25BE7 /* armv8-poly1305.c in Sources */,
 				A4ADF90B1FCE0C5600A06E90 /* logging.c in Sources */,
 				A4ADF8E01FCE0C5600A06E90 /* ecc_fp.c in Sources */,
 				A4ADF8EB1FCE0C5600A06E90 /* chacha20_poly1305.c in Sources */,
@@ -522,6 +533,7 @@
 				A4ADF8D71FCE0C5600A06E90 /* wolfevent.c in Sources */,
 				A46FE1802493E8F800A25BE7 /* ed448.c in Sources */,
 				A4DFEC0D1FD4CAA300A7BB33 /* benchmark.c in Sources */,
+				A4CA2EA324C8AF97003CCC50 /* armv8-sha512.c in Sources */,
 				A4ADF91D1FCE0C5600A06E90 /* cpuid.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -671,10 +683,10 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_STYLE = Automatic;
-				DEVELOPMENT_TEAM = 2S2PAGNS5B;
+				DEVELOPMENT_TEAM = TJKX238PPD;
 				INFOPLIST_FILE = wolfBench/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				PRODUCT_BUNDLE_IDENTIFIER = com.wolfSSL.wolfBench;
+				PRODUCT_BUNDLE_IDENTIFIER = "com.wolfSSL.wolfBench-ios";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
@@ -685,10 +697,10 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_STYLE = Automatic;
-				DEVELOPMENT_TEAM = 2S2PAGNS5B;
+				DEVELOPMENT_TEAM = TJKX238PPD;
 				INFOPLIST_FILE = wolfBench/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				PRODUCT_BUNDLE_IDENTIFIER = com.wolfSSL.wolfBench;
+				PRODUCT_BUNDLE_IDENTIFIER = "com.wolfSSL.wolfBench-ios";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};

+ 3 - 1
IDE/XCODE/user_settings.h

@@ -56,7 +56,9 @@
     #define HAVE_CHACHA
 
     #define HAVE_CURVE25519
-    #define HAVE_ED25519
+    #ifndef WOLFSSL_ARMASM
+        #define HAVE_ED25519
+    #endif
 
     /* TLS extensions */
     #define HAVE_ONE_TIME_AUTH

+ 7 - 9
wolfcrypt/src/port/arm/armv8-chacha.c

@@ -2186,17 +2186,15 @@ static WC_INLINE void wc_Chacha_encrypt_64(const word32* input, const byte* m,
         "BEQ    L_chacha20_arm64_64_done_%= \n\t"
         "\n"
     "L_chacha20_arm64_64_lt_8_%=: \n\t"
-        "MOV    x4, v0.D[0] \n\t"
-        "LSL    x5, %[bytes], #3 \n\t"
+        "MOV	x4, v0.D[0] \n\t"
         "\n"
     "L_chacha20_arm64_64_loop_lt_8_%=: \n\t"
-        "LDRB   w6, [%[m], %[bytes]] \n\t"
-        "ROR    x7, x4, x5 \n\t"
-        "EOR    w6, w6, w7 \n\t"
-        "STRB   w6, [%[c], %[bytes]] \n\t"
-        "SUBS   %[bytes], %[bytes], #1 \n\t"
-        "SUB    x5, x5, #8 \n\t"
-        "BGE    L_chacha20_arm64_64_loop_lt_8_%= \n\t"
+        "LDRB	w6, [%[m]], #1 \n\t"
+        "EOR	w6, w6, w4 \n\t"
+        "STRB	w6, [%[c]], #1 \n\t"
+        "SUBS	%[bytes], %[bytes], #1 \n\t"
+        "LSR	x4, x4, #8 \n\t"
+        "BGT	L_chacha20_arm64_64_loop_lt_8_%= \n\t"
         "\n"
     "L_chacha20_arm64_64_done_%=: \n\t"
         : [input] "+r" (input), [m] "+r" (m), [c] "+r" (c), [bytes] "+r" (bytes64)

File diff suppressed because it is too large
+ 573 - 72
wolfcrypt/src/port/arm/armv8-curve25519.S


+ 341 - 5
wolfcrypt/src/port/arm/armv8-curve25519.c

@@ -19,17 +19,17 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
 
+#ifdef HAVE_CONFIG_H
+    #include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <wolfssl/wolfcrypt/settings.h>
+
 /* Generated using (from wolfssl):
  *   cd ../scripts
  *   ruby ./x25519/x25519.rb arm64 ../wolfssl/wolfcrypt/src/port/arm/armv8-curve25519.c
  */
 #ifdef WOLFSSL_ARMASM
 #ifdef __aarch64__
-#include <stdint.h>
-#ifdef HAVE_CONFIG_H
-    #include <config.h>
-#endif /* HAVE_CONFIG_H */
-#include <wolfssl/wolfcrypt/settings.h>
 #include <wolfssl/wolfcrypt/fe_operations.h>
 
 void fe_init()
@@ -771,123 +771,235 @@ void fe_invert(fe r, const fe a)
         "str	%x[r], [x29, #144]\n\t"
         "str	%x[a], [x29, #152]\n\t"
         "add	x0, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #48\n\t"
         "add	x1, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x1, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "ldr	x1, [x29, #152]\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #16\n\t"
         "add	x1, x29, #16\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #48\n\t"
         "add	x1, x29, #48\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x20, #4\n\t"
         "add	x1, x29, #0x50\n\t"
         "\n"
     "L_fe_invert1_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x20, x20, #1\n\t"
         "cmp	x20, #0\n\t"
         "bne	L_fe_invert1_%=\n\t"
         "add	x0, x29, #48\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x50\n\t"
         "add	x1, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x20, #9\n\t"
         "add	x1, x29, #0x50\n\t"
         "\n"
     "L_fe_invert2_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x20, x20, #1\n\t"
         "cmp	x20, #0\n\t"
         "bne	L_fe_invert2_%=\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x70\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x20, #19\n\t"
         "add	x1, x29, #0x70\n\t"
         "\n"
     "L_fe_invert3_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x20, x20, #1\n\t"
         "cmp	x20, #0\n\t"
         "bne	L_fe_invert3_%=\n\t"
         "add	x0, x29, #0x50\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x20, #10\n\t"
         "add	x1, x29, #0x50\n\t"
         "\n"
     "L_fe_invert4_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x20, x20, #1\n\t"
         "cmp	x20, #0\n\t"
         "bne	L_fe_invert4_%=\n\t"
         "add	x0, x29, #48\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x50\n\t"
         "add	x1, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x20, #49\n\t"
         "add	x1, x29, #0x50\n\t"
         "\n"
     "L_fe_invert5_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x20, x20, #1\n\t"
         "cmp	x20, #0\n\t"
         "bne	L_fe_invert5_%=\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x70\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x20, #0x63\n\t"
         "add	x1, x29, #0x70\n\t"
         "\n"
     "L_fe_invert6_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x20, x20, #1\n\t"
         "cmp	x20, #0\n\t"
         "bne	L_fe_invert6_%=\n\t"
         "add	x0, x29, #0x50\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x20, #50\n\t"
         "add	x1, x29, #0x50\n\t"
         "\n"
     "L_fe_invert7_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x20, x20, #1\n\t"
         "cmp	x20, #0\n\t"
         "bne	L_fe_invert7_%=\n\t"
         "add	x0, x29, #48\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x20, #5\n\t"
         "add	x1, x29, #48\n\t"
         "\n"
     "L_fe_invert8_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x20, x20, #1\n\t"
         "cmp	x20, #0\n\t"
         "bne	L_fe_invert8_%=\n\t"
         "ldr	x0, [x29, #144]\n\t"
         "add	x2, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "ldp	x29, x30, [sp], #0xa0\n\t"
         : [r] "+r" (r), [a] "+r" (a)
         :
@@ -2210,123 +2322,235 @@ int curve25519(byte* r, byte* n, byte* a)
         /* Invert */
         "add	x0, x29, #48\n\t"
         "add	x1, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x50\n\t"
         "add	x1, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x1, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x1, x29, #16\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #48\n\t"
         "add	x1, x29, #48\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x70\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x50\n\t"
         "add	x1, x29, #0x50\n\t"
         "add	x2, x29, #0x70\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x70\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x24, #4\n\t"
         "add	x1, x29, #0x70\n\t"
         "\n"
     "L_curve25519_inv_1_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x24, x24, #1\n\t"
         "cmp	x24, #0\n\t"
         "bne	L_curve25519_inv_1_%=\n\t"
         "add	x0, x29, #0x50\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x70\n\t"
         "add	x1, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x24, #9\n\t"
         "add	x1, x29, #0x70\n\t"
         "\n"
     "L_curve25519_inv_2_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x24, x24, #1\n\t"
         "cmp	x24, #0\n\t"
         "bne	L_curve25519_inv_2_%=\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x90\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x24, #19\n\t"
         "add	x1, x29, #0x90\n\t"
         "\n"
     "L_curve25519_inv_3_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x24, x24, #1\n\t"
         "cmp	x24, #0\n\t"
         "bne	L_curve25519_inv_3_%=\n\t"
         "add	x0, x29, #0x70\n\t"
         "add	x2, x29, #0x70\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x24, #10\n\t"
         "add	x1, x29, #0x70\n\t"
         "\n"
     "L_curve25519_inv_4_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x24, x24, #1\n\t"
         "cmp	x24, #0\n\t"
         "bne	L_curve25519_inv_4_%=\n\t"
         "add	x0, x29, #0x50\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x70\n\t"
         "add	x1, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x24, #49\n\t"
         "add	x1, x29, #0x70\n\t"
         "\n"
     "L_curve25519_inv_5_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x24, x24, #1\n\t"
         "cmp	x24, #0\n\t"
         "bne	L_curve25519_inv_5_%=\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x90\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x24, #0x63\n\t"
         "add	x1, x29, #0x90\n\t"
         "\n"
     "L_curve25519_inv_6_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x24, x24, #1\n\t"
         "cmp	x24, #0\n\t"
         "bne	L_curve25519_inv_6_%=\n\t"
         "add	x0, x29, #0x70\n\t"
         "add	x2, x29, #0x70\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x24, #50\n\t"
         "add	x1, x29, #0x70\n\t"
         "\n"
     "L_curve25519_inv_7_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x24, x24, #1\n\t"
         "cmp	x24, #0\n\t"
         "bne	L_curve25519_inv_7_%=\n\t"
         "add	x0, x29, #0x50\n\t"
         "add	x2, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x24, #5\n\t"
         "add	x1, x29, #0x50\n\t"
         "\n"
     "L_curve25519_inv_8_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x24, x24, #1\n\t"
         "cmp	x24, #0\n\t"
         "bne	L_curve25519_inv_8_%=\n\t"
         "add	x0, x29, #16\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "ldr	%x[r], [x29, #176]\n\t"
         /* Multiply */
         "ldp	x6, x7, [%x[r]]\n\t"
@@ -2486,122 +2710,234 @@ void fe_pow22523(fe r, const fe a)
         "str	%x[r], [x29, #112]\n\t"
         "str	%x[a], [x29, #120]\n\t"
         "add	x0, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #48\n\t"
         "add	x1, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x1, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "ldr	x1, [x29, #120]\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #16\n\t"
         "add	x1, x29, #16\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "add	x1, x29, #48\n\t"
         "add	x2, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #48\n\t"
         "add	x1, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x21, #4\n\t"
         "add	x1, x29, #48\n\t"
         "\n"
     "L_fe_pow22523_1_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x21, x21, #1\n\t"
         "cmp	x21, #0\n\t"
         "bne	L_fe_pow22523_1_%=\n\t"
         "add	x0, x29, #16\n\t"
         "add	x2, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #48\n\t"
         "add	x1, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x21, #9\n\t"
         "add	x1, x29, #48\n\t"
         "\n"
     "L_fe_pow22523_2_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x21, x21, #1\n\t"
         "cmp	x21, #0\n\t"
         "bne	L_fe_pow22523_2_%=\n\t"
         "add	x2, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x21, #19\n\t"
         "add	x1, x29, #0x50\n\t"
         "\n"
     "L_fe_pow22523_3_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x21, x21, #1\n\t"
         "cmp	x21, #0\n\t"
         "bne	L_fe_pow22523_3_%=\n\t"
         "add	x0, x29, #48\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x21, #10\n\t"
         "add	x1, x29, #48\n\t"
         "\n"
     "L_fe_pow22523_4_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x21, x21, #1\n\t"
         "cmp	x21, #0\n\t"
         "bne	L_fe_pow22523_4_%=\n\t"
         "add	x0, x29, #16\n\t"
         "add	x2, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #48\n\t"
         "add	x1, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x21, #49\n\t"
         "add	x1, x29, #48\n\t"
         "\n"
     "L_fe_pow22523_5_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x21, x21, #1\n\t"
         "cmp	x21, #0\n\t"
         "bne	L_fe_pow22523_5_%=\n\t"
         "add	x2, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "add	x0, x29, #0x50\n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "mov	x21, #0x63\n\t"
         "add	x1, x29, #0x50\n\t"
         "\n"
     "L_fe_pow22523_6_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x21, x21, #1\n\t"
         "cmp	x21, #0\n\t"
         "bne	L_fe_pow22523_6_%=\n\t"
         "add	x0, x29, #48\n\t"
         "add	x2, x29, #48\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x21, #50\n\t"
         "add	x1, x29, #48\n\t"
         "\n"
     "L_fe_pow22523_7_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x21, x21, #1\n\t"
         "cmp	x21, #0\n\t"
         "bne	L_fe_pow22523_7_%=\n\t"
         "add	x0, x29, #16\n\t"
         "add	x2, x29, #16\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "mov	x21, #2\n\t"
         "add	x1, x29, #16\n\t"
         "\n"
     "L_fe_pow22523_8_%=: \n\t"
+#ifndef __APPLE__
         "bl	fe_sq\n\t"
+#else
+        "bl	_fe_sq\n\t"
+#endif /* __APPLE__ */
         "sub	x21, x21, #1\n\t"
         "cmp	x21, #0\n\t"
         "bne	L_fe_pow22523_8_%=\n\t"
         "ldr	x0, [x29, #112]\n\t"
         "ldr	x2, [x29, #120]\n\t"
+#ifndef __APPLE__
         "bl	fe_mul\n\t"
+#else
+        "bl	_fe_mul\n\t"
+#endif /* __APPLE__ */
         "ldp	x29, x30, [sp], #0x80\n\t"
         : [r] "+r" (r), [a] "+r" (a)
         :

+ 8 - 9
wolfcrypt/src/port/arm/armv8-poly1305.c

@@ -24,9 +24,6 @@
  * and Daniel J. Bernstein
  */
 
-
-#ifdef __aarch64__
-
 #ifdef HAVE_CONFIG_H
     #include <config.h>
 #endif
@@ -34,6 +31,8 @@
 #include <wolfssl/wolfcrypt/settings.h>
 
 #ifdef WOLFSSL_ARMASM
+#ifdef __aarch64__
+
 #ifdef HAVE_POLY1305
 #include <wolfssl/wolfcrypt/poly1305.h>
 #include <wolfssl/wolfcrypt/error-crypt.h>
@@ -208,11 +207,11 @@ void poly1305_blocks(Poly1305* ctx, const unsigned char *m,
         "MOV        v28.D[0], x9         \n\t"
         "AND        x22, x22, #0x3ffffff \n\t"
         /* Zero accumulator registers */
-        "MOVI       v15.2D, #0x0         \n\t"
-        "MOVI       v16.2D, #0x0         \n\t"
-        "MOVI       v17.2D, #0x0         \n\t"
-        "MOVI       v18.2D, #0x0         \n\t"
-        "MOVI       v19.2D, #0x0         \n\t"
+        "MOVI       v15.16B, #0x0        \n\t"
+        "MOVI       v16.16B, #0x0        \n\t"
+        "MOVI       v17.16B, #0x0        \n\t"
+        "MOVI       v18.16B, #0x0        \n\t"
+        "MOVI       v19.16B, #0x0        \n\t"
         /* Set hibit */
         "CMP        %[finished], #0      \n\t"
         "CSET       x9, EQ               \n\t"
@@ -1162,5 +1161,5 @@ int wc_Poly1305Final(Poly1305* ctx, byte* mac)
 }
 
 #endif /* HAVE_POLY1305 */
-#endif /* WOLFSSL_ARMASM */
 #endif /* __aarch64__ */
+#endif /* WOLFSSL_ARMASM */

+ 51 - 6
wolfcrypt/src/port/arm/armv8-sha512-asm.S

@@ -19,17 +19,30 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
 
+#ifdef HAVE_CONFIG_H
+    #include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <wolfssl/wolfcrypt/settings.h>
+
 /* Generated using (from wolfssl):
  *   cd ../scripts
  *   ruby ./sha2/sha512.rb arm64 ../wolfssl/wolfcrypt/src/port/arm/armv8-sha512-asm.S
  */
 #ifdef WOLFSSL_ARMASM
 #ifdef __aarch64__
+#ifndef __APPLE__
 	.text
-	.section	.rodata
 	.type	L_SHA512_transform_neon_len_k, %object
+	.section	.rodata
 	.size	L_SHA512_transform_neon_len_k, 640
+#else
+	.section	__DATA,__data
+#endif /* __APPLE__ */
+#ifndef __APPLE__
 	.align	3
+#else
+	.p2align	3
+#endif /* __APPLE__ */
 L_SHA512_transform_neon_len_k:
 	.xword	0x428a2f98d728ae22
 	.xword	0x7137449123ef65cd
@@ -111,18 +124,33 @@ L_SHA512_transform_neon_len_k:
 	.xword	0x597f299cfc657e2a
 	.xword	0x5fcb6fab3ad6faec
 	.xword	0x6c44198c4a475817
+#ifndef __APPLE__
 	.text
-	.section	.rodata
 	.type	L_SHA512_transform_neon_len_ror8, %object
+	.section	.rodata
 	.size	L_SHA512_transform_neon_len_ror8, 16
+#else
+	.section	__DATA,__data
+#endif /* __APPLE__ */
+#ifndef __APPLE__
 	.align	4
+#else
+	.p2align	4
+#endif /* __APPLE__ */
 L_SHA512_transform_neon_len_ror8:
 	.xword	0x7060504030201, 0x80f0e0d0c0b0a09
-	.text
-	.align	2
-	.globl	Transform_Sha512_Len
-	.type	Transform_Sha512_Len, %function
+#ifndef __APPLE__
+.text
+.globl	Transform_Sha512_Len
+.type	Transform_Sha512_Len,@function
+.align	2
 Transform_Sha512_Len:
+#else
+.section	__TEXT,__text
+.globl	_Transform_Sha512_Len
+.p2align	2
+_Transform_Sha512_Len:
+#endif /* __APPLE__ */
 	stp	x29, x30, [sp, #-128]!
 	add	x29, sp, #0
 	str	x17, [x29, #16]
@@ -133,8 +161,18 @@ Transform_Sha512_Len:
 	stp	x26, x27, [x29, #80]
 	stp	d8, d9, [x29, #96]
 	stp	d10, d11, [x29, #112]
+#ifndef __APPLE__
 	adr	x3, L_SHA512_transform_neon_len_k
+#else
+	adrp	x3, L_SHA512_transform_neon_len_k@PAGE
+	add	x3, x3, :lo12:L_SHA512_transform_neon_len_k@PAGEOFF
+#endif /* __APPLE__ */
+#ifndef __APPLE__
 	adr	x27, L_SHA512_transform_neon_len_ror8
+#else
+	adrp	x27, L_SHA512_transform_neon_len_ror8@PAGE
+	add	x27, x27, :lo12:L_SHA512_transform_neon_len_ror8@PAGEOFF
+#endif /* __APPLE__ */
 	ld1	{v11.16b}, [x27]
 	# Load digest into working vars
 	ldp	x4, x5, [x0]
@@ -1026,7 +1064,12 @@ L_sha512_len_neon_start:
 	add	x6, x6, x21
 	add	x5, x5, x20
 	add	x4, x4, x19
+#ifndef __APPLE__
 	adr	x3, L_SHA512_transform_neon_len_k
+#else
+	adrp	x3, L_SHA512_transform_neon_len_k@PAGE
+	add	x3, x3, :lo12:L_SHA512_transform_neon_len_k@PAGEOFF
+#endif /* __APPLE__ */
 	subs	w2, w2, #0x80
 	bne	L_sha512_len_neon_begin
 	stp	x4, x5, [x0]
@@ -1043,7 +1086,9 @@ L_sha512_len_neon_start:
 	ldp	d10, d11, [x29, #112]
 	ldp	x29, x30, [sp], #0x80
 	ret
+#ifndef __APPLE__
 	.size	Transform_Sha512_Len,.-Transform_Sha512_Len
+#endif /* __APPLE__ */
 #endif /* __aarch64__ */
 #endif /* WOLFSSL_ARMASM */
 

+ 20 - 5
wolfcrypt/src/port/arm/armv8-sha512-asm.c

@@ -19,17 +19,17 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  */
 
+#ifdef HAVE_CONFIG_H
+    #include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <wolfssl/wolfcrypt/settings.h>
+
 /* Generated using (from wolfssl):
  *   cd ../scripts
  *   ruby ./sha2/sha512.rb arm64 ../wolfssl/wolfcrypt/src/port/arm/armv8-sha512-asm.c
  */
 #ifdef WOLFSSL_ARMASM
 #ifdef __aarch64__
-#include <stdint.h>
-#ifdef HAVE_CONFIG_H
-    #include <config.h>
-#endif /* HAVE_CONFIG_H */
-#include <wolfssl/wolfcrypt/settings.h>
 #include <wolfssl/wolfcrypt/sha512.h>
 
 static const uint64_t L_SHA512_transform_neon_len_k[] = {
@@ -125,8 +125,18 @@ void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len)
     __asm__ __volatile__ (
         "stp	x29, x30, [sp, #-16]!\n\t"
         "add	x29, sp, #0\n\t"
+#ifndef __APPLE__
         "adr	x3, %[L_SHA512_transform_neon_len_k]\n\t"
+#else
+        "adrp	x3, %[L_SHA512_transform_neon_len_k]@PAGE\n\t"
+        "add	x3, x3, %[L_SHA512_transform_neon_len_k]@PAGEOFF\n\t"
+#endif /* __APPLE__ */
+#ifndef __APPLE__
         "adr	x27, %[L_SHA512_transform_neon_len_ror8]\n\t"
+#else
+        "adrp	x27, %[L_SHA512_transform_neon_len_ror8]@PAGE\n\t"
+        "add	x27, x27, %[L_SHA512_transform_neon_len_ror8]@PAGEOFF\n\t"
+#endif /* __APPLE__ */
         "ld1	{v11.16b}, [x27]\n\t"
         /* Load digest into working vars */
         "ldp	x4, x5, [%x[sha512]]\n\t"
@@ -1020,7 +1030,12 @@ void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len)
         "add	x6, x6, x21\n\t"
         "add	x5, x5, x20\n\t"
         "add	x4, x4, x19\n\t"
+#ifndef __APPLE__
         "adr	x3, %[L_SHA512_transform_neon_len_k]\n\t"
+#else
+        "adrp	x3, %[L_SHA512_transform_neon_len_k]@PAGE\n\t"
+        "add	x3, x3, %[L_SHA512_transform_neon_len_k]@PAGEOFF\n\t"
+#endif /* __APPLE__ */
         "subs	%w[len], %w[len], #0x80\n\t"
         "bne	L_sha512_len_neon_begin_%=\n\t"
         "stp	x4, x5, [%x[sha512]]\n\t"

+ 51 - 51
wolfcrypt/src/sp_arm32.c

@@ -7394,11 +7394,11 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[128], m[64], r[128];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -7734,10 +7734,10 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -7796,16 +7796,16 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[64], tmpb[64];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 
@@ -18953,11 +18953,11 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[192], m[96], r[192];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -19373,10 +19373,10 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -19435,16 +19435,16 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[96], tmpb[96];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 
@@ -26940,11 +26940,11 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[256], m[128], r[256];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -27440,10 +27440,10 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -27502,16 +27502,16 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[128], tmpb[128];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 

+ 51 - 51
wolfcrypt/src/sp_arm64.c

@@ -4888,11 +4888,11 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[64], m[32], r[64];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -5124,10 +5124,10 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -5186,16 +5186,16 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[32], tmpb[32];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 
@@ -12597,11 +12597,11 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[96], m[48], r[96];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -12861,10 +12861,10 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -12923,16 +12923,16 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[48], tmpb[48];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 
@@ -17528,11 +17528,11 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[128], m[64], r[128];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -17820,10 +17820,10 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -17882,16 +17882,16 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[64], tmpb[64];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 

+ 51 - 51
wolfcrypt/src/sp_armthumb.c

@@ -4259,11 +4259,11 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[128], m[64], r[128];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -4432,10 +4432,10 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -4494,16 +4494,16 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[64], tmpb[64];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 
@@ -10065,11 +10065,11 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[192], m[96], r[192];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -10238,10 +10238,10 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -10300,16 +10300,16 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[96], tmpb[96];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 
@@ -13952,11 +13952,11 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[256], m[128], r[256];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -14126,10 +14126,10 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -14188,16 +14188,16 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[128], tmpb[128];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 

+ 63 - 63
wolfcrypt/src/sp_c32.c

@@ -2087,7 +2087,7 @@ static int sp_2048_mod_exp_45(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 90) + 90];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -3040,7 +3040,7 @@ static int sp_2048_mod_exp_90(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 180) + 180];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -3192,10 +3192,10 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 {
 #ifdef WOLFSSL_SP_SMALL
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
-    sp_digit* norm;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
+    sp_digit* norm = NULL;
     sp_digit e[1] = {0};
     sp_digit mp;
     int i;
@@ -3289,9 +3289,9 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 #else
     sp_digit* d = NULL;
 #endif
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     sp_digit e[1] = {0};
     int err = MP_OKAY;
 
@@ -3430,10 +3430,10 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -3530,15 +3530,15 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
 #else
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* dq;
-    sp_digit* qi;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* dq = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)dm;
@@ -5928,7 +5928,7 @@ static int sp_3072_mod_exp_67(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 134) + 134];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -6917,7 +6917,7 @@ static int sp_3072_mod_exp_134(sp_digit* r, const sp_digit* a, const sp_digit* e
     sp_digit td[(32 * 268) + 268];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -7069,10 +7069,10 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 {
 #ifdef WOLFSSL_SP_SMALL
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
-    sp_digit* norm;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
+    sp_digit* norm = NULL;
     sp_digit e[1] = {0};
     sp_digit mp;
     int i;
@@ -7166,9 +7166,9 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 #else
     sp_digit* d = NULL;
 #endif
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     sp_digit e[1] = {0};
     int err = MP_OKAY;
 
@@ -7307,10 +7307,10 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -7407,15 +7407,15 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
 #else
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* dq;
-    sp_digit* qi;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* dq = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)dm;
@@ -9992,7 +9992,7 @@ static int sp_4096_mod_exp_98(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 196) + 196];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -10958,7 +10958,7 @@ static int sp_4096_mod_exp_196(sp_digit* r, const sp_digit* a, const sp_digit* e
     sp_digit td[(32 * 392) + 392];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -11110,10 +11110,10 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 {
 #ifdef WOLFSSL_SP_SMALL
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
-    sp_digit* norm;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
+    sp_digit* norm = NULL;
     sp_digit e[1] = {0};
     sp_digit mp;
     int i;
@@ -11207,9 +11207,9 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 #else
     sp_digit* d = NULL;
 #endif
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     sp_digit e[1] = {0};
     int err = MP_OKAY;
 
@@ -11348,10 +11348,10 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -11448,15 +11448,15 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
 #else
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* dq;
-    sp_digit* qi;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* dq = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)dm;

+ 63 - 63
wolfcrypt/src/sp_c64.c

@@ -1735,7 +1735,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 36) + 36];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -2680,7 +2680,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 72) + 72];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -2832,10 +2832,10 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 {
 #ifdef WOLFSSL_SP_SMALL
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
-    sp_digit* norm;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
+    sp_digit* norm = NULL;
     sp_digit e[1] = {0};
     sp_digit mp;
     int i;
@@ -2929,9 +2929,9 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 #else
     sp_digit* d = NULL;
 #endif
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     sp_digit e[1] = {0};
     int err = MP_OKAY;
 
@@ -3070,10 +3070,10 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -3170,15 +3170,15 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
 #else
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* dq;
-    sp_digit* qi;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* dq = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)dm;
@@ -5916,7 +5916,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 54) + 54];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -6831,7 +6831,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 108) + 108];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -6983,10 +6983,10 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 {
 #ifdef WOLFSSL_SP_SMALL
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
-    sp_digit* norm;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
+    sp_digit* norm = NULL;
     sp_digit e[1] = {0};
     sp_digit mp;
     int i;
@@ -7080,9 +7080,9 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 #else
     sp_digit* d = NULL;
 #endif
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     sp_digit e[1] = {0};
     int err = MP_OKAY;
 
@@ -7221,10 +7221,10 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -7321,15 +7321,15 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
 #else
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* dq;
-    sp_digit* qi;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* dq = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)dm;
@@ -10213,7 +10213,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 78) + 78];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -11227,7 +11227,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e,
     sp_digit td[(32 * 156) + 156];
 #endif
     sp_digit* t[32];
-    sp_digit* rt;
+    sp_digit* rt = NULL;
     sp_digit* norm;
     sp_digit mp = 1;
     sp_digit n;
@@ -11379,10 +11379,10 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 {
 #ifdef WOLFSSL_SP_SMALL
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
-    sp_digit* norm;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
+    sp_digit* norm = NULL;
     sp_digit e[1] = {0};
     sp_digit mp;
     int i;
@@ -11476,9 +11476,9 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
 #else
     sp_digit* d = NULL;
 #endif
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     sp_digit e[1] = {0};
     int err = MP_OKAY;
 
@@ -11617,10 +11617,10 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -11717,15 +11717,15 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
 #else
 #if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* dq;
-    sp_digit* qi;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* dq = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)dm;

+ 51 - 51
wolfcrypt/src/sp_cortexm.c

@@ -4013,11 +4013,11 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[128], m[64], r[128];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -4184,10 +4184,10 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -4246,16 +4246,16 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[64], tmpb[64];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 
@@ -8668,11 +8668,11 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[192], m[96], r[192];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -8839,10 +8839,10 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -8901,16 +8901,16 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[96], tmpb[96];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 
@@ -11875,11 +11875,11 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm,
     sp_digit a[256], m[128], r[256];
 #else
     sp_digit* d = NULL;
-    sp_digit* a;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* a = NULL;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
 #endif
-    sp_digit *ah;
+    sp_digit *ah = NULL;
     sp_digit e[1];
     int err = MP_OKAY;
 
@@ -12047,10 +12047,10 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
     byte* out, word32* outLen)
 {
 #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
-    sp_digit* a;
+    sp_digit* a = NULL;
     sp_digit* d = NULL;
-    sp_digit* m;
-    sp_digit* r;
+    sp_digit* m = NULL;
+    sp_digit* r = NULL;
     int err = MP_OKAY;
 
     (void)pm;
@@ -12109,16 +12109,16 @@ int sp_RsaPrivate_4096(const byte* in, word32 inLen, mp_int* dm,
     sp_digit tmpa[128], tmpb[128];
 #else
     sp_digit* t = NULL;
-    sp_digit* a;
-    sp_digit* p;
-    sp_digit* q;
-    sp_digit* dp;
-    sp_digit* tmpa;
-    sp_digit* tmpb;
-#endif
-    sp_digit* r;
-    sp_digit* qi;
-    sp_digit* dq;
+    sp_digit* a = NULL;
+    sp_digit* p = NULL;
+    sp_digit* q = NULL;
+    sp_digit* dp = NULL;
+    sp_digit* tmpa = NULL;
+    sp_digit* tmpb = NULL;
+#endif
+    sp_digit* r = NULL;
+    sp_digit* qi = NULL;
+    sp_digit* dq = NULL;
     sp_digit c;
     int err = MP_OKAY;
 

Some files were not shown because too many files changed in this diff